@squidcloud/client 1.0.188 → 1.0.189

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 (26) hide show
  1. package/dist/cjs/index.js +21290 -21213
  2. package/dist/internal-common/src/public-types/integration.public-types.d.ts +0 -9
  3. package/dist/typescript-client/src/ai-assistant-client.d.ts +0 -2
  4. package/dist/typescript-client/src/ai-chatbot-client.d.ts +20 -25
  5. package/dist/typescript-client/src/api.manager.d.ts +1 -10
  6. package/dist/typescript-client/src/auth.manager.d.ts +1 -22
  7. package/dist/typescript-client/src/backend-function.manager.d.ts +1 -9
  8. package/dist/typescript-client/src/client-id.service.d.ts +1 -27
  9. package/dist/typescript-client/src/collection-reference.d.ts +2 -1
  10. package/dist/typescript-client/src/graphql-client.d.ts +1 -3
  11. package/dist/typescript-client/src/graphql-client.factory.d.ts +1 -11
  12. package/dist/typescript-client/src/index.d.ts +40 -10
  13. package/dist/typescript-client/src/native-query-manager.d.ts +1 -7
  14. package/dist/typescript-client/src/public-types.d.ts +0 -2
  15. package/dist/typescript-client/src/query/deserializer.d.ts +2 -1
  16. package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +12 -2
  17. package/dist/{internal-common/src/public-types/pagination.public-types.d.ts → typescript-client/src/query/pagination.d.ts} +1 -1
  18. package/dist/typescript-client/src/query/query-builder.factory.d.ts +117 -10
  19. package/dist/typescript-client/src/query/snapshot-emitter.d.ts +34 -0
  20. package/dist/typescript-client/src/rate-limiter.d.ts +1 -32
  21. package/dist/typescript-client/src/rpc.manager.d.ts +1 -24
  22. package/dist/typescript-client/src/secret.client.d.ts +1 -5
  23. package/dist/typescript-client/src/squid-http-client.d.ts +0 -9
  24. package/package.json +1 -1
  25. package/dist/internal-common/src/public-types/base-query-builder.public-types.d.ts +0 -147
  26. package/dist/typescript-client/src/testing/setup-tests.d.ts +0 -1
@@ -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",
@@ -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,42 @@
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';
@@ -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';
@@ -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,122 @@
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. '%' is the only allowed wildcard
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. '%' is the only allowed wildcard
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
+ /**
105
+ * Sets a limit to the number of results returned by the query. The maximum limit is 20,000 and the default is 1,000
106
+ * if none is provided.
107
+ * @param limit The limit to set.
108
+ * @returns The query builder.
109
+ */
110
+ abstract limit(limit: number): this;
111
+ /**
112
+ * Adds a sort order to the query. You can add multiple sort orders to the query. The order in which you add them
113
+ * determines the order in which they are applied.
114
+ * @param fieldName The name of the field to sort by.
115
+ * @param asc Whether to sort in ascending order. Defaults to true.
116
+ * @returns The query builder.
117
+ */
118
+ abstract sortBy(fieldName: keyof MyDocType & FieldName, asc?: boolean): this;
119
+ }
4
120
  /** A query builder that can be used to build a query that returns a list of documents. */
5
121
  export declare class QueryBuilder<DocumentType extends DocumentData> extends BaseQueryBuilder<DocumentType> implements SnapshotEmitter<DocumentReference<DocumentType>>, HasDereference {
6
122
  private readonly collectionName;
@@ -55,8 +171,6 @@ export declare class QueryBuilder<DocumentType extends DocumentData> extends Bas
55
171
  clone(): QueryBuilder<DocumentType>;
56
172
  addCompositeCondition(conditions: Array<SimpleCondition>): QueryBuilder<DocumentType>;
57
173
  flipSortOrder(): QueryBuilder<DocumentType>;
58
- serialize(): SerializedSimpleQuery;
59
- extractData(data: DocumentReference<DocumentType>): DocumentType;
60
174
  paginate(options?: Partial<PaginationOptions>): Pagination<DocumentReference<DocumentType>>;
61
175
  }
62
176
  /** Describes the changes to a query result. */
@@ -67,11 +181,4 @@ export declare class Changes<DocumentType extends DocumentData> {
67
181
  readonly updates: Array<DocumentReference<DocumentType>>;
68
182
  /** The actual document data that was deleted from the query result */
69
183
  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
184
  }
@@ -0,0 +1,34 @@
1
+ import { Observable } from 'rxjs';
2
+ import { Pagination, PaginationOptions } from './pagination';
3
+ export interface SnapshotEmitter<ReturnType> {
4
+ /**
5
+ * Returns a promise that resolves to the query results.
6
+ *
7
+ * @returns A promise that resolves to the query results.
8
+ */
9
+ snapshot(): Promise<Array<ReturnType>>;
10
+ /**
11
+ * Returns an observable that emits the query results and updates whenever the query results change unless
12
+ * `subscribe=false` is provided.
13
+ *
14
+ * Important: Make sure to unsubscribe from the observable when you are done with it.
15
+ *
16
+ * @param subscribe Whether to subscribe to changes to the query results. Defaults to `true`.
17
+ * @returns An observable for the query results.
18
+ */
19
+ snapshots(subscribe?: boolean): Observable<Array<ReturnType>>;
20
+ /**
21
+ * Returns the results of the query based on the data that is currently available on the client. This method is useful
22
+ * for synchronously accessing data that has already been fetched by another query. The method will return an empty
23
+ * array if data has not yet been populated.
24
+ *
25
+ * @returns An array of query results.
26
+ */
27
+ peek(): Array<ReturnType>;
28
+ limit(limit: number): SnapshotEmitter<ReturnType>;
29
+ /**
30
+ * Returns a pagination wrapper for this query.
31
+ * @param options The pagination options. Defaults to `{ subscribe: true, pageSize: 100 }`.
32
+ */
33
+ paginate(options?: Partial<PaginationOptions>): Pagination<ReturnType>;
34
+ }
@@ -1,32 +1 @@
1
- export declare class RateLimiter {
2
- private readonly capacity;
3
- private readonly seconds;
4
- private tokens;
5
- private lastRefillTimestamp;
6
- private readonly refillRatePerMs;
7
- /**
8
- * Creates a new rate limiter. It limits the number of requests using two parameters:
9
- * - capacity: the maximum number of tokens (actions) that can be stored at any given time
10
- * - seconds: the number of seconds it takes to refill the bucket to its maximum capacity
11
- *
12
- * We then can calculate the refillRatePerMs: the number of tokens (actions) that are added to the bucket every
13
- * millisecond
14
- *
15
- * Example:
16
- * Say we want to allow maximum 60 requests in a period of 5 seconds. We can create a rate limiter with:
17
- * - capacity: 60
18
- * - seconds: 5
19
- * And we will get refillRatePerMs: 60 / (5 * 1000) = 0.012
20
- *
21
- * To use:
22
- * const rateLimiter = new RateLimiter(60, 5);
23
- * await rateLimiter.consume();
24
- *
25
- * @param capacity
26
- * @param refillRatePerMs
27
- */
28
- constructor(capacity: number, seconds: number);
29
- consume(): Promise<void>;
30
- private attemptConsume;
31
- private refill;
32
- }
1
+ export {};
@@ -1,24 +1 @@
1
- import { AuthManager } from './auth.manager';
2
- import { ClientIdService } from './client-id.service';
3
- import { DestructManager } from './destruct.manager';
4
- import { BlobAndFilename } from './types';
5
- import { SquidRegion } from './public-types';
6
- import { HttpResponse } from './squid-http-client';
7
- export declare class RpcManager {
8
- private readonly region;
9
- private readonly appId;
10
- private readonly authManager;
11
- private readonly clientIdService;
12
- private readonly staticHeaders;
13
- private readonly onGoingRpcCounter;
14
- private readonly rateLimiters;
15
- constructor(region: SquidRegion, appId: string, destructManager: DestructManager, headers: Record<string, string>, authManager: AuthManager, clientIdService: ClientIdService);
16
- private getAuthHeaders;
17
- awaitAllSettled(): Promise<void>;
18
- setStaticHeader(key: string, value: string): void;
19
- deleteStaticHeader(key: string): void;
20
- getStaticHeaders(): Record<string, string>;
21
- post<ResponseType = unknown, RequestType = unknown>(path: string, message: RequestType, files?: Array<File | BlobAndFilename>, filesFieldName?: string): Promise<ResponseType>;
22
- rawPost<ResponseType = unknown, RequestType = unknown>(path: string, message: RequestType, files?: Array<File | BlobAndFilename>, filesFieldName?: string, extractErrorMessage?: boolean): Promise<HttpResponse<ResponseType>>;
23
- private getRateLimiterBucket;
24
- }
1
+ export {};
@@ -1,8 +1,6 @@
1
1
  import { SecretEntry, SecretKey, SecretValue, SetSecretRequestEntry } from './public-types';
2
- import { RpcManager } from './rpc.manager';
3
2
  export declare class SecretClient {
4
3
  private readonly rpcManager;
5
- constructor(rpcManager: RpcManager);
6
4
  get(key: SecretKey): Promise<SecretEntry | undefined>;
7
5
  getAll(): Promise<Record<SecretKey, SecretEntry>>;
8
6
  upsert(key: SecretKey, value: SecretValue): Promise<SecretEntry>;
@@ -11,12 +9,10 @@ export declare class SecretClient {
11
9
  deleteMany(keys: Array<SecretKey>): Promise<void>;
12
10
  get apiKeys(): ApiKeysSecretClient;
13
11
  }
14
- declare class ApiKeysSecretClient {
12
+ export declare class ApiKeysSecretClient {
15
13
  private readonly rpcManager;
16
- constructor(rpcManager: RpcManager);
17
14
  get(key: SecretKey): Promise<SecretEntry | undefined>;
18
15
  getAll(): Promise<Record<SecretKey, SecretEntry>>;
19
16
  upsert(key: SecretKey): Promise<SecretEntry>;
20
17
  delete(key: SecretKey): Promise<void>;
21
18
  }
22
- export {};