@squidcloud/client 1.0.188 → 1.0.190

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 (35) hide show
  1. package/dist/cjs/index.js +21383 -21132
  2. package/dist/internal-common/src/public-types/bundle-api.public-types.d.ts +3 -1
  3. package/dist/internal-common/src/public-types/bundle-data.public-types.d.ts +2 -0
  4. package/dist/internal-common/src/public-types/integration.public-types.d.ts +2 -9
  5. package/dist/internal-common/src/public-types/integrations/api.public-types.d.ts +3 -0
  6. package/dist/internal-common/src/public-types/storage.types.d.ts +9 -0
  7. package/dist/internal-common/src/types/query.types.d.ts +10 -1
  8. package/dist/internal-common/src/utils/object.d.ts +6 -2
  9. package/dist/typescript-client/src/ai-assistant-client.d.ts +0 -2
  10. package/dist/typescript-client/src/ai-chatbot-client.d.ts +20 -25
  11. package/dist/typescript-client/src/api.manager.d.ts +1 -10
  12. package/dist/typescript-client/src/auth.manager.d.ts +1 -22
  13. package/dist/typescript-client/src/backend-function.manager.d.ts +1 -9
  14. package/dist/typescript-client/src/client-id.service.d.ts +1 -27
  15. package/dist/typescript-client/src/collection-reference.d.ts +2 -1
  16. package/dist/typescript-client/src/graphql-client.d.ts +1 -3
  17. package/dist/typescript-client/src/graphql-client.factory.d.ts +1 -11
  18. package/dist/typescript-client/src/index.d.ts +41 -10
  19. package/dist/typescript-client/src/native-query-manager.d.ts +1 -7
  20. package/dist/typescript-client/src/public-types.d.ts +1 -2
  21. package/dist/typescript-client/src/query/deserializer.d.ts +2 -1
  22. package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +12 -2
  23. package/dist/{internal-common/src/public-types/pagination.public-types.d.ts → typescript-client/src/query/pagination.d.ts} +1 -1
  24. package/dist/typescript-client/src/query/query-builder.factory.d.ts +118 -10
  25. package/dist/typescript-client/src/query/snapshot-emitter.d.ts +34 -0
  26. package/dist/typescript-client/src/rate-limiter.d.ts +1 -32
  27. package/dist/typescript-client/src/rpc.manager.d.ts +1 -24
  28. package/dist/typescript-client/src/secret.client.d.ts +1 -5
  29. package/dist/typescript-client/src/squid-http-client.d.ts +0 -9
  30. package/dist/typescript-client/src/squid.d.ts +12 -1
  31. package/dist/typescript-client/src/storage-client.d.ts +53 -0
  32. package/package.json +1 -1
  33. package/dist/internal-common/src/public-types/base-query-builder.public-types.d.ts +0 -147
  34. package/dist/typescript-client/src/backend-transforms.d.ts +0 -0
  35. /package/dist/{typescript-client/src/testing/setup-tests.d.ts → internal-common/src/types/integrations/storage-types.d.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { MutationContext } from './mutation.public-context';
2
2
  import { ApiCallContext } from './api-call.public-context';
3
3
  import { QueryContext } from './query.public-context';
4
- import { AiChatbotActionType, DatabaseActionType, TopicActionType } from './bundle-data.public-types';
4
+ import { AiChatbotActionType, DatabaseActionType, StorageActionType, TopicActionType } from './bundle-data.public-types';
5
5
  import { ClientConnectionState } from './socket.public-types';
6
6
  import { DocumentData } from './document.public-types';
7
7
  import { MutationType } from './mutation.public-types';
@@ -11,7 +11,9 @@ import { NativeQueryContext } from './native-query.public-context';
11
11
  import { DistributedLockContext } from './distributed-lock.public-context';
12
12
  import { GraphqlContext } from './graphql.public-context';
13
13
  import { AiChatbotChatContext, AiChatbotMutationContext } from './ai-chatbot.public-context';
14
+ import { SecureStorageRequest } from './storage.types';
14
15
  export type SecureDatabaseAction<T extends DatabaseActionType> = T extends 'all' ? () => boolean | Promise<boolean> : T extends 'read' ? ((context: QueryContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>) : ((context: MutationContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
16
+ export type SecureStorageAction<T extends StorageActionType> = T extends 'all' ? () => boolean | Promise<boolean> : (request: SecureStorageRequest) => boolean | Promise<boolean>;
15
17
  export type SecureTopicAction<T extends TopicActionType> = T extends 'all' ? () => boolean | Promise<boolean> : T extends 'read' ? ((context: TopicReadContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>) : ((context: TopicWriteContext<T>) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
16
18
  export type SecureApiAction = ((context: ApiCallContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
17
19
  export type SecureNativeQueryAction = ((context: NativeQueryContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
@@ -1,5 +1,7 @@
1
1
  /** The different types of actions that can be performed on a database. */
2
2
  export type DatabaseActionType = 'read' | 'write' | 'update' | 'insert' | 'delete' | 'all';
3
+ /** The different types of actions that can be performed for storage. */
4
+ export type StorageActionType = 'read' | 'write' | 'update' | 'insert' | 'delete' | 'all';
3
5
  /** The different types of actions that can be performed on a topic. */
4
6
  export type TopicActionType = 'read' | 'write' | 'all';
5
7
  /** The different types of actions that can be performed on an AI chatbot. */
@@ -1,12 +1,3 @@
1
- export declare enum IntegrationCategory {
2
- 'database' = "database",
3
- 'queue' = "queue",
4
- 'api' = "api",
5
- 'observability' = "observability",
6
- 'crm' = "crm",
7
- 'auth' = "auth",
8
- 'ai' = "ai"
9
- }
10
1
  export declare enum IntegrationType {
11
2
  'built_in_db' = "built_in_db",
12
3
  'mongo' = "mongo",
@@ -30,6 +21,8 @@ export declare enum IntegrationType {
30
21
  'kafka' = "kafka",
31
22
  'confluent' = "confluent",
32
23
  'built_in_queue' = "built_in_queue",
24
+ 's3' = "s3",
25
+ 'built_in_s3' = "built_in_s3",
33
26
  'algolia' = "algolia",
34
27
  'elastic_observability' = "elastic_observability",
35
28
  'elastic_search' = "elastic_search",
@@ -39,3 +39,6 @@ export interface DiscoverOpenApiSchemaRequest {
39
39
  integrationType: IntegrationType.api;
40
40
  discoveryOptions: OpenApiDiscoveryOptions;
41
41
  }
42
+ export interface DiscoverOpenApiSchemaFromFileRequest {
43
+ integrationType: IntegrationType.api;
44
+ }
@@ -0,0 +1,9 @@
1
+ import { IntegrationId } from './communication.public-types';
2
+ import { StorageActionType } from './bundle-data.public-types';
3
+ export type StorageFunctionality = 'fileUpload';
4
+ export interface SecureStorageRequest {
5
+ integrationId: IntegrationId;
6
+ pathsInBucket: Array<string>;
7
+ action: StorageActionType;
8
+ functionality: StorageFunctionality;
9
+ }
@@ -1 +1,10 @@
1
- export {};
1
+ /**
2
+ * Generates the regex pattern, handling special characters as follows:
3
+ * - `_` is replaced with a `.`
4
+ * - `%` is replaced with `[\s\S]*`.
5
+ * - The above characters can be escaped with \, eg. `\_` is replaced with `_` and `\%` with `%`.
6
+ * - All special characters in regex (-, /, \, ^, $, *, +, ?, ., (, ), |, [, ], {, }) get escaped with \
7
+ *
8
+ * Exported for testing purposes.
9
+ * */
10
+ export declare function replaceSpecialCharacters(input: string): string;
@@ -9,8 +9,12 @@ export declare function replaceKeyInRecord<K extends keyof any, T>(record: Recor
9
9
  export declare function isNil(obj: unknown): obj is null | undefined;
10
10
  export declare function isEqual(a: unknown, b: unknown): boolean;
11
11
  export declare function isEmpty(a: unknown): boolean;
12
- export declare function omit<T extends object, K extends (string | number | symbol)[]>(object: T | null | undefined, ...paths: K): Pick<T, Exclude<keyof T, K[number]>>;
12
+ export declare function omit<T extends object, K extends PropertyKey[]>(object: T | null | undefined, ...fieldsToRemove: K): Pick<T, Exclude<keyof T, K[number]>>;
13
13
  /** Creates a deep copy of the object. Copies all Date, Map, Set fields. */
14
14
  export declare function cloneDeep<T>(value: T): T;
15
15
  /** Compares 2 values. 'null' and 'undefined' values are considered equal and are less than any other values. */
16
- export declare function compareValues(a: any, b: any): number;
16
+ export declare function compareValues(v1: unknown, v2: unknown): number;
17
+ /** Returns a new object with all top-level object fields re-mapped using `valueMapperFn`. */
18
+ export declare function mapValues<ResultType extends object = Record<string, unknown>, InputType extends Record<string, unknown> = Record<string, unknown>>(obj: InputType, valueMapperFn: (value: any, key: keyof InputType, obj: InputType) => unknown): ResultType;
19
+ /** Groups elements of the array by key. See _.groupBy for details. */
20
+ export declare function groupBy<T, K extends PropertyKey>(array: T[], getKey: (item: T) => K): Record<K, T[]>;
@@ -1,5 +1,4 @@
1
1
  import { AssistantToolType, FunctionName } from './public-types';
2
- import { RpcManager } from './rpc.manager';
3
2
  import { BlobAndFilename } from './types';
4
3
  /**
5
4
  * Client class for interacting with an AI Assistant server.
@@ -8,7 +7,6 @@ import { BlobAndFilename } from './types';
8
7
  */
9
8
  export declare class AiAssistantClient {
10
9
  private readonly rpcManager;
11
- constructor(rpcManager: RpcManager);
12
10
  /**
13
11
  * Creates a new AI assistant with specified characteristics.
14
12
  * @param name - The name of the assistant.
@@ -26,6 +26,18 @@ export declare class AiChatbotClient {
26
26
  chat(profileId: string, prompt: string, options?: AiChatbotChatOptions): Observable<string>;
27
27
  private handleChatResponse;
28
28
  }
29
+ export interface AiChatBotContextData {
30
+ title: string;
31
+ context: AiChatbotContext;
32
+ }
33
+ export interface ProfileData {
34
+ modelName: AiModelName;
35
+ /** If the profile is public, there is no need to write a security rule to access the chat functionality. This can be dangerous, use with caution. */
36
+ isPublic: boolean;
37
+ }
38
+ export interface InstructionData {
39
+ instruction: string;
40
+ }
29
41
  export declare class AiChatbotProfileReference {
30
42
  private readonly client;
31
43
  private readonly integrationId;
@@ -65,10 +77,7 @@ export declare class AiChatbotProfileReference {
65
77
  * @param data.isPublic - Whether the chat functionality of the profile can be accessed without security rules.
66
78
  * @returns A promise that resolves when the profile is successfully created.
67
79
  */
68
- insert(data: {
69
- modelName: AiModelName;
70
- isPublic: boolean;
71
- }): Promise<void>;
80
+ insert(data: ProfileData): Promise<void>;
72
81
  /**
73
82
  * Updates an existing chatbot profile. This will result in an error if a profile has not yet been created for the
74
83
  * current profile id.
@@ -78,10 +87,7 @@ export declare class AiChatbotProfileReference {
78
87
  * @param data.isPublic - Whether the chat functionality of the profile can be accessed without security rules.
79
88
  * @returns A promise that resolves when the profile is successfully updated.
80
89
  */
81
- update(data: {
82
- modelName?: AiModelName;
83
- isPublic?: boolean;
84
- }): Promise<void>;
90
+ update(data: Partial<ProfileData>): Promise<void>;
85
91
  /**
86
92
  * Deletes an existing chatbot profile. This will result in an error if a profile has not yet been created for the
87
93
  * current profile id.
@@ -90,7 +96,7 @@ export declare class AiChatbotProfileReference {
90
96
  */
91
97
  delete(): Promise<void>;
92
98
  }
93
- declare class AiChatbotContextReference {
99
+ export declare class AiChatbotContextReference {
94
100
  private readonly client;
95
101
  private readonly integrationId;
96
102
  private readonly profileId;
@@ -105,10 +111,7 @@ declare class AiChatbotContextReference {
105
111
  * @param file - The file to insert.
106
112
  * @returns A promise that resolves when the context is successfully created.
107
113
  */
108
- insert(data: {
109
- title: string;
110
- context: AiChatbotContext;
111
- }, file?: File): Promise<void>;
114
+ insert(data: AiChatBotContextData, file?: File): Promise<void>;
112
115
  /**
113
116
  * Updates an existing context entry on the chatbot profile. This will result in an error if an entry has not yet
114
117
  * been created for the current context id.
@@ -118,10 +121,7 @@ declare class AiChatbotContextReference {
118
121
  * @param data.context - The context data.
119
122
  * @returns A promise that resolves when the context is successfully updated.
120
123
  */
121
- update(data: {
122
- title?: string;
123
- context?: AiChatbotContext;
124
- }): Promise<void>;
124
+ update(data: Partial<AiChatBotContextData>): Promise<void>;
125
125
  /**
126
126
  * Deletes an existing context entry on the chatbot profile. This will result in an error if an entry has not yet
127
127
  * been created for the current context id.
@@ -130,7 +130,7 @@ declare class AiChatbotContextReference {
130
130
  */
131
131
  delete(): Promise<void>;
132
132
  }
133
- declare class AiChatbotInstructionReference {
133
+ export declare class AiChatbotInstructionReference {
134
134
  private readonly client;
135
135
  private readonly integrationId;
136
136
  private readonly profileId;
@@ -143,9 +143,7 @@ declare class AiChatbotInstructionReference {
143
143
  * @param data.instruction - The instruction data.
144
144
  * @returns A promise that resolves when the instruction is successfully created.
145
145
  */
146
- insert(data: {
147
- instruction: string;
148
- }): Promise<void>;
146
+ insert(data: InstructionData): Promise<void>;
149
147
  /**
150
148
  * Updates an existing instruction entry on the chatbot profile. This will result in an error if an entry has not
151
149
  * yet been created for the current instruction id.
@@ -154,9 +152,7 @@ declare class AiChatbotInstructionReference {
154
152
  * @param data.instruction - The instruction data.
155
153
  * @returns A promise that resolves when the instruction is successfully updated.
156
154
  */
157
- update(data: {
158
- instruction: string;
159
- }): Promise<void>;
155
+ update(data: InstructionData): Promise<void>;
160
156
  /**
161
157
  * Deletes an existing instruction entry on the chatbot profile. This will result in an error if an entry has not
162
158
  * yet been created for the current instruction id.
@@ -165,4 +161,3 @@ declare class AiChatbotInstructionReference {
165
161
  */
166
162
  delete(): Promise<void>;
167
163
  }
168
- export {};
@@ -1,10 +1 @@
1
- import { Observable } from 'rxjs';
2
- import { RpcManager } from './rpc.manager';
3
- import { ClientIdService } from './client-id.service';
4
- import { ApiEndpointId, CallApiOptions, IntegrationId } from './public-types';
5
- export declare class ApiManager {
6
- private readonly clientIdService;
7
- private readonly rpcManager;
8
- constructor(clientIdService: ClientIdService, rpcManager: RpcManager);
9
- callApiAndSubscribe<T>(integrationId: IntegrationId, endpointId: ApiEndpointId, request: Record<string, any>, options: CallApiOptions): Observable<T>;
10
- }
1
+ export {};
@@ -1,27 +1,6 @@
1
- import { SquidAuthProvider } from './squid';
2
- import { ApiKey, AuthToken, IntegrationId } from './public-types';
1
+ import { IntegrationId } from './public-types';
3
2
  /** Holds authentication token for the specified integration. */
4
3
  export interface AuthData {
5
4
  token: string | undefined;
6
5
  integrationId?: IntegrationId;
7
6
  }
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 +1 @@
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
+ export {};
@@ -1,27 +1 @@
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
- notifyClientNotTooOld(): void;
23
- observeClientReadyToBeRegenerated(): Observable<void>;
24
- getClientId(): ClientId;
25
- isClientTooOld(): boolean;
26
- private generateClientId;
27
- }
1
+ export {};
@@ -1,7 +1,8 @@
1
- import { Alias, DocId, DocIdObj, DocumentData, SnapshotEmitter } from './public-types';
1
+ import { Alias, DocId, DocIdObj, DocumentData } from './public-types';
2
2
  import { DocumentReference } from './document-reference';
3
3
  import { JoinQueryBuilder } from './query/join-query-builder.factory';
4
4
  import { QueryBuilder } from './query/query-builder.factory';
5
+ import { SnapshotEmitter } from './query/snapshot-emitter';
5
6
  /**
6
7
  * Holds a reference to a data collection. A collection reference is a reference to a collection in a database. You
7
8
  * can use it to read or write data to the collection. A collection can refer to a table in a relational database or a
@@ -1,12 +1,10 @@
1
- import { RpcManager } from './rpc.manager';
2
- import { GraphQLRequest, IntegrationId, SquidRegion } from './public-types';
1
+ import { GraphQLRequest } from './public-types';
3
2
  /** A GraphQL client that can be used to query and mutate data. */
4
3
  export declare class GraphQLClient {
5
4
  private readonly rpcManager;
6
5
  private readonly region;
7
6
  private readonly appId;
8
7
  private readonly client;
9
- constructor(rpcManager: RpcManager, integrationId: IntegrationId, region: SquidRegion, appId: string);
10
8
  /** Executes a GraphQL query and returns a promise with the result. */
11
9
  query<T = any>(request: GraphQLRequest): Promise<T>;
12
10
  /** Executes a GraphQL mutation and returns a promise with the result. */
@@ -1,11 +1 @@
1
- import { GraphQLClient } from './graphql-client';
2
- import { RpcManager } from './rpc.manager';
3
- import { IntegrationId, SquidRegion } from './public-types';
4
- export declare class GraphQLClientFactory {
5
- private readonly rpcManager;
6
- private readonly region;
7
- private readonly appId;
8
- private readonly clientsMap;
9
- constructor(rpcManager: RpcManager, region: SquidRegion, appId: string);
10
- get(integrationId: IntegrationId): GraphQLClient;
11
- }
1
+ export {};
@@ -1,12 +1,43 @@
1
- export { AiChatbotProfileReference } from './ai-chatbot-client';
2
- export { CollectionReference } from './collection-reference';
3
- export { DocumentReference } from './document-reference';
4
- export { GraphQLClient } from './graphql-client';
1
+ export * from './ai-assistant-client';
2
+ export * from './ai-chatbot-client.factory';
3
+ export * from './ai-chatbot-client';
4
+ export * from './ai.types';
5
+ export * from './api-client';
6
+ export * from './api.manager';
7
+ export * from './auth.manager';
8
+ export * from './backend-function.manager';
9
+ export * from './client-id.service';
10
+ export * from './collection-reference.factory';
11
+ export * from './collection-reference';
12
+ export * from './connection-details';
13
+ export * from './data.manager';
14
+ export * from './destruct.manager';
15
+ export * from './distributed-lock.manager';
16
+ export * from './document-identity.service';
17
+ export * from './document-reference.factory';
18
+ export * from './document-reference';
19
+ export * from './document-store';
20
+ export * from './graphql-client.factory';
21
+ export * from './graphql-client';
22
+ export * from './mutation/mutation-sender';
23
+ export * from './native-query-manager';
5
24
  export * from './public-types';
6
25
  export * from './public-utils';
7
- export { deserializeQuery } from './query/deserializer';
8
- export { JoinQueryBuilder } from './query/join-query-builder.factory';
9
- export { Changes, QueryBuilder } from './query/query-builder.factory';
10
- export { QueueManager } from './queue.manager';
11
- export { Squid, SquidOptions } from './squid';
12
- export { TransactionId } from './types';
26
+ export * from './query/deserializer';
27
+ export * from './query/join-query-builder.factory';
28
+ export * from './query/local-query-manager';
29
+ export * from './query/query-builder.factory';
30
+ export * from './query/query-sender';
31
+ export * from './query/query-subscription.manager';
32
+ export * from './query/query.types';
33
+ export * from './query/pagination';
34
+ export * from './query/snapshot-emitter';
35
+ export * from './queue.manager';
36
+ export * from './rate-limiter';
37
+ export * from './rpc.manager';
38
+ export * from './secret.client';
39
+ export * from './socket.manager';
40
+ export * from './squid-http-client';
41
+ export * from './squid';
42
+ export * from './types';
43
+ export * from './storage-client';
@@ -1,7 +1 @@
1
- import { RpcManager } from './rpc.manager';
2
- import { IntegrationId, NativeQueryRequest } from './public-types';
3
- export declare class NativeQueryManager {
4
- private readonly rpcManager;
5
- constructor(rpcManager: RpcManager);
6
- executeNativeQuery<T>(integrationId: IntegrationId, request: NativeQueryRequest): Promise<T>;
7
- }
1
+ export {};
@@ -3,7 +3,6 @@ export * from '../../internal-common/src/public-types/ai-chatbot.public-context'
3
3
  export * from '../../internal-common/src/public-types/ai-chatbot.public-types';
4
4
  export * from '../../internal-common/src/public-types/api-call.public-context';
5
5
  export * from '../../internal-common/src/public-types/application.public-types';
6
- export * from '../../internal-common/src/public-types/base-query-builder.public-types';
7
6
  export * from '../../internal-common/src/public-types/bundle-api.public-types';
8
7
  export * from '../../internal-common/src/public-types/bundle-data.public-types';
9
8
  export * from '../../internal-common/src/public-types/communication.public-types';
@@ -21,7 +20,6 @@ export * from '../../internal-common/src/public-types/mutation.public-types';
21
20
  export * from '../../internal-common/src/public-types/native-query.public-context';
22
21
  export * from '../../internal-common/src/public-types/native-query.public-types';
23
22
  export * from '../../internal-common/src/public-types/openapi.public-types';
24
- export * from '../../internal-common/src/public-types/pagination.public-types';
25
23
  export * from '../../internal-common/src/public-types/query.public-context';
26
24
  export * from '../../internal-common/src/public-types/query.public-types';
27
25
  export * from '../../internal-common/src/public-types/regions.public-types';
@@ -31,3 +29,4 @@ export * from '../../internal-common/src/public-types/serialized-query.public-ty
31
29
  export * from '../../internal-common/src/public-types/socket.public-types';
32
30
  export * from '../../internal-common/src/public-types/topic.public-context';
33
31
  export * from '../../internal-common/src/public-types/typescript.public-types';
32
+ export * from '../../internal-common/src/public-types/storage.types';
@@ -1,3 +1,4 @@
1
1
  import { Squid } from '../squid';
2
- import { SerializedQuery, SnapshotEmitter } from '../public-types';
2
+ import { SerializedQuery } from '../public-types';
3
+ import { SnapshotEmitter } from './snapshot-emitter';
3
4
  export declare function deserializeQuery<ReturnType = any>(squid: Squid, serializedQuery: SerializedQuery): SnapshotEmitter<ReturnType>;
@@ -1,10 +1,20 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { DocumentReference } from '../document-reference';
3
- import { QueryBuilder } from './query-builder.factory';
4
- import { Alias, BaseQueryBuilder, DocumentData, FieldName, FieldSort, HasDereference, Operator, Pagination, PaginationOptions, PrimitiveFieldType, SerializedJoinQuery, SimpleCondition, SnapshotEmitter } from '../public-types';
3
+ import { BaseQueryBuilder, HasDereference, QueryBuilder } from './query-builder.factory';
4
+ import { Alias, DocumentData, FieldName, FieldSort, Operator, PrimitiveFieldType, SerializedJoinQuery, SimpleCondition } from '../public-types';
5
+ import { Pagination, PaginationOptions } from './pagination';
6
+ import { SnapshotEmitter } from './snapshot-emitter';
5
7
  type WithDocumentReferences<T extends Record<any, DocumentData>> = {
6
8
  [k in keyof T]: DocumentReference<Required<T>[k]>;
7
9
  };
10
+ export interface JoinFields<ReturnType> {
11
+ left: FieldName;
12
+ right: keyof ReturnType & FieldName;
13
+ }
14
+ export interface JoinOptions {
15
+ leftAlias: Alias;
16
+ isInner?: boolean;
17
+ }
8
18
  type Grouped<Aliases extends Record<Alias, Alias[]>, ReturnType extends Record<Alias, any>, RootAlias extends Alias> = Aliases[RootAlias] extends [] ? Required<ReturnType>[RootAlias] : Record<RootAlias, Required<ReturnType>[RootAlias]> & OtherGroups<Aliases, ReturnType, Aliases[RootAlias]>;
9
19
  type OtherGroups<Aliases extends Record<Alias, Alias[]>, ReturnType extends Record<Alias, any>, ManyRootAliases extends Alias[]> = ManyRootAliases extends [infer First extends Alias, ...infer Rest extends Alias[]] ? Record<First, Array<Grouped<Aliases, ReturnType, First>>> & OtherGroups<Aliases, ReturnType, Rest> : Record<Alias, never>;
10
20
  interface HasGrouped {
@@ -22,7 +22,7 @@ interface InternalState<ReturnType> {
22
22
  numAfter: number;
23
23
  }
24
24
  export declare class Pagination<ReturnType> {
25
- private readonly options;
25
+ private readonly paginateOptions;
26
26
  private internalStateObserver;
27
27
  private firstElement;
28
28
  private readonly isDestroyed;
@@ -1,6 +1,123 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { DocumentReference } from '../document-reference';
3
- import { BaseQueryBuilder, DocumentData, FieldName, FieldSort, HasDereference, Operator, Pagination, PaginationOptions, PrimitiveFieldType, SerializedSimpleQuery, SimpleCondition, SnapshotEmitter } from '../public-types';
3
+ import { DocumentData, FieldName, FieldSort, Operator, PrimitiveFieldType, SimpleCondition } from '../public-types';
4
+ import { Pagination, PaginationOptions } from './pagination';
5
+ import { SnapshotEmitter } from './snapshot-emitter';
6
+ /**
7
+ * Interface used solely for @inheritDoc
8
+ */
9
+ export interface HasDereference {
10
+ /**
11
+ * Dereferences the document references in the result of this query. For example, collection.query().snapshot()
12
+ * returns an array of DocumentReference objects, but collection.query().dereference().snapshot() returns an array of
13
+ * the actual document data.
14
+ */
15
+ dereference(): any;
16
+ }
17
+ /**
18
+ * Query builder base class.
19
+ */
20
+ export declare abstract class BaseQueryBuilder<MyDocType extends DocumentData> {
21
+ /**
22
+ * Adds a condition to the query.
23
+ * @param fieldName The name of the field to query.
24
+ * @param operator The operator to use.
25
+ * @param value The value to compare against.
26
+ * @returns The query builder.
27
+ */
28
+ abstract where(fieldName: (keyof MyDocType & FieldName) | string, operator: Operator | 'in' | 'not in', value: PrimitiveFieldType | Array<PrimitiveFieldType>): this;
29
+ /**
30
+ * A shortcut for where(fieldName, '==', value)
31
+ *
32
+ * @param fieldName The name of the field to query.
33
+ * @param value The value to compare against.
34
+ * @returns The query builder.
35
+ */
36
+ eq(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
37
+ /**
38
+ * A shortcut for where(fieldName, '!=', value)
39
+ * @param fieldName The name of the field to query.
40
+ * @param value The value to compare against.
41
+ * @returns The query builder.
42
+ */
43
+ neq(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
44
+ /**
45
+ * A shortcut for where(fieldName, 'in', value)
46
+ * @param fieldName The name of the field to query.
47
+ * @param value An array of values to compare against.
48
+ * @returns The query builder.
49
+ */
50
+ in(fieldName: (keyof MyDocType & FieldName) | string, value: Array<PrimitiveFieldType>): this;
51
+ /**
52
+ * A shortcut for where(fieldName, 'not in', value)
53
+ * @param fieldName The name of the field to query.
54
+ * @param value An array of values to compare against.
55
+ * @returns The query builder.
56
+ */
57
+ nin(fieldName: (keyof MyDocType & FieldName) | string, value: Array<PrimitiveFieldType>): this;
58
+ /**
59
+ * A shortcut for where(fieldName, '>', value)
60
+ * @param fieldName The name of the field to query.
61
+ * @param value The value to compare against.
62
+ * @returns The query builder.
63
+ */
64
+ gt(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
65
+ /**
66
+ * A shortcut for where(fieldName, '>=', value)
67
+ * @param fieldName The name of the field to query.
68
+ * @param value The value to compare against.
69
+ * @returns The query builder.
70
+ */
71
+ gte(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
72
+ /**
73
+ * A shortcut for where(fieldName, '<', value)
74
+ * @param fieldName The name of the field to query.
75
+ * @param value The value to compare against.
76
+ * @returns The query builder.
77
+ */
78
+ lt(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
79
+ /**
80
+ * A shortcut for where(fieldName, '<=', value)
81
+ * @param fieldName The name of the field to query.
82
+ * @param value The value to compare against.
83
+ * @returns The query builder.
84
+ */
85
+ lte(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
86
+ /**
87
+ * A shortcut for where(fieldName, 'like', pattern).
88
+ *
89
+ * @param fieldName The name of the field to query.
90
+ * @param pattern The pattern to compare against. '%' matches 0 or more wildcard characters. '_' matches exactly one wildcard character. '\' can be used to escape '%', '_'. or another '\'. Note that any '\' that is not followed by '%', '_', or '\' is invalid.
91
+ * @param caseSensitive Whether to use case-sensitive comparison. Defaults to true.
92
+ * @returns The query builder.
93
+ */
94
+ like(fieldName: (keyof MyDocType & FieldName) | string, pattern: string, caseSensitive?: boolean): this;
95
+ /**
96
+ * A shortcut for where(fieldName, 'not like', pattern).
97
+ *
98
+ * @param fieldName The name of the field to query.
99
+ * @param pattern The pattern to compare against. '%' matches 0 or more wildcard characters. '_' matches exactly one wildcard character. '\' can be used to escape '%', '_'. or another '\'. Note that any '\' that is not followed by '%', '_', or '\' is invalid.
100
+ * @param caseSensitive Whether to use case-sensitive comparison. Defaults to true.
101
+ * @returns The query builder.
102
+ */
103
+ notLike(fieldName: (keyof MyDocType & FieldName) | string, pattern: string, caseSensitive?: boolean): this;
104
+ throwIfInvalidLikePattern(pattern: string): void;
105
+ /**
106
+ * Sets a limit to the number of results returned by the query. The maximum limit is 20,000 and the default is 1,000
107
+ * if none is provided.
108
+ * @param limit The limit to set.
109
+ * @returns The query builder.
110
+ */
111
+ abstract limit(limit: number): this;
112
+ /**
113
+ * Adds a sort order to the query. You can add multiple sort orders to the query. The order in which you add them
114
+ * determines the order in which they are applied.
115
+ * @param fieldName The name of the field to sort by.
116
+ * @param asc Whether to sort in ascending order. Defaults to true.
117
+ * @returns The query builder.
118
+ */
119
+ abstract sortBy(fieldName: keyof MyDocType & FieldName, asc?: boolean): this;
120
+ }
4
121
  /** A query builder that can be used to build a query that returns a list of documents. */
5
122
  export declare class QueryBuilder<DocumentType extends DocumentData> extends BaseQueryBuilder<DocumentType> implements SnapshotEmitter<DocumentReference<DocumentType>>, HasDereference {
6
123
  private readonly collectionName;
@@ -55,8 +172,6 @@ export declare class QueryBuilder<DocumentType extends DocumentData> extends Bas
55
172
  clone(): QueryBuilder<DocumentType>;
56
173
  addCompositeCondition(conditions: Array<SimpleCondition>): QueryBuilder<DocumentType>;
57
174
  flipSortOrder(): QueryBuilder<DocumentType>;
58
- serialize(): SerializedSimpleQuery;
59
- extractData(data: DocumentReference<DocumentType>): DocumentType;
60
175
  paginate(options?: Partial<PaginationOptions>): Pagination<DocumentReference<DocumentType>>;
61
176
  }
62
177
  /** Describes the changes to a query result. */
@@ -67,11 +182,4 @@ export declare class Changes<DocumentType extends DocumentData> {
67
182
  readonly updates: Array<DocumentReference<DocumentType>>;
68
183
  /** The actual document data that was deleted from the query result */
69
184
  readonly deletes: Array<DocumentType>;
70
- constructor(
71
- /** The newly inserted documents to the query result */
72
- inserts: Array<DocumentReference<DocumentType>>,
73
- /** The documents that were updated in the query result */
74
- updates: Array<DocumentReference<DocumentType>>,
75
- /** The actual document data that was deleted from the query result */
76
- deletes: Array<DocumentType>);
77
185
  }