@squidcloud/client 1.0.166 → 1.0.168

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/cjs/index.js +35 -16
  2. package/package.json +1 -1
  3. package/dist/internal-common/src/public-types/ai-assistant.public-types.d.ts +0 -25
  4. package/dist/internal-common/src/public-types/ai-chatbot.public-context.d.ts +0 -12
  5. package/dist/internal-common/src/public-types/ai-chatbot.public-types.d.ts +0 -31
  6. package/dist/internal-common/src/public-types/api-call.public-context.d.ts +0 -14
  7. package/dist/internal-common/src/public-types/application.public-types.d.ts +0 -149
  8. package/dist/internal-common/src/public-types/base-query-builder.public-types.d.ts +0 -147
  9. package/dist/internal-common/src/public-types/bundle-api.public-types.d.ts +0 -57
  10. package/dist/internal-common/src/public-types/bundle-data.public-types.d.ts +0 -8
  11. package/dist/internal-common/src/public-types/communication.public-types.d.ts +0 -12
  12. package/dist/internal-common/src/public-types/context.public-types.d.ts +0 -40
  13. package/dist/internal-common/src/public-types/distributed-lock.public-context.d.ts +0 -4
  14. package/dist/internal-common/src/public-types/document.public-types.d.ts +0 -32
  15. package/dist/internal-common/src/public-types/graphql.public-context.d.ts +0 -7
  16. package/dist/internal-common/src/public-types/graphql.public-types.d.ts +0 -9
  17. package/dist/internal-common/src/public-types/http-status.enum.d.ts +0 -50
  18. package/dist/internal-common/src/public-types/integration.public-types.d.ts +0 -61
  19. package/dist/internal-common/src/public-types/integrations/ai_chatbot.types.d.ts +0 -32
  20. package/dist/internal-common/src/public-types/integrations/api.types.d.ts +0 -81
  21. package/dist/internal-common/src/public-types/integrations/auth.types.d.ts +0 -54
  22. package/dist/internal-common/src/public-types/integrations/database.types.d.ts +0 -206
  23. package/dist/internal-common/src/public-types/integrations/observability.types.d.ts +0 -24
  24. package/dist/internal-common/src/public-types/integrations/queue-types.d.ts +0 -40
  25. package/dist/internal-common/src/public-types/integrations/schemas.d.ts +0 -70
  26. package/dist/internal-common/src/public-types/mutation.public-context.d.ts +0 -14
  27. package/dist/internal-common/src/public-types/mutation.public-types.d.ts +0 -53
  28. package/dist/internal-common/src/public-types/native-query.public-context.d.ts +0 -7
  29. package/dist/internal-common/src/public-types/native-query.public-types.d.ts +0 -16
  30. package/dist/internal-common/src/public-types/pagination.public-types.d.ts +0 -62
  31. package/dist/internal-common/src/public-types/query.public-context.d.ts +0 -137
  32. package/dist/internal-common/src/public-types/query.public-types.d.ts +0 -64
  33. package/dist/internal-common/src/public-types/regions.public-types.d.ts +0 -5
  34. package/dist/internal-common/src/public-types/schema.public-types.d.ts +0 -46
  35. package/dist/internal-common/src/public-types/secret.public-types.d.ts +0 -16
  36. package/dist/internal-common/src/public-types/serialized-query.public-types.d.ts +0 -24
  37. package/dist/internal-common/src/public-types/socket.public-types.d.ts +0 -5
  38. package/dist/internal-common/src/public-types/topic.public-context.d.ts +0 -10
  39. package/dist/internal-common/src/public-types/typescript.public-types.d.ts +0 -15
  40. package/dist/internal-common/src/public-utils/id-utils.d.ts +0 -6
  41. package/dist/internal-common/src/types/ai-assistant.types.d.ts +0 -1
  42. package/dist/internal-common/src/types/ai-chatbot.types.d.ts +0 -1
  43. package/dist/internal-common/src/types/api.types.d.ts +0 -2
  44. package/dist/internal-common/src/types/backend-function.types.d.ts +0 -1
  45. package/dist/internal-common/src/types/backend-run.types.d.ts +0 -2
  46. package/dist/internal-common/src/types/bundle-data.types.d.ts +0 -4
  47. package/dist/internal-common/src/types/communication.types.d.ts +0 -1
  48. package/dist/internal-common/src/types/document.types.d.ts +0 -1
  49. package/dist/internal-common/src/types/mutation.types.d.ts +0 -1
  50. package/dist/internal-common/src/types/openapi.types.d.ts +0 -1
  51. package/dist/internal-common/src/types/query.types.d.ts +0 -1
  52. package/dist/internal-common/src/types/secret.types.d.ts +0 -11
  53. package/dist/internal-common/src/types/socket.types.d.ts +0 -7
  54. package/dist/internal-common/src/utils/array.d.ts +0 -1
  55. package/dist/internal-common/src/utils/assert.d.ts +0 -1
  56. package/dist/internal-common/src/utils/global.utils.d.ts +0 -1
  57. package/dist/internal-common/src/utils/http.d.ts +0 -2
  58. package/dist/internal-common/src/utils/lock.manager.d.ts +0 -14
  59. package/dist/internal-common/src/utils/object.d.ts +0 -5
  60. package/dist/internal-common/src/utils/serialization.d.ts +0 -5
  61. package/dist/internal-common/src/utils/validation.d.ts +0 -27
  62. package/dist/internal-common/src/websocket.impl.d.ts +0 -21
  63. package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +0 -1239
  64. package/dist/typescript-client/src/ai-assistant-client.d.ts +0 -73
  65. package/dist/typescript-client/src/ai-chatbot-client.d.ts +0 -174
  66. package/dist/typescript-client/src/ai-chatbot-client.factory.d.ts +0 -8
  67. package/dist/typescript-client/src/ai.types.d.ts +0 -63
  68. package/dist/typescript-client/src/api.manager.d.ts +0 -11
  69. package/dist/typescript-client/src/auth.manager.d.ts +0 -27
  70. package/dist/typescript-client/src/backend-function.manager.d.ts +0 -9
  71. package/dist/typescript-client/src/backend-transforms.d.ts +0 -0
  72. package/dist/typescript-client/src/client-id.service.d.ts +0 -27
  73. package/dist/typescript-client/src/collection-reference.d.ts +0 -80
  74. package/dist/typescript-client/src/collection-reference.factory.d.ts +0 -13
  75. package/dist/typescript-client/src/connection-details.d.ts +0 -23
  76. package/dist/typescript-client/src/data.manager.d.ts +0 -175
  77. package/dist/typescript-client/src/destruct.manager.d.ts +0 -13
  78. package/dist/typescript-client/src/distributed-lock.manager.d.ts +0 -16
  79. package/dist/typescript-client/src/document-identity.service.d.ts +0 -12
  80. package/dist/typescript-client/src/document-reference.d.ts +0 -149
  81. package/dist/typescript-client/src/document-reference.factory.d.ts +0 -13
  82. package/dist/typescript-client/src/document-store.d.ts +0 -14
  83. package/dist/typescript-client/src/graphql-client.d.ts +0 -14
  84. package/dist/typescript-client/src/graphql-client.factory.d.ts +0 -11
  85. package/dist/typescript-client/src/index.d.ts +0 -11
  86. package/dist/typescript-client/src/mutation/mutation-sender.d.ts +0 -12
  87. package/dist/typescript-client/src/native-query-manager.d.ts +0 -7
  88. package/dist/typescript-client/src/public-types.d.ts +0 -37
  89. package/dist/typescript-client/src/public-utils.d.ts +0 -1
  90. package/dist/typescript-client/src/query/deserializer.d.ts +0 -3
  91. package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +0 -161
  92. package/dist/typescript-client/src/query/local-query-manager.d.ts +0 -9
  93. package/dist/typescript-client/src/query/query-builder.factory.d.ts +0 -77
  94. package/dist/typescript-client/src/query/query-sender.d.ts +0 -34
  95. package/dist/typescript-client/src/query/query-subscription.manager.d.ts +0 -133
  96. package/dist/typescript-client/src/query/query.types.d.ts +0 -49
  97. package/dist/typescript-client/src/queue.manager.d.ts +0 -7
  98. package/dist/typescript-client/src/rate-limiter.d.ts +0 -32
  99. package/dist/typescript-client/src/rpc.manager.d.ts +0 -30
  100. package/dist/typescript-client/src/secret.client.d.ts +0 -23
  101. package/dist/typescript-client/src/socket.manager.d.ts +0 -44
  102. package/dist/typescript-client/src/squid.d.ts +0 -245
  103. package/dist/typescript-client/src/state/state.service.spec.d.ts +0 -1
  104. package/dist/typescript-client/src/testing/setup-tests.d.ts +0 -1
  105. package/dist/typescript-client/src/types.d.ts +0 -2
@@ -1,73 +0,0 @@
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
- }
@@ -1,174 +0,0 @@
1
- import { AiChatbotChatOptions, AiChatbotContext, AiModelName, IntegrationId } from './public-types';
2
- import { Observable } from 'rxjs';
3
- import { RpcManager } from './rpc.manager';
4
- import { SocketManager } from './socket.manager';
5
- export declare class AiChatbotClient {
6
- private readonly rpcManager;
7
- private readonly socketManager;
8
- private readonly integrationId;
9
- private readonly ongoingChatSequences;
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): AiChatbotProfileReference;
20
- /**
21
- * Sends a prompt to the specified profile id.
22
- *
23
- * @param profileId - The profile id.
24
- * @param prompt - The prompt.
25
- * @param options - The options to send to the chat model.
26
- * @returns An observable that emits when a new response token is received. The emitted value is the entire response
27
- * that has been received so far.
28
- */
29
- chat(profileId: string, prompt: string, options?: AiChatbotChatOptions): Observable<string>;
30
- private handleChatResponse;
31
- }
32
- export declare class AiChatbotProfileReference {
33
- private readonly client;
34
- private readonly integrationId;
35
- private readonly profileId;
36
- constructor(client: AiChatbotClient, integrationId: IntegrationId, profileId: string);
37
- /**
38
- * Sends a prompt to the current profile.
39
- *
40
- * @param prompt - The prompt.
41
- * @param options - The chat options.
42
- * @returns An observable that emits when a new response token is received. The emitted value is the entire response
43
- * that has been received so far.
44
- */
45
- chat(prompt: string, options?: AiChatbotChatOptions): Observable<string>;
46
- /**
47
- * Retrieves a context reference for the current profile. A context reference can be used to add a new context entry
48
- * to the profile, or update/delete an existing entry context.
49
- *
50
- * @param id - The id of the context entry. If no id is passed, an id will be
51
- * generated and the reference will point to a new context entry.
52
- * @returns The context reference.
53
- */
54
- context(id?: string): AiChatbotContextReference;
55
- /**
56
- * Retrieves an instruction reference for the current profile. An instruction reference can be used to add a new
57
- * instruction entry to the profile, or update/delete an existing instruction entry.
58
- *
59
- * @param id - The id of the instruction entry. If no id is passed, an id will be
60
- * generated and the reference will point to a new instruction entry.
61
- * @returns The instruction reference.
62
- */
63
- instruction(id?: string): AiChatbotInstructionReference;
64
- /**
65
- * Adds a new profile to the chatbot. This will result in an error if a profile already exists with the same id.
66
- *
67
- * @param data An object containing options for creating the profile.
68
- * @param data.modelName - The name of the OpenAI model (`gpt-3.5, `gpt-4` or `claude-2`).
69
- * @param data.isPublic - Whether the chat functionality of the profile can be accessed without security rules.
70
- * @returns A promise that resolves when the profile is successfully created.
71
- */
72
- insert(data: {
73
- modelName: AiModelName;
74
- isPublic: boolean;
75
- }): Promise<void>;
76
- /**
77
- * Updates an existing chatbot profile. This will result in an error if a profile has not yet been created for the
78
- * current profile id.
79
- *
80
- * @param data An object containing options for updating the profile.
81
- * @param data.modelName - The name of the OpenAI model (`gpt-3.5, `gpt-4` or `claude-2`).
82
- * @param data.isPublic - Whether the chat functionality of the profile can be accessed without security rules.
83
- * @returns A promise that resolves when the profile is successfully updated.
84
- */
85
- update(data: {
86
- modelName?: AiModelName;
87
- isPublic?: boolean;
88
- }): Promise<void>;
89
- /**
90
- * Deletes an existing chatbot profile. This will result in an error if a profile has not yet been created for the
91
- * current profile id.
92
- *
93
- * @returns A promise that resolves when the profile is successfully deleted.
94
- */
95
- delete(): Promise<void>;
96
- }
97
- declare class AiChatbotContextReference {
98
- private readonly client;
99
- private readonly integrationId;
100
- private readonly profileId;
101
- private readonly id;
102
- constructor(client: AiChatbotClient, integrationId: IntegrationId, profileId: string, id?: string);
103
- /**
104
- * Adds a new context entry to the chatbot profile. This will result in an error if an entry already exists with
105
- * the same id.
106
- *
107
- * @param data An object containing options for creating the entry.
108
- * @param data.title - The title of the entry.
109
- * @param data.context - The context data.
110
- * @param file - The file to insert.
111
- * @returns A promise that resolves when the context is successfully created.
112
- */
113
- insert(data: {
114
- title: string;
115
- context: AiChatbotContext;
116
- }, file?: File): Promise<void>;
117
- /**
118
- * Updates an existing context entry on the chatbot profile. This will result in an error if an entry has not yet
119
- * been created for the current context id.
120
- *
121
- * @param data An object containing options for updated the entry.
122
- * @param data.title - The title of the entry.
123
- * @param data.context - The context data.
124
- * @returns A promise that resolves when the context is successfully updated.
125
- */
126
- update(data: {
127
- title?: string;
128
- context?: AiChatbotContext;
129
- }): Promise<void>;
130
- /**
131
- * Deletes an existing context entry on the chatbot profile. This will result in an error if an entry has not yet
132
- * been created for the current context id.
133
- *
134
- * @returns A promise that resolves when the context is successfully deleted.
135
- */
136
- delete(): Promise<void>;
137
- }
138
- declare class AiChatbotInstructionReference {
139
- private readonly client;
140
- private readonly integrationId;
141
- private readonly profileId;
142
- private readonly id;
143
- constructor(client: AiChatbotClient, integrationId: IntegrationId, profileId: string, id?: string);
144
- /**
145
- * Adds a new instruction entry to the chatbot profile. This will result in an error if an entry already exists with
146
- * the same id.
147
- *
148
- * @param data An object containing options for creating the entry.
149
- * @param data.instruction - The instruction data.
150
- * @returns A promise that resolves when the instruction is successfully created.
151
- */
152
- insert(data: {
153
- instruction: string;
154
- }): Promise<void>;
155
- /**
156
- * Updates an existing instruction entry on the chatbot profile. This will result in an error if an entry has not
157
- * yet been created for the current instruction id.
158
- *
159
- * @param data An object containing options for updated the entry.
160
- * @param data.instruction - The instruction data.
161
- * @returns A promise that resolves when the instruction is successfully updated.
162
- */
163
- update(data: {
164
- instruction: string;
165
- }): Promise<void>;
166
- /**
167
- * Deletes an existing instruction entry on the chatbot profile. This will result in an error if an entry has not
168
- * yet been created for the current instruction id.
169
- *
170
- * @returns A promise that resolves when the instruction is successfully deleted.
171
- */
172
- delete(): Promise<void>;
173
- }
174
- export {};
@@ -1,8 +0,0 @@
1
- import { RpcManager } from './rpc.manager';
2
- import { SocketManager } from './socket.manager';
3
- export declare class AiChatbotClientFactory {
4
- private readonly rpcManager;
5
- private readonly socketManager;
6
- private readonly chatbotsMap;
7
- constructor(rpcManager: RpcManager, socketManager: SocketManager);
8
- }
@@ -1,63 +0,0 @@
1
- import { AiChatbotClient } from './ai-chatbot-client';
2
- import { AiChatbotClientFactory } from './ai-chatbot-client.factory';
3
- import { RpcManager } from './rpc.manager';
4
- import { AiAssistantClient } from './ai-assistant-client';
5
- import { IntegrationId } from './public-types';
6
- export interface ExecuteAiQueryRequest {
7
- integrationId: IntegrationId;
8
- prompt: string;
9
- }
10
- export interface ExecuteAiQueryResponse {
11
- answer: string;
12
- explanation?: string;
13
- executedQuery?: string;
14
- queryMarkdownType?: string;
15
- success: boolean;
16
- }
17
- /**
18
- * AiClient class serves as a facade for interacting with different AI services.
19
- * It provides simplified access to AI chatbot and assistant functionalities
20
- * through its methods.
21
- */
22
- export declare class AiClient {
23
- private readonly aiChatbotClientFactory;
24
- private readonly rpcManager;
25
- private readonly aiAssistantClient;
26
- constructor(aiChatbotClientFactory: AiChatbotClientFactory, rpcManager: RpcManager);
27
- /**
28
- * Retrieves an AI chatbot client for a specific AI integration.
29
- * @param aiIntegrationId - The identifier for the AI integration.
30
- * @returns An instance of AiChatbotClient associated with the given AI integration ID.
31
- */
32
- chatbot(aiIntegrationId: IntegrationId): AiChatbotClient;
33
- /**
34
- * Retrieves the AI assistant client.
35
- * @returns An instance of AiAssistantClient.
36
- */
37
- assistant(): AiAssistantClient;
38
- /**
39
- * Executes an AI query using a specific DB integration, sending a prompt to the AI and returning its response.
40
- * This function allows for direct interaction with the AI's capabilities by sending text prompts and receiving
41
- * the AI's responses, which can be used for various applications such as automating tasks, generating content,
42
- * or obtaining information.
43
- *
44
- * @param integrationId The identifier for the DB integration which is used to direct the query to the
45
- * appropriate DB.
46
- * @param prompt The text prompt to send to the AI. This should be formulated in a way that the AI can
47
- * understand and respond to, taking into account the nature of the task or the information
48
- * sought.
49
- * @returns A promise that resolves to an `ExecuteAiQueryResponse`. This response includes the AI's
50
- * reply to the provided prompt, along with any other relevant information that is part of
51
- * the AI's response. The promise can be awaited to handle the response asynchronously.
52
- *
53
- * @example
54
- * ```
55
- * const response = await ai().executeAiQuery(myDbIntegrationId, "How many transactions ran yesterday?");
56
- * console.log(response);
57
- * ```
58
- *
59
- * For more details on the usage and capabilities of the AI Assistant, refer to the documentation provided at
60
- * {@link https://docs.squid.cloud/docs/ai}.
61
- */
62
- executeAiQuery(integrationId: IntegrationId, prompt: string): Promise<ExecuteAiQueryResponse>;
63
- }
@@ -1,11 +0,0 @@
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
- }
@@ -1,27 +0,0 @@
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
- }
@@ -1,9 +0,0 @@
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
- }
@@ -1,27 +0,0 @@
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
- }
@@ -1,80 +0,0 @@
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
- }
@@ -1,13 +0,0 @@
1
- import { CollectionReference } from './collection-reference';
2
- import { DocumentReferenceFactory } from './document-reference.factory';
3
- import { QueryBuilderFactory } from './query/query-builder.factory';
4
- import { QuerySubscriptionManager } from './query/query-subscription.manager';
5
- import { CollectionName, DocumentData, IntegrationId } from './public-types';
6
- export declare class CollectionReferenceFactory {
7
- private readonly documentReferenceFactory;
8
- private readonly queryBuilderFactory;
9
- private readonly querySubscriptionManager;
10
- private readonly collections;
11
- constructor(documentReferenceFactory: DocumentReferenceFactory, queryBuilderFactory: QueryBuilderFactory, querySubscriptionManager: QuerySubscriptionManager);
12
- get<T extends DocumentData>(collectionName: CollectionName, integrationId: IntegrationId): CollectionReference<T>;
13
- }
@@ -1,23 +0,0 @@
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
- }