@squidcloud/client 1.0.168 → 1.0.169
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +17 -10
- package/dist/internal-common/src/public-types/ai-assistant.public-types.d.ts +25 -0
- package/dist/internal-common/src/public-types/ai-chatbot.public-context.d.ts +12 -0
- package/dist/internal-common/src/public-types/ai-chatbot.public-types.d.ts +31 -0
- package/dist/internal-common/src/public-types/api-call.public-context.d.ts +14 -0
- package/dist/internal-common/src/public-types/application.public-types.d.ts +149 -0
- package/dist/internal-common/src/public-types/base-query-builder.public-types.d.ts +147 -0
- package/dist/internal-common/src/public-types/bundle-api.public-types.d.ts +57 -0
- package/dist/internal-common/src/public-types/bundle-data.public-types.d.ts +8 -0
- package/dist/internal-common/src/public-types/communication.public-types.d.ts +12 -0
- package/dist/internal-common/src/public-types/context.public-types.d.ts +40 -0
- package/dist/internal-common/src/public-types/distributed-lock.public-context.d.ts +4 -0
- package/dist/internal-common/src/public-types/document.public-types.d.ts +32 -0
- package/dist/internal-common/src/public-types/graphql.public-context.d.ts +7 -0
- package/dist/internal-common/src/public-types/graphql.public-types.d.ts +9 -0
- package/dist/internal-common/src/public-types/http-status.enum.d.ts +50 -0
- package/dist/internal-common/src/public-types/integration.public-types.d.ts +61 -0
- package/dist/internal-common/src/public-types/integrations/ai_chatbot.types.d.ts +32 -0
- package/dist/internal-common/src/public-types/integrations/api.types.d.ts +81 -0
- package/dist/internal-common/src/public-types/integrations/auth.types.d.ts +54 -0
- package/dist/internal-common/src/public-types/integrations/database.types.d.ts +206 -0
- package/dist/internal-common/src/public-types/integrations/observability.types.d.ts +24 -0
- package/dist/internal-common/src/public-types/integrations/queue-types.d.ts +40 -0
- package/dist/internal-common/src/public-types/integrations/schemas.d.ts +70 -0
- package/dist/internal-common/src/public-types/mutation.public-context.d.ts +14 -0
- package/dist/internal-common/src/public-types/mutation.public-types.d.ts +53 -0
- package/dist/internal-common/src/public-types/native-query.public-context.d.ts +7 -0
- package/dist/internal-common/src/public-types/native-query.public-types.d.ts +16 -0
- package/dist/internal-common/src/public-types/pagination.public-types.d.ts +62 -0
- package/dist/internal-common/src/public-types/query.public-context.d.ts +137 -0
- package/dist/internal-common/src/public-types/query.public-types.d.ts +64 -0
- package/dist/internal-common/src/public-types/regions.public-types.d.ts +5 -0
- package/dist/internal-common/src/public-types/schema.public-types.d.ts +46 -0
- package/dist/internal-common/src/public-types/secret.public-types.d.ts +16 -0
- package/dist/internal-common/src/public-types/serialized-query.public-types.d.ts +24 -0
- package/dist/internal-common/src/public-types/socket.public-types.d.ts +5 -0
- package/dist/internal-common/src/public-types/topic.public-context.d.ts +10 -0
- package/dist/internal-common/src/public-types/typescript.public-types.d.ts +15 -0
- package/dist/internal-common/src/public-utils/id-utils.d.ts +6 -0
- package/dist/internal-common/src/types/ai-assistant.types.d.ts +1 -0
- package/dist/internal-common/src/types/ai-chatbot.types.d.ts +1 -0
- package/dist/internal-common/src/types/api.types.d.ts +2 -0
- package/dist/internal-common/src/types/backend-function.types.d.ts +1 -0
- package/dist/internal-common/src/types/backend-run.types.d.ts +1 -0
- package/dist/internal-common/src/types/bundle-data.types.d.ts +1 -0
- package/dist/internal-common/src/types/communication.types.d.ts +1 -0
- package/dist/internal-common/src/types/document.types.d.ts +1 -0
- package/dist/internal-common/src/types/mutation.types.d.ts +1 -0
- package/dist/internal-common/src/types/openapi.types.d.ts +1 -0
- package/dist/internal-common/src/types/query.types.d.ts +1 -0
- package/dist/internal-common/src/types/secret.types.d.ts +11 -0
- package/dist/internal-common/src/types/socket.types.d.ts +1 -0
- package/dist/internal-common/src/utils/array.d.ts +1 -0
- package/dist/internal-common/src/utils/assert.d.ts +1 -0
- package/dist/internal-common/src/utils/global.utils.d.ts +1 -0
- package/dist/internal-common/src/utils/http.d.ts +2 -0
- package/dist/internal-common/src/utils/lock.manager.d.ts +14 -0
- package/dist/internal-common/src/utils/object.d.ts +5 -0
- package/dist/internal-common/src/utils/serialization.d.ts +5 -0
- package/dist/internal-common/src/utils/validation.d.ts +24 -0
- package/dist/internal-common/src/websocket.impl.d.ts +21 -0
- package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -0
- package/dist/typescript-client/src/ai-assistant-client.d.ts +73 -0
- package/dist/typescript-client/src/ai-chatbot-client.d.ts +168 -0
- package/dist/typescript-client/src/ai-chatbot-client.factory.d.ts +1 -0
- package/dist/typescript-client/src/ai.types.d.ts +60 -0
- package/dist/typescript-client/src/api.manager.d.ts +11 -0
- package/dist/typescript-client/src/auth.manager.d.ts +27 -0
- package/dist/typescript-client/src/backend-function.manager.d.ts +9 -0
- package/dist/typescript-client/src/backend-transforms.d.ts +0 -0
- package/dist/typescript-client/src/client-id.service.d.ts +27 -0
- package/dist/typescript-client/src/collection-reference.d.ts +80 -0
- package/dist/typescript-client/src/collection-reference.factory.d.ts +1 -0
- package/dist/typescript-client/src/connection-details.d.ts +23 -0
- package/dist/typescript-client/src/data.manager.d.ts +5 -0
- package/dist/typescript-client/src/destruct.manager.d.ts +13 -0
- package/dist/typescript-client/src/distributed-lock.manager.d.ts +16 -0
- package/dist/typescript-client/src/document-identity.service.d.ts +1 -0
- package/dist/typescript-client/src/document-reference.d.ts +149 -0
- package/dist/typescript-client/src/document-reference.factory.d.ts +1 -0
- package/dist/typescript-client/src/document-store.d.ts +14 -0
- package/dist/typescript-client/src/graphql-client.d.ts +14 -0
- package/dist/typescript-client/src/graphql-client.factory.d.ts +11 -0
- package/dist/typescript-client/src/index.d.ts +11 -0
- package/dist/typescript-client/src/mutation/mutation-sender.d.ts +1 -0
- package/dist/typescript-client/src/native-query-manager.d.ts +7 -0
- package/dist/typescript-client/src/public-types.d.ts +37 -0
- package/dist/typescript-client/src/public-utils.d.ts +1 -0
- package/dist/typescript-client/src/query/deserializer.d.ts +3 -0
- package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +161 -0
- package/dist/typescript-client/src/query/local-query-manager.d.ts +1 -0
- package/dist/typescript-client/src/query/query-builder.factory.d.ts +77 -0
- package/dist/typescript-client/src/query/query-sender.d.ts +1 -0
- package/dist/typescript-client/src/query/query-subscription.manager.d.ts +2 -0
- package/dist/typescript-client/src/query/query.types.d.ts +49 -0
- package/dist/typescript-client/src/queue.manager.d.ts +7 -0
- package/dist/typescript-client/src/rate-limiter.d.ts +32 -0
- package/dist/typescript-client/src/rpc.manager.d.ts +30 -0
- package/dist/typescript-client/src/secret.client.d.ts +23 -0
- package/dist/typescript-client/src/socket.manager.d.ts +1 -0
- package/dist/typescript-client/src/squid.d.ts +245 -0
- package/dist/typescript-client/src/state/state.service.spec.d.ts +1 -0
- package/dist/typescript-client/src/testing/setup-tests.d.ts +1 -0
- package/dist/typescript-client/src/types.d.ts +6 -0
- package/package.json +3 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { AssistantToolType, FunctionName } from './public-types';
|
|
2
|
+
import { RpcManager } from './rpc.manager';
|
|
3
|
+
import { BlobAndFilename } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Client class for interacting with an AI Assistant server.
|
|
6
|
+
* Provides functionalities like creating and deleting assistants and threads,
|
|
7
|
+
* querying assistants, and managing files associated with assistants and threads.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AiAssistantClient {
|
|
10
|
+
private readonly rpcManager;
|
|
11
|
+
constructor(rpcManager: RpcManager);
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new AI assistant with specified characteristics.
|
|
14
|
+
* @param name - The name of the assistant.
|
|
15
|
+
* @param instructions - Instructions for the assistant.
|
|
16
|
+
* @param functions - Array of function names annotated with "@aiFunction" in your Squid backend that will be
|
|
17
|
+
* available tol the assistant.
|
|
18
|
+
* @param toolTypes - Optional array of tool types. If you want to use files for retrieval, you must add them using
|
|
19
|
+
* the addFileToAssistant method.
|
|
20
|
+
* @returns A promise that resolves to the created assistant's ID.
|
|
21
|
+
*/
|
|
22
|
+
createAssistant(name: string, instructions: string, functions: Array<FunctionName>, toolTypes?: Array<AssistantToolType>): Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Deletes an AI assistant.
|
|
25
|
+
* @param assistantId - The ID of the assistant to be deleted.
|
|
26
|
+
* @returns A promise that resolves when the assistant is deleted.
|
|
27
|
+
*/
|
|
28
|
+
deleteAssistant(assistantId: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new thread for an AI assistant. A thread is a long-lived conversation with the assistant that you can
|
|
31
|
+
* always send questions to.
|
|
32
|
+
* @param assistantId - The ID of the assistant for which the thread is created.
|
|
33
|
+
* @returns A promise that resolves to the created thread's ID.
|
|
34
|
+
*/
|
|
35
|
+
createThread(assistantId: string): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Deletes a thread of an AI assistant.
|
|
38
|
+
* @param threadId - The ID of the thread to be deleted.
|
|
39
|
+
* @returns A promise that resolves when the thread is deleted.
|
|
40
|
+
*/
|
|
41
|
+
deleteThread(threadId: string): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Queries an AI assistant within a specific thread.
|
|
44
|
+
* @param assistantId - The ID of the assistant.
|
|
45
|
+
* @param threadId - The ID of the thread.
|
|
46
|
+
* @param prompt - The query prompt.
|
|
47
|
+
* @param fileIds - Optional array of file IDs to include in the query. These file IDs need to be added using the
|
|
48
|
+
* addFileToThread method.
|
|
49
|
+
* @returns A promise that resolves to the assistant's response.
|
|
50
|
+
*/
|
|
51
|
+
queryAssistant(assistantId: string, threadId: string, prompt: string, fileIds?: string[]): Promise<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Adds a file to an AI assistant that can be available for retrieval or code analyzer.
|
|
54
|
+
* @param assistantId - The ID of the assistant.
|
|
55
|
+
* @param file - The file or blob and filename to be added.
|
|
56
|
+
* @returns A promise that resolves to the ID of the added file.
|
|
57
|
+
*/
|
|
58
|
+
addFileToAssistant(assistantId: string, file: File | BlobAndFilename): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Removes a file from an AI assistant.
|
|
61
|
+
* @param assistantId - The ID of the assistant.
|
|
62
|
+
* @param fileId - The ID of the file to be removed.
|
|
63
|
+
* @returns A promise that resolves when the file is removed.
|
|
64
|
+
*/
|
|
65
|
+
removeFileFromAssistant(assistantId: string, fileId: string): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Adds a file to a specific thread of an AI assistant. These files can be used when asking a question in the thread.
|
|
68
|
+
* @param threadId - The ID of the thread.
|
|
69
|
+
* @param file - The file or blob and filename to be added.
|
|
70
|
+
* @returns A promise that resolves to the ID of the added file.
|
|
71
|
+
*/
|
|
72
|
+
addFileToThread(threadId: string, file: File | BlobAndFilename): Promise<string>;
|
|
73
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { AiChatbotChatOptions, AiChatbotContext, AiModelName } from './public-types';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
export declare class AiChatbotClient {
|
|
4
|
+
private readonly rpcManager;
|
|
5
|
+
private readonly socketManager;
|
|
6
|
+
private readonly integrationId;
|
|
7
|
+
private readonly ongoingChatSequences;
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves a profile reference for the provided id. A profile reference
|
|
10
|
+
* can be used to create and update profiles, add instructions and context
|
|
11
|
+
* and start chats.
|
|
12
|
+
*
|
|
13
|
+
* @param id - The id of the profile.
|
|
14
|
+
* @returns The profile reference.
|
|
15
|
+
*/
|
|
16
|
+
profile(id: string): AiChatbotProfileReference;
|
|
17
|
+
/**
|
|
18
|
+
* Sends a prompt to the specified profile id.
|
|
19
|
+
*
|
|
20
|
+
* @param profileId - The profile id.
|
|
21
|
+
* @param prompt - The prompt.
|
|
22
|
+
* @param options - The options to send to the chat model.
|
|
23
|
+
* @returns An observable that emits when a new response token is received. The emitted value is the entire response
|
|
24
|
+
* that has been received so far.
|
|
25
|
+
*/
|
|
26
|
+
chat(profileId: string, prompt: string, options?: AiChatbotChatOptions): Observable<string>;
|
|
27
|
+
private handleChatResponse;
|
|
28
|
+
}
|
|
29
|
+
export declare class AiChatbotProfileReference {
|
|
30
|
+
private readonly client;
|
|
31
|
+
private readonly integrationId;
|
|
32
|
+
private readonly profileId;
|
|
33
|
+
/**
|
|
34
|
+
* Sends a prompt to the current profile.
|
|
35
|
+
*
|
|
36
|
+
* @param prompt - The prompt.
|
|
37
|
+
* @param options - The chat options.
|
|
38
|
+
* @returns An observable that emits when a new response token is received. The emitted value is the entire response
|
|
39
|
+
* that has been received so far.
|
|
40
|
+
*/
|
|
41
|
+
chat(prompt: string, options?: AiChatbotChatOptions): Observable<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Retrieves a context reference for the current profile. A context reference can be used to add a new context entry
|
|
44
|
+
* to the profile, or update/delete an existing entry context.
|
|
45
|
+
*
|
|
46
|
+
* @param id - The id of the context entry. If no id is passed, an id will be
|
|
47
|
+
* generated and the reference will point to a new context entry.
|
|
48
|
+
* @returns The context reference.
|
|
49
|
+
*/
|
|
50
|
+
context(id?: string): AiChatbotContextReference;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves an instruction reference for the current profile. An instruction reference can be used to add a new
|
|
53
|
+
* instruction entry to the profile, or update/delete an existing instruction entry.
|
|
54
|
+
*
|
|
55
|
+
* @param id - The id of the instruction entry. If no id is passed, an id will be
|
|
56
|
+
* generated and the reference will point to a new instruction entry.
|
|
57
|
+
* @returns The instruction reference.
|
|
58
|
+
*/
|
|
59
|
+
instruction(id?: string): AiChatbotInstructionReference;
|
|
60
|
+
/**
|
|
61
|
+
* Adds a new profile to the chatbot. This will result in an error if a profile already exists with the same id.
|
|
62
|
+
*
|
|
63
|
+
* @param data An object containing options for creating the profile.
|
|
64
|
+
* @param data.modelName - The name of the OpenAI model (`gpt-3.5, `gpt-4` or `claude-2`).
|
|
65
|
+
* @param data.isPublic - Whether the chat functionality of the profile can be accessed without security rules.
|
|
66
|
+
* @returns A promise that resolves when the profile is successfully created.
|
|
67
|
+
*/
|
|
68
|
+
insert(data: {
|
|
69
|
+
modelName: AiModelName;
|
|
70
|
+
isPublic: boolean;
|
|
71
|
+
}): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Updates an existing chatbot 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, `gpt-4` or `claude-2`).
|
|
78
|
+
* @param data.isPublic - Whether the chat functionality of the profile can be accessed without security rules.
|
|
79
|
+
* @returns A promise that resolves when the profile is successfully updated.
|
|
80
|
+
*/
|
|
81
|
+
update(data: {
|
|
82
|
+
modelName?: AiModelName;
|
|
83
|
+
isPublic?: boolean;
|
|
84
|
+
}): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Deletes an existing chatbot profile. This will result in an error if a profile has not yet been created for the
|
|
87
|
+
* current profile id.
|
|
88
|
+
*
|
|
89
|
+
* @returns A promise that resolves when the profile is successfully deleted.
|
|
90
|
+
*/
|
|
91
|
+
delete(): Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
declare class AiChatbotContextReference {
|
|
94
|
+
private readonly client;
|
|
95
|
+
private readonly integrationId;
|
|
96
|
+
private readonly profileId;
|
|
97
|
+
private readonly id;
|
|
98
|
+
/**
|
|
99
|
+
* Adds a new context entry to the chatbot profile. This will result in an error if an entry already exists with
|
|
100
|
+
* the same id.
|
|
101
|
+
*
|
|
102
|
+
* @param data An object containing options for creating the entry.
|
|
103
|
+
* @param data.title - The title of the entry.
|
|
104
|
+
* @param data.context - The context data.
|
|
105
|
+
* @param file - The file to insert.
|
|
106
|
+
* @returns A promise that resolves when the context is successfully created.
|
|
107
|
+
*/
|
|
108
|
+
insert(data: {
|
|
109
|
+
title: string;
|
|
110
|
+
context: AiChatbotContext;
|
|
111
|
+
}, file?: File): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Updates an existing context entry on the chatbot profile. This will result in an error if an entry has not yet
|
|
114
|
+
* been created for the current context id.
|
|
115
|
+
*
|
|
116
|
+
* @param data An object containing options for updated the entry.
|
|
117
|
+
* @param data.title - The title of the entry.
|
|
118
|
+
* @param data.context - The context data.
|
|
119
|
+
* @returns A promise that resolves when the context is successfully updated.
|
|
120
|
+
*/
|
|
121
|
+
update(data: {
|
|
122
|
+
title?: string;
|
|
123
|
+
context?: AiChatbotContext;
|
|
124
|
+
}): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Deletes an existing context entry on the chatbot profile. This will result in an error if an entry has not yet
|
|
127
|
+
* been created for the current context id.
|
|
128
|
+
*
|
|
129
|
+
* @returns A promise that resolves when the context is successfully deleted.
|
|
130
|
+
*/
|
|
131
|
+
delete(): Promise<void>;
|
|
132
|
+
}
|
|
133
|
+
declare class AiChatbotInstructionReference {
|
|
134
|
+
private readonly client;
|
|
135
|
+
private readonly integrationId;
|
|
136
|
+
private readonly profileId;
|
|
137
|
+
private readonly id;
|
|
138
|
+
/**
|
|
139
|
+
* Adds a new instruction entry to the chatbot profile. This will result in an error if an entry already exists with
|
|
140
|
+
* the same id.
|
|
141
|
+
*
|
|
142
|
+
* @param data An object containing options for creating the entry.
|
|
143
|
+
* @param data.instruction - The instruction data.
|
|
144
|
+
* @returns A promise that resolves when the instruction is successfully created.
|
|
145
|
+
*/
|
|
146
|
+
insert(data: {
|
|
147
|
+
instruction: string;
|
|
148
|
+
}): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Updates an existing instruction entry on the chatbot profile. This will result in an error if an entry has not
|
|
151
|
+
* yet been created for the current instruction id.
|
|
152
|
+
*
|
|
153
|
+
* @param data An object containing options for updated the entry.
|
|
154
|
+
* @param data.instruction - The instruction data.
|
|
155
|
+
* @returns A promise that resolves when the instruction is successfully updated.
|
|
156
|
+
*/
|
|
157
|
+
update(data: {
|
|
158
|
+
instruction: string;
|
|
159
|
+
}): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* Deletes an existing instruction entry on the chatbot profile. This will result in an error if an entry has not
|
|
162
|
+
* yet been created for the current instruction id.
|
|
163
|
+
*
|
|
164
|
+
* @returns A promise that resolves when the instruction is successfully deleted.
|
|
165
|
+
*/
|
|
166
|
+
delete(): Promise<void>;
|
|
167
|
+
}
|
|
168
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AiChatbotClient } from './ai-chatbot-client';
|
|
2
|
+
import { AiAssistantClient } from './ai-assistant-client';
|
|
3
|
+
import { IntegrationId } from './public-types';
|
|
4
|
+
export interface ExecuteAiQueryRequest {
|
|
5
|
+
integrationId: IntegrationId;
|
|
6
|
+
prompt: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ExecuteAiQueryResponse {
|
|
9
|
+
answer: string;
|
|
10
|
+
explanation?: string;
|
|
11
|
+
executedQuery?: string;
|
|
12
|
+
queryMarkdownType?: string;
|
|
13
|
+
success: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* AiClient class serves as a facade for interacting with different AI services.
|
|
17
|
+
* It provides simplified access to AI chatbot and assistant functionalities
|
|
18
|
+
* through its methods.
|
|
19
|
+
*/
|
|
20
|
+
export declare class AiClient {
|
|
21
|
+
private readonly aiChatbotClientFactory;
|
|
22
|
+
private readonly rpcManager;
|
|
23
|
+
private readonly aiAssistantClient;
|
|
24
|
+
/**
|
|
25
|
+
* Retrieves an AI chatbot client for a specific AI integration.
|
|
26
|
+
* @param aiIntegrationId - The identifier for the AI integration.
|
|
27
|
+
* @returns An instance of AiChatbotClient associated with the given AI integration ID.
|
|
28
|
+
*/
|
|
29
|
+
chatbot(aiIntegrationId: IntegrationId): AiChatbotClient;
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves the AI assistant client.
|
|
32
|
+
* @returns An instance of AiAssistantClient.
|
|
33
|
+
*/
|
|
34
|
+
assistant(): AiAssistantClient;
|
|
35
|
+
/**
|
|
36
|
+
* Executes an AI query using a specific DB integration, sending a prompt to the AI and returning its response.
|
|
37
|
+
* This function allows for direct interaction with the AI's capabilities by sending text prompts and receiving
|
|
38
|
+
* the AI's responses, which can be used for various applications such as automating tasks, generating content,
|
|
39
|
+
* or obtaining information.
|
|
40
|
+
*
|
|
41
|
+
* @param integrationId The identifier for the DB integration which is used to direct the query to the
|
|
42
|
+
* appropriate DB.
|
|
43
|
+
* @param prompt The text prompt to send to the AI. This should be formulated in a way that the AI can
|
|
44
|
+
* understand and respond to, taking into account the nature of the task or the information
|
|
45
|
+
* sought.
|
|
46
|
+
* @returns A promise that resolves to an `ExecuteAiQueryResponse`. This response includes the AI's
|
|
47
|
+
* reply to the provided prompt, along with any other relevant information that is part of
|
|
48
|
+
* the AI's response. The promise can be awaited to handle the response asynchronously.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```
|
|
52
|
+
* const response = await ai().executeAiQuery(myDbIntegrationId, "How many transactions ran yesterday?");
|
|
53
|
+
* console.log(response);
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* For more details on the usage and capabilities of the AI Assistant, refer to the documentation provided at
|
|
57
|
+
* {@link https://docs.squid.cloud/docs/ai}.
|
|
58
|
+
*/
|
|
59
|
+
executeAiQuery(integrationId: IntegrationId, prompt: string): Promise<ExecuteAiQueryResponse>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { RpcManager } from './rpc.manager';
|
|
3
|
+
import { ClientIdService } from './client-id.service';
|
|
4
|
+
import { ApiEndpointId, IntegrationId } from './public-types';
|
|
5
|
+
export declare class ApiManager {
|
|
6
|
+
private readonly clientIdService;
|
|
7
|
+
private readonly rpcManager;
|
|
8
|
+
private readonly apiServerUrlOverrideMapping;
|
|
9
|
+
constructor(clientIdService: ClientIdService, rpcManager: RpcManager, apiServerUrlOverrideMapping?: Record<IntegrationId, string>);
|
|
10
|
+
callApiAndSubscribe<T>(integrationId: IntegrationId, endpointId: ApiEndpointId, request: Record<string, any>): Observable<T>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SquidAuthProvider } from './squid';
|
|
2
|
+
import { ApiKey, AuthToken, IntegrationId } from './public-types';
|
|
3
|
+
/** Holds authentication token for the specified integration. */
|
|
4
|
+
export interface AuthData {
|
|
5
|
+
token: string | undefined;
|
|
6
|
+
integrationId?: IntegrationId;
|
|
7
|
+
}
|
|
8
|
+
export declare class AuthManager {
|
|
9
|
+
private readonly apiKey;
|
|
10
|
+
private authProvider?;
|
|
11
|
+
constructor(apiKey: ApiKey | undefined, authProvider?: SquidAuthProvider | undefined);
|
|
12
|
+
/**
|
|
13
|
+
* Sets a new auth-token provider to Squid.
|
|
14
|
+
* All future squid backend requests will use this token provider.
|
|
15
|
+
* Exising in-flight requests won't be affected.
|
|
16
|
+
*/
|
|
17
|
+
setAuthProvider(authProvider: SquidAuthProvider): void;
|
|
18
|
+
getAuthData(): Promise<AuthData>;
|
|
19
|
+
private getTokenFromAuthProvider;
|
|
20
|
+
getApiKey(): ApiKey | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Returns a valid AuthToken.
|
|
23
|
+
* Tries to use `apiKey` first if set up.
|
|
24
|
+
* Falls back to `await authTokenProvider()` result.
|
|
25
|
+
*/
|
|
26
|
+
getToken(): Promise<AuthToken | undefined>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { RpcManager } from './rpc.manager';
|
|
3
|
+
import { ClientIdService } from './client-id.service';
|
|
4
|
+
export declare class BackendFunctionManager {
|
|
5
|
+
private readonly clientIdService;
|
|
6
|
+
private readonly rpcManager;
|
|
7
|
+
constructor(clientIdService: ClientIdService, rpcManager: RpcManager);
|
|
8
|
+
executeFunctionAndSubscribe<T>(functionName: string, ...params: unknown[]): Observable<T>;
|
|
9
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { DestructManager } from './destruct.manager';
|
|
3
|
+
import { ClientId } from '../../internal-common/src/public-types/communication.public-types';
|
|
4
|
+
/**
|
|
5
|
+
* Whenever a squid client is created, it assigns itself a client id.
|
|
6
|
+
* Later on, if the squid client disconnects for a specified time interval, it will generate itself a new client id.
|
|
7
|
+
* The client id is generated before the socket is reconnected, so it is possible that the new client id is generated,
|
|
8
|
+
* but the socket has not connected yet.
|
|
9
|
+
*
|
|
10
|
+
* Short-term disconnects/reconnects of the socket do not cause the client id to be regenerated.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ClientIdService {
|
|
13
|
+
private readonly destructManager;
|
|
14
|
+
private readonly clientTooOldSubject;
|
|
15
|
+
private readonly clientIdSubject;
|
|
16
|
+
private readonly isTenant;
|
|
17
|
+
constructor(destructManager: DestructManager);
|
|
18
|
+
observeClientId(): Observable<ClientId>;
|
|
19
|
+
observeClientTooOld(): Observable<void>;
|
|
20
|
+
/** there was a long-term disconnection of the socket */
|
|
21
|
+
notifyClientTooOld(): void;
|
|
22
|
+
notifyClientReadyToBeRegenerated(): void;
|
|
23
|
+
observeClientReadyToBeRegenerated(): Observable<void>;
|
|
24
|
+
getClientId(): ClientId;
|
|
25
|
+
isClientTooOld(): boolean;
|
|
26
|
+
private generateClientId;
|
|
27
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Alias, DocId, DocIdObj, DocumentData, SnapshotEmitter } from './public-types';
|
|
2
|
+
import { DocumentReference } from './document-reference';
|
|
3
|
+
import { JoinQueryBuilder } from './query/join-query-builder.factory';
|
|
4
|
+
import { QueryBuilder } from './query/query-builder.factory';
|
|
5
|
+
/**
|
|
6
|
+
* Holds a reference to a data collection. A collection reference is a reference to a collection in a database. You
|
|
7
|
+
* can use it to read or write data to the collection. A collection can refer to a table in a relational database or a
|
|
8
|
+
* collection in a NoSQL database.
|
|
9
|
+
*
|
|
10
|
+
* Read more about collection references in the
|
|
11
|
+
* {@link https://docs.squid.cloud/docs/development-tools/client-sdk/collection-reference documentation}.
|
|
12
|
+
* @typeParam T The type of the document data.
|
|
13
|
+
*/
|
|
14
|
+
export declare class CollectionReference<T extends DocumentData> {
|
|
15
|
+
private readonly collectionName;
|
|
16
|
+
private integrationId;
|
|
17
|
+
private readonly documentReferenceFactory;
|
|
18
|
+
private readonly queryBuilderFactory;
|
|
19
|
+
private readonly querySubscriptionManager;
|
|
20
|
+
/** A string that uniquely identifies this collection reference. */
|
|
21
|
+
refId: string;
|
|
22
|
+
/**
|
|
23
|
+
* Returns a document reference for the given document id.
|
|
24
|
+
* The document id is an object that maps the primary keys of the collection (as defined in the Squid Cloud Console)
|
|
25
|
+
* to their values. There are a few exceptions:
|
|
26
|
+
* 1 - String document id is only supported for the `built_in_db` when a schema was not defined.
|
|
27
|
+
* 2 - Not all the fields in the document id are required. If a field is not provided, it will be generated on the
|
|
28
|
+
* server once the document is created (if the integration supports it).
|
|
29
|
+
* 3 - When a document id is not provided, it will be treated as an empty object or empty string.
|
|
30
|
+
* 4 - When the document id is just a `string` and not provided (applies only for the `built_in_db`), it will be
|
|
31
|
+
* generated on the server.
|
|
32
|
+
* 5 - If the collection in the `built_in_db` does not have a schema, the document id must be provided as a string.
|
|
33
|
+
*
|
|
34
|
+
* Examples:
|
|
35
|
+
* ```typescript
|
|
36
|
+
* // For a collection in the built_in_db that does not have a schema
|
|
37
|
+
* const docRef = collectionRef.doc('my-doc-id');
|
|
38
|
+
* const docRef = collectionRef.doc({id: my-doc-id'});
|
|
39
|
+
*
|
|
40
|
+
* // For a collection with a single primary key field called "id"
|
|
41
|
+
* const docRef = collectionRef.doc({id: 'my-doc-id'});
|
|
42
|
+
*
|
|
43
|
+
* // For a collection with a composite primary key
|
|
44
|
+
* const docRef = collectionRef.doc({id1: 'my-doc-id1', id2: 'my-doc-id2'});
|
|
45
|
+
* const docRef = collectionRef.doc({id1: 'my-doc-id1'}); // id2 will be generated on the server if the integration
|
|
46
|
+
* supports it
|
|
47
|
+
*
|
|
48
|
+
* // For a collection from the `built_in_db` without a defined schema when an id is not provided
|
|
49
|
+
* const docRef = collectionRef.doc(); // The id will be generated on the server
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @param docId The document id as an object for the different fields in the primary key or a string.
|
|
53
|
+
* @returns A document reference for the given document id.
|
|
54
|
+
*/
|
|
55
|
+
doc(docId?: DocId | DocIdObj): DocumentReference<T>;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a `QueryBuilder` that can be used to query the collection.
|
|
58
|
+
*
|
|
59
|
+
* @returns A `QueryBuilder` that can be used to query the collection.
|
|
60
|
+
*/
|
|
61
|
+
query(): QueryBuilder<T>;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a `JoinQueryBuilder` that can be used to query the collection
|
|
64
|
+
* Note that when using a join query, you have to provide an alias for the query and for every other query
|
|
65
|
+
* participating in the join.
|
|
66
|
+
*
|
|
67
|
+
* @param alias The alias for the query.
|
|
68
|
+
* @returns A `JoinQueryBuilder` that can be used to query the collection and joins with other queries.
|
|
69
|
+
*/
|
|
70
|
+
joinQuery<A extends Alias>(alias: A): JoinQueryBuilder<Record<A, []>, Record<A, T>, A, A>;
|
|
71
|
+
/**
|
|
72
|
+
* Performs `or` on a list of queries. All the queries need to be on the same collection.
|
|
73
|
+
* The result will be a merge of all the queries sorted by the same sort condition of the first query.
|
|
74
|
+
* Duplicate items will be removed.
|
|
75
|
+
* @param builders The list of query builders to merge. (A query builder can be returned from the {@link query}
|
|
76
|
+
* method).
|
|
77
|
+
* @returns A query builder that can be used to perform the `or` operation.
|
|
78
|
+
*/
|
|
79
|
+
or(...builders: QueryBuilder<T>[]): SnapshotEmitter<DocumentReference<T>>;
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { ClientId } from '../../internal-common/src/public-types/communication.public-types';
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
reportDestructed(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|