@squidcloud/client 1.0.85 → 1.0.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +5 -5
- package/dist/common/src/ai-assistant.context.d.ts +12 -12
- package/dist/common/src/ai-assistant.schemas.d.ts +1 -1
- package/dist/common/src/ai-assistant.types.d.ts +2 -2
- package/dist/common/src/api-call.context.d.ts +13 -13
- package/dist/common/src/api.types.d.ts +4 -4
- package/dist/common/src/application.schemas.d.ts +1 -1
- package/dist/common/src/application.types.d.ts +184 -184
- package/dist/common/src/backend-function.schemas.d.ts +1 -1
- package/dist/common/src/backend-function.types.d.ts +1 -1
- package/dist/common/src/backend-run.types.d.ts +2 -2
- package/dist/common/src/bundle-api.types.d.ts +36 -36
- package/dist/common/src/bundle-data.types.d.ts +4 -4
- package/dist/common/src/communication.types.d.ts +12 -12
- package/dist/common/src/context.types.d.ts +40 -40
- package/dist/common/src/distributed-lock.context.d.ts +5 -5
- package/dist/common/src/document.types.d.ts +22 -22
- package/dist/common/src/graphql.context.d.ts +7 -7
- package/dist/common/src/graphql.types.d.ts +9 -9
- package/dist/common/src/heartbeat.types.d.ts +1 -1
- package/dist/common/src/http-status.enum.d.ts +50 -50
- package/dist/common/src/index.d.ts +53 -54
- package/dist/common/src/integrations/ai_assistant.types.d.ts +30 -30
- package/dist/common/src/integrations/api.types.d.ts +80 -80
- package/dist/common/src/integrations/auth.types.d.ts +39 -39
- package/dist/common/src/integrations/database.types.d.ts +236 -236
- package/dist/common/src/integrations/index.d.ts +101 -101
- package/dist/common/src/integrations/observability.types.d.ts +23 -23
- package/dist/common/src/logger.types.d.ts +21 -21
- package/dist/common/src/metrics.types.d.ts +1 -1
- package/dist/common/src/mutation.context.d.ts +14 -14
- package/dist/common/src/mutation.schemas.d.ts +1 -1
- package/dist/common/src/mutation.types.d.ts +53 -53
- package/dist/common/src/named-query.context.d.ts +4 -4
- package/dist/common/src/named-query.schemas.d.ts +1 -1
- package/dist/common/src/named-query.types.d.ts +1 -1
- package/dist/common/src/query/base-query-builder.d.ts +186 -130
- package/dist/common/src/query/index.d.ts +2 -2
- package/dist/common/src/query/query-context.d.ts +137 -109
- package/dist/common/src/query.types.d.ts +45 -57
- package/dist/common/src/regions.d.ts +1 -1
- package/dist/common/src/schema/schema.types.d.ts +54 -54
- package/dist/common/src/secret.schemas.d.ts +1 -1
- package/dist/common/src/secret.types.d.ts +8 -8
- package/dist/common/src/security.types.d.ts +1 -1
- package/dist/common/src/socket.schemas.d.ts +1 -1
- package/dist/common/src/socket.types.d.ts +1 -1
- package/dist/common/src/time-units.d.ts +1 -1
- package/dist/common/src/trigger.types.d.ts +1 -1
- package/dist/common/src/types.d.ts +14 -8
- package/dist/common/src/utils/array.d.ts +1 -1
- package/dist/common/src/utils/assert.d.ts +1 -1
- package/dist/common/src/utils/error.d.ts +4 -4
- package/dist/common/src/utils/http.d.ts +2 -2
- package/dist/common/src/utils/id.d.ts +2 -2
- package/dist/common/src/utils/lock.manager.d.ts +14 -14
- package/dist/common/src/utils/nullish.d.ts +1 -1
- package/dist/common/src/utils/object.d.ts +6 -6
- package/dist/common/src/utils/serialization.d.ts +6 -6
- package/dist/common/src/utils/transforms.d.ts +18 -18
- package/dist/common/src/utils/url.d.ts +1 -1
- package/dist/common/src/utils/validation.d.ts +30 -30
- package/dist/common/src/webhook-response.d.ts +1 -1
- package/dist/esm/index.js +5 -5
- package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -1239
- package/dist/typescript-client/src/ai-assistant-client.d.ts +167 -167
- package/dist/typescript-client/src/ai-client.factory.d.ts +11 -11
- package/dist/typescript-client/src/api.manager.d.ts +15 -15
- package/dist/typescript-client/src/auth.manager.d.ts +23 -23
- package/dist/typescript-client/src/backend-function.manager.d.ts +13 -13
- package/dist/typescript-client/src/client-id.service.d.ts +25 -25
- package/dist/typescript-client/src/collection-reference.d.ts +82 -82
- package/dist/typescript-client/src/collection-reference.factory.d.ts +13 -13
- package/dist/typescript-client/src/connection-details.d.ts +23 -23
- package/dist/typescript-client/src/data.manager.d.ts +172 -172
- package/dist/typescript-client/src/destruct.manager.d.ts +12 -12
- package/dist/typescript-client/src/distributed-lock.manager.d.ts +19 -19
- package/dist/typescript-client/src/document-identity.service.d.ts +12 -12
- package/dist/typescript-client/src/document-reference.d.ts +134 -134
- package/dist/typescript-client/src/document-reference.factory.d.ts +12 -12
- package/dist/typescript-client/src/document-store.d.ts +11 -11
- package/dist/typescript-client/src/graphql-client.d.ts +12 -12
- package/dist/typescript-client/src/graphql-client.factory.d.ts +9 -9
- package/dist/typescript-client/src/index.d.ts +8 -8
- package/dist/typescript-client/src/mutation/mutation-sender.d.ts +10 -10
- package/dist/typescript-client/src/named-query.manager.d.ts +12 -12
- package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +125 -122
- package/dist/typescript-client/src/query/query-builder.factory.d.ts +64 -64
- package/dist/typescript-client/src/query/query-subscription.manager.d.ts +135 -135
- package/dist/typescript-client/src/query/query.types.d.ts +14 -14
- package/dist/typescript-client/src/rpc.manager.d.ts +28 -28
- package/dist/typescript-client/src/socket.manager.d.ts +32 -32
- package/dist/typescript-client/src/squid.d.ts +217 -217
- package/dist/typescript-client/src/state/action.applier.d.ts +7 -7
- package/dist/typescript-client/src/state/actions.d.ts +29 -29
- package/dist/typescript-client/src/state/path_trie.d.ts +27 -27
- package/dist/typescript-client/src/state/state.service.d.ts +22 -22
- package/dist/typescript-client/src/state/state.service.spec.d.ts +1 -1
- package/dist/typescript-client/src/testing/setup-tests.d.ts +1 -1
- package/dist/typescript-client/src/types.d.ts +2 -2
- package/package.json +1 -1
- package/dist/common/src/query.schemas.d.ts +0 -3
|
@@ -1,130 +1,186 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export interface SnapshotEmitter<ReturnType> {
|
|
5
|
-
/**
|
|
6
|
-
* Returns a promise that resolves to the query results.
|
|
7
|
-
*
|
|
8
|
-
* @returns A promise that resolves to the query results.
|
|
9
|
-
*/
|
|
10
|
-
snapshot(): Promise<Array<ReturnType>>;
|
|
11
|
-
/**
|
|
12
|
-
* Returns an observable that emits the query results and updates whenever the query results change unless
|
|
13
|
-
* `subscribe=false` is provided.
|
|
14
|
-
*
|
|
15
|
-
* Important: Make sure to unsubscribe from the observable when you are done with it.
|
|
16
|
-
*
|
|
17
|
-
* @param subscribe Whether to subscribe to changes to the query results. Defaults to `true`.
|
|
18
|
-
* @returns An observable for the query results.
|
|
19
|
-
*/
|
|
20
|
-
snapshots(subscribe?: boolean): Observable<Array<ReturnType>>;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
* @param
|
|
43
|
-
* @
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
* @param
|
|
50
|
-
* @
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*
|
|
56
|
-
* @param
|
|
57
|
-
* @
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
* @param
|
|
64
|
-
* @
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
*
|
|
70
|
-
* @param
|
|
71
|
-
* @
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
*
|
|
77
|
-
* @param
|
|
78
|
-
* @
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
*
|
|
84
|
-
* @param
|
|
85
|
-
* @
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* @
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* @
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* @
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* @
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
*
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { DocumentData, FieldName, PrimitiveFieldType } from '../document.types';
|
|
3
|
+
import { Operator } from '../query.types';
|
|
4
|
+
export interface SnapshotEmitter<ReturnType> {
|
|
5
|
+
/**
|
|
6
|
+
* Returns a promise that resolves to the query results.
|
|
7
|
+
*
|
|
8
|
+
* @returns A promise that resolves to the query results.
|
|
9
|
+
*/
|
|
10
|
+
snapshot(): Promise<Array<ReturnType>>;
|
|
11
|
+
/**
|
|
12
|
+
* Returns an observable that emits the query results and updates whenever the query results change unless
|
|
13
|
+
* `subscribe=false` is provided.
|
|
14
|
+
*
|
|
15
|
+
* Important: Make sure to unsubscribe from the observable when you are done with it.
|
|
16
|
+
*
|
|
17
|
+
* @param subscribe Whether to subscribe to changes to the query results. Defaults to `true`.
|
|
18
|
+
* @returns An observable for the query results.
|
|
19
|
+
*/
|
|
20
|
+
snapshots(subscribe?: boolean): Observable<Array<ReturnType>>;
|
|
21
|
+
limit(limit: number): SnapshotEmitter<ReturnType>;
|
|
22
|
+
/**
|
|
23
|
+
* Returns a pagination wrapper for this query.
|
|
24
|
+
* @param options The pagination options. Defaults to `{ subscribe: true, pageSize: 100 }`.
|
|
25
|
+
*/
|
|
26
|
+
paginate(options?: Partial<PaginationOptions>): Pagination<ReturnType>;
|
|
27
|
+
}
|
|
28
|
+
/** Query builder base class. */
|
|
29
|
+
export declare abstract class BaseQueryBuilder<MyDocType extends DocumentData> {
|
|
30
|
+
/**
|
|
31
|
+
* Adds a condition to the query.
|
|
32
|
+
* @param fieldName The name of the field to query.
|
|
33
|
+
* @param operator The operator to use.
|
|
34
|
+
* @param value The value to compare against.
|
|
35
|
+
* @returns The query builder.
|
|
36
|
+
*/
|
|
37
|
+
abstract where(fieldName: (keyof MyDocType & FieldName) | string, operator: Operator | 'in' | 'not in', value: PrimitiveFieldType | Array<PrimitiveFieldType>): this;
|
|
38
|
+
/**
|
|
39
|
+
* A shortcut for where(fieldName, '==', value)
|
|
40
|
+
*
|
|
41
|
+
* @param fieldName The name of the field to query.
|
|
42
|
+
* @param value The value to compare against.
|
|
43
|
+
* @returns The query builder.
|
|
44
|
+
*/
|
|
45
|
+
eq(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
|
|
46
|
+
/**
|
|
47
|
+
* A shortcut for where(fieldName, '!=', value)
|
|
48
|
+
* @param fieldName The name of the field to query.
|
|
49
|
+
* @param value The value to compare against.
|
|
50
|
+
* @returns The query builder.
|
|
51
|
+
*/
|
|
52
|
+
neq(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
|
|
53
|
+
/**
|
|
54
|
+
* A shortcut for where(fieldName, 'in', value)
|
|
55
|
+
* @param fieldName The name of the field to query.
|
|
56
|
+
* @param value An array of values to compare against.
|
|
57
|
+
* @returns The query builder.
|
|
58
|
+
*/
|
|
59
|
+
in(fieldName: (keyof MyDocType & FieldName) | string, value: Array<PrimitiveFieldType>): this;
|
|
60
|
+
/**
|
|
61
|
+
* A shortcut for where(fieldName, 'not in', value)
|
|
62
|
+
* @param fieldName The name of the field to query.
|
|
63
|
+
* @param value An array of values to compare against.
|
|
64
|
+
* @returns The query builder.
|
|
65
|
+
*/
|
|
66
|
+
nin(fieldName: (keyof MyDocType & FieldName) | string, value: Array<PrimitiveFieldType>): this;
|
|
67
|
+
/**
|
|
68
|
+
* A shortcut for where(fieldName, '>', value)
|
|
69
|
+
* @param fieldName The name of the field to query.
|
|
70
|
+
* @param value The value to compare against.
|
|
71
|
+
* @returns The query builder.
|
|
72
|
+
*/
|
|
73
|
+
gt(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
|
|
74
|
+
/**
|
|
75
|
+
* A shortcut for where(fieldName, '>=', value)
|
|
76
|
+
* @param fieldName The name of the field to query.
|
|
77
|
+
* @param value The value to compare against.
|
|
78
|
+
* @returns The query builder.
|
|
79
|
+
*/
|
|
80
|
+
gte(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
|
|
81
|
+
/**
|
|
82
|
+
* A shortcut for where(fieldName, '<', value)
|
|
83
|
+
* @param fieldName The name of the field to query.
|
|
84
|
+
* @param value The value to compare against.
|
|
85
|
+
* @returns The query builder.
|
|
86
|
+
*/
|
|
87
|
+
lt(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
|
|
88
|
+
/**
|
|
89
|
+
* A shortcut for where(fieldName, '<=', value)
|
|
90
|
+
* @param fieldName The name of the field to query.
|
|
91
|
+
* @param value The value to compare against.
|
|
92
|
+
* @returns The query builder.
|
|
93
|
+
*/
|
|
94
|
+
lte(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
|
|
95
|
+
/**
|
|
96
|
+
* A shortcut for where(fieldName, '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
|
+
like(fieldName: (keyof MyDocType & FieldName) | string, pattern: string, caseSensitive?: boolean): this;
|
|
104
|
+
/**
|
|
105
|
+
* A shortcut for where(fieldName, 'not like', pattern).
|
|
106
|
+
*
|
|
107
|
+
* @param fieldName The name of the field to query.
|
|
108
|
+
* @param pattern The pattern to compare against. '%' is the only allowed wildcard
|
|
109
|
+
* @param caseSensitive Whether to use case-sensitive comparison. Defaults to true.
|
|
110
|
+
* @returns The query builder.
|
|
111
|
+
*/
|
|
112
|
+
notLike(fieldName: (keyof MyDocType & FieldName) | string, pattern: string, caseSensitive?: boolean): this;
|
|
113
|
+
/**
|
|
114
|
+
* Sets a limit to the number of results returned by the query. The maximum limit is 20,000 and the default is 1,000
|
|
115
|
+
* if none is provided.
|
|
116
|
+
* @param limit The limit to set.
|
|
117
|
+
* @returns The query builder.
|
|
118
|
+
*/
|
|
119
|
+
abstract limit(limit: number): this;
|
|
120
|
+
/**
|
|
121
|
+
* Adds a sort order to the query. You can add multiple sort orders to the query. The order in which you add them
|
|
122
|
+
* determines the order in which they are applied.
|
|
123
|
+
* @param fieldName The name of the field to sort by.
|
|
124
|
+
* @param asc Whether to sort in ascending order. Defaults to true.
|
|
125
|
+
* @returns The query builder.
|
|
126
|
+
*/
|
|
127
|
+
abstract sortBy(fieldName: keyof MyDocType & FieldName, asc?: boolean): this;
|
|
128
|
+
}
|
|
129
|
+
export interface HasDereference {
|
|
130
|
+
/**
|
|
131
|
+
* Dereferences the document references in the result of this query. For example, collection.query().snapshot()
|
|
132
|
+
* returns an array of DocumentReference objects, but collection.query().dereference().snapshot() returns an array of
|
|
133
|
+
* the actual document data.
|
|
134
|
+
*/
|
|
135
|
+
dereference(): any;
|
|
136
|
+
}
|
|
137
|
+
/** The state of a pagination. */
|
|
138
|
+
export interface PaginationState<ReturnType> {
|
|
139
|
+
data: Array<ReturnType>;
|
|
140
|
+
hasNext: boolean;
|
|
141
|
+
hasPrev: boolean;
|
|
142
|
+
isLoading: boolean;
|
|
143
|
+
}
|
|
144
|
+
/** Pagination options */
|
|
145
|
+
export interface PaginationOptions {
|
|
146
|
+
/** Whether to show real-time updates. Defaults to true. */
|
|
147
|
+
subscribe: boolean;
|
|
148
|
+
/** The number of items in a page. Defaults to 100. */
|
|
149
|
+
pageSize: number;
|
|
150
|
+
}
|
|
151
|
+
/** A query wrapper that provides pagination functionality. */
|
|
152
|
+
export declare class Pagination<ReturnType> {
|
|
153
|
+
private readonly templateSnapshotEmitter;
|
|
154
|
+
/**
|
|
155
|
+
* The first page data - only available when subscribe is true.
|
|
156
|
+
* It is used for:
|
|
157
|
+
* 1 - Telling whether there is a previous page
|
|
158
|
+
* 2 - Used as the data when the current page has less than page size and hasNext = true
|
|
159
|
+
*/
|
|
160
|
+
private readonly firstPageSnapshotEmitterWrapper;
|
|
161
|
+
private readonly firstPageDataAvailable;
|
|
162
|
+
/**
|
|
163
|
+
* The last page data - only available when subscribe is true. Lazily initialized when calling prev.
|
|
164
|
+
* It is used for telling whether there is a next result after calling prev.
|
|
165
|
+
*/
|
|
166
|
+
private lastPageSnapshotEmitterWrapper;
|
|
167
|
+
private lastPageDataAvailable;
|
|
168
|
+
private readonly isDestroyed;
|
|
169
|
+
private readonly destroyedObs;
|
|
170
|
+
private readonly _observeState;
|
|
171
|
+
/** The current snapshot emitter wrapper. */
|
|
172
|
+
private readonly currentPageSnapshotEmitterWrapperSubject;
|
|
173
|
+
private readonly options;
|
|
174
|
+
/** Requests the next page. */
|
|
175
|
+
next(): Promise<PaginationState<ReturnType>>;
|
|
176
|
+
/** Requests the previous page. */
|
|
177
|
+
prev(): Promise<PaginationState<ReturnType>>;
|
|
178
|
+
/** Unsubscribe from the pagination object and from the query. */
|
|
179
|
+
unsubscribe(): void;
|
|
180
|
+
/** The current pagination state and data. */
|
|
181
|
+
observeState(): Observable<PaginationState<ReturnType>>;
|
|
182
|
+
/** Wait for the data to be available (the isLoading flag to be false). */
|
|
183
|
+
waitForData(): Promise<PaginationState<ReturnType>>;
|
|
184
|
+
private createLastPageSnapshotEmitterWrapper;
|
|
185
|
+
private resetToFirstPageData;
|
|
186
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './query-context';
|
|
2
|
-
export * from './base-query-builder';
|
|
1
|
+
export * from './query-context';
|
|
2
|
+
export * from './base-query-builder';
|
|
@@ -1,109 +1,137 @@
|
|
|
1
|
-
import { IntegrationId } from '../communication.types';
|
|
2
|
-
import { CollectionName, DocumentData
|
|
3
|
-
import {
|
|
4
|
-
import { PartialBy, Paths } from '../types';
|
|
5
|
-
export declare class QueryContext<T = any> {
|
|
6
|
-
readonly query: Query<T>;
|
|
7
|
-
private readonly parsedConditions;
|
|
8
|
-
/**
|
|
9
|
-
* The ID of the integration being queried.
|
|
10
|
-
*/
|
|
11
|
-
get integrationId(): IntegrationId;
|
|
12
|
-
/**
|
|
13
|
-
* The name of the collection being queried.
|
|
14
|
-
*/
|
|
15
|
-
get collectionName(): CollectionName;
|
|
16
|
-
/**
|
|
17
|
-
* The query limit if one exists, -1 otherwise.
|
|
18
|
-
*/
|
|
19
|
-
get limit(): number;
|
|
20
|
-
/**
|
|
21
|
-
* Verifies that the query's sort order aligns with the provided field sorts. The fields specified in the `sorts`
|
|
22
|
-
* parameter must appear in the exact order at the beginning of the query's sort sequence. The query can include
|
|
23
|
-
* additional fields in its sort order, but only after the specified sorts.
|
|
24
|
-
*
|
|
25
|
-
* @param sorts An array of field sorts.
|
|
26
|
-
* @returns Whether the query's sorts matches the provided field sorts.
|
|
27
|
-
*/
|
|
28
|
-
sortedBy(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Verifies that the query's sort order exactly matches the provided field sorts. The fields specified in the
|
|
31
|
-
* `sorts` parameter must appear in the exact order in the query's sort sequence. No additional sorts may be present
|
|
32
|
-
* in the query.
|
|
33
|
-
*
|
|
34
|
-
* @param sorts An array of field sorts.
|
|
35
|
-
* @returns Whether the query's sorts exactly match the provided field sorts.
|
|
36
|
-
*/
|
|
37
|
-
sortedByExact(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
|
|
40
|
-
* to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
|
|
41
|
-
* additional conditions, as these only narrow the result set.
|
|
42
|
-
*
|
|
43
|
-
* @param fieldName The name of the field for the condition.
|
|
44
|
-
* @param operator The operator of the condition.
|
|
45
|
-
* @param value The value of the condition.
|
|
46
|
-
* @returns Whether the query is a subquery of the parent condition.
|
|
47
|
-
*/
|
|
48
|
-
isSubqueryOf<F extends
|
|
49
|
-
/**
|
|
50
|
-
* Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
|
|
51
|
-
* to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
|
|
52
|
-
* additional conditions, as these only narrow the result set.
|
|
53
|
-
*
|
|
54
|
-
* @param condition The condition to validate.
|
|
55
|
-
* @returns Whether the query is a subquery of the parent condition.
|
|
56
|
-
*/
|
|
57
|
-
isSubqueryOfCondition(condition: GeneralCondition<T>): boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Verifies that the query is a subquery of the specified conditions. A subquery is defined as a query that evaluates
|
|
60
|
-
* to a subset of the results that would be obtained by applying the parent conditions. The subquery may also include
|
|
61
|
-
* additional conditions, as these only narrow the result set.
|
|
62
|
-
*
|
|
63
|
-
* @param conditions The conditions to validate.
|
|
64
|
-
* @returns Whether the query includes subquery of the parent conditions.
|
|
65
|
-
*/
|
|
66
|
-
isSubqueryOfConditions(conditions: GeneralConditions<T>): boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Verifies that the query is a subquery of the specified query. A subquery is defined as a query that evaluates
|
|
69
|
-
* to a subset of the results that obtained for the parent query, including sorts and limits.
|
|
70
|
-
*
|
|
71
|
-
* @param query The query to validate.
|
|
72
|
-
* @returns Whether the query is a subquery of the parent query.
|
|
73
|
-
*/
|
|
74
|
-
isSubqueryOfQuery(query: Query<T>): boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Returns all conditions that apply to any of the specified field names. This method
|
|
77
|
-
* provides a convenient way to retrieve all conditions that involve a specific set of fields.
|
|
78
|
-
*
|
|
79
|
-
* @param fieldNames The field names for which to retrieve conditions.
|
|
80
|
-
* @returns An array of conditions that involve any of the specified field names.
|
|
81
|
-
*/
|
|
82
|
-
getConditionsFor<K extends
|
|
83
|
-
/**
|
|
84
|
-
* Returns all conditions that apply to the specified field name. This method provides
|
|
85
|
-
* a convenient way to retrieve all conditions that involve a specific field.
|
|
86
|
-
*
|
|
87
|
-
* @param fieldName The field name for which to retrieve conditions.
|
|
88
|
-
* @returns An array of conditions that involve the specified field name.
|
|
89
|
-
*/
|
|
90
|
-
getConditionsForField<K extends Paths<T>>(fieldName: K): ContextConditions<T>;
|
|
91
|
-
/**
|
|
92
|
-
* Returns true if the given document can be a result of the query.
|
|
93
|
-
* The method does not account for limit and sort order.
|
|
94
|
-
*/
|
|
95
|
-
documentMatchesQuery(doc: DocumentData): boolean;
|
|
96
|
-
/**
|
|
97
|
-
* Compares a condition against a given operator and value to determine if the
|
|
98
|
-
* provided condition is a subset of the operator and value. A condition is
|
|
99
|
-
* considered a subset if all values that satisfy (return true for) the
|
|
100
|
-
* condition also satisfy the operator and value.
|
|
101
|
-
*
|
|
102
|
-
* This is done using the underlying CompareTable, which provides a comparison
|
|
103
|
-
* function for each operator pair, or undefined if the comparison would
|
|
104
|
-
* always be false, regardless of the values.
|
|
105
|
-
*/
|
|
106
|
-
private evaluateSubset;
|
|
107
|
-
private evaluateIncludes;
|
|
108
|
-
private parseConditions;
|
|
109
|
-
}
|
|
1
|
+
import { IntegrationId } from '../communication.types';
|
|
2
|
+
import { CollectionName, DocumentData } from '../document.types';
|
|
3
|
+
import { FieldSort, Operator, Query, SimpleCondition } from '../query.types';
|
|
4
|
+
import { DeepRecord, FieldOf, PartialBy, Paths } from '../types';
|
|
5
|
+
export declare class QueryContext<T extends DocumentData = any> {
|
|
6
|
+
readonly query: Query<T>;
|
|
7
|
+
private readonly parsedConditions;
|
|
8
|
+
/**
|
|
9
|
+
* The ID of the integration being queried.
|
|
10
|
+
*/
|
|
11
|
+
get integrationId(): IntegrationId;
|
|
12
|
+
/**
|
|
13
|
+
* The name of the collection being queried.
|
|
14
|
+
*/
|
|
15
|
+
get collectionName(): CollectionName;
|
|
16
|
+
/**
|
|
17
|
+
* The query limit if one exists, -1 otherwise.
|
|
18
|
+
*/
|
|
19
|
+
get limit(): number;
|
|
20
|
+
/**
|
|
21
|
+
* Verifies that the query's sort order aligns with the provided field sorts. The fields specified in the `sorts`
|
|
22
|
+
* parameter must appear in the exact order at the beginning of the query's sort sequence. The query can include
|
|
23
|
+
* additional fields in its sort order, but only after the specified sorts.
|
|
24
|
+
*
|
|
25
|
+
* @param sorts An array of field sorts.
|
|
26
|
+
* @returns Whether the query's sorts matches the provided field sorts.
|
|
27
|
+
*/
|
|
28
|
+
sortedBy(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Verifies that the query's sort order exactly matches the provided field sorts. The fields specified in the
|
|
31
|
+
* `sorts` parameter must appear in the exact order in the query's sort sequence. No additional sorts may be present
|
|
32
|
+
* in the query.
|
|
33
|
+
*
|
|
34
|
+
* @param sorts An array of field sorts.
|
|
35
|
+
* @returns Whether the query's sorts exactly match the provided field sorts.
|
|
36
|
+
*/
|
|
37
|
+
sortedByExact(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
|
|
40
|
+
* to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
|
|
41
|
+
* additional conditions, as these only narrow the result set.
|
|
42
|
+
*
|
|
43
|
+
* @param fieldName The name of the field for the condition.
|
|
44
|
+
* @param operator The operator of the condition.
|
|
45
|
+
* @param value The value of the condition.
|
|
46
|
+
* @returns Whether the query is a subquery of the parent condition.
|
|
47
|
+
*/
|
|
48
|
+
isSubqueryOf<F extends Paths<T>, O extends AllOperators>(fieldName: F, operator: O, value: GenericValue<T, F, O> | null): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
|
|
51
|
+
* to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
|
|
52
|
+
* additional conditions, as these only narrow the result set.
|
|
53
|
+
*
|
|
54
|
+
* @param condition The condition to validate.
|
|
55
|
+
* @returns Whether the query is a subquery of the parent condition.
|
|
56
|
+
*/
|
|
57
|
+
isSubqueryOfCondition(condition: GeneralCondition<T>): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Verifies that the query is a subquery of the specified conditions. A subquery is defined as a query that evaluates
|
|
60
|
+
* to a subset of the results that would be obtained by applying the parent conditions. The subquery may also include
|
|
61
|
+
* additional conditions, as these only narrow the result set.
|
|
62
|
+
*
|
|
63
|
+
* @param conditions The conditions to validate.
|
|
64
|
+
* @returns Whether the query includes subquery of the parent conditions.
|
|
65
|
+
*/
|
|
66
|
+
isSubqueryOfConditions(conditions: GeneralConditions<T>): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Verifies that the query is a subquery of the specified query. A subquery is defined as a query that evaluates
|
|
69
|
+
* to a subset of the results that obtained for the parent query, including sorts and limits.
|
|
70
|
+
*
|
|
71
|
+
* @param query The query to validate.
|
|
72
|
+
* @returns Whether the query is a subquery of the parent query.
|
|
73
|
+
*/
|
|
74
|
+
isSubqueryOfQuery(query: Query<T>): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Returns all conditions that apply to any of the specified field names. This method
|
|
77
|
+
* provides a convenient way to retrieve all conditions that involve a specific set of fields.
|
|
78
|
+
*
|
|
79
|
+
* @param fieldNames The field names for which to retrieve conditions.
|
|
80
|
+
* @returns An array of conditions that involve any of the specified field names.
|
|
81
|
+
*/
|
|
82
|
+
getConditionsFor<K extends Paths<T>>(...fieldNames: Array<K>): ContextConditions<T, K>;
|
|
83
|
+
/**
|
|
84
|
+
* Returns all conditions that apply to the specified field name. This method provides
|
|
85
|
+
* a convenient way to retrieve all conditions that involve a specific field.
|
|
86
|
+
*
|
|
87
|
+
* @param fieldName The field name for which to retrieve conditions.
|
|
88
|
+
* @returns An array of conditions that involve the specified field name.
|
|
89
|
+
*/
|
|
90
|
+
getConditionsForField<K extends Paths<T>>(fieldName: K): ContextConditions<T>;
|
|
91
|
+
/**
|
|
92
|
+
* Returns true if the given document can be a result of the query.
|
|
93
|
+
* The method does not account for limit and sort order.
|
|
94
|
+
*/
|
|
95
|
+
documentMatchesQuery(doc: DocumentData): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Compares a condition against a given operator and value to determine if the
|
|
98
|
+
* provided condition is a subset of the operator and value. A condition is
|
|
99
|
+
* considered a subset if all values that satisfy (return true for) the
|
|
100
|
+
* condition also satisfy the operator and value.
|
|
101
|
+
*
|
|
102
|
+
* This is done using the underlying CompareTable, which provides a comparison
|
|
103
|
+
* function for each operator pair, or undefined if the comparison would
|
|
104
|
+
* always be false, regardless of the values.
|
|
105
|
+
*/
|
|
106
|
+
private evaluateSubset;
|
|
107
|
+
private evaluateIncludes;
|
|
108
|
+
private parseConditions;
|
|
109
|
+
}
|
|
110
|
+
/** A list of context conditions */
|
|
111
|
+
type ContextConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<ContextCondition<Doc, F>>;
|
|
112
|
+
/** A Context condition - a condition that replaces multiple '==' or '!=' conditions with 'in' and 'not in'. */
|
|
113
|
+
type ContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = InContextCondition<Doc, F> | NotInContextCondition<Doc, F> | OtherContextCondition<Doc, F>;
|
|
114
|
+
interface InContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'in'> {
|
|
115
|
+
operator: 'in';
|
|
116
|
+
value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
|
|
117
|
+
}
|
|
118
|
+
interface NotInContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'not in'> {
|
|
119
|
+
operator: 'not in';
|
|
120
|
+
value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
|
|
121
|
+
}
|
|
122
|
+
interface OtherContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, Exclude<ContextOperator, 'in' | 'not in'>> {
|
|
123
|
+
operator: Exclude<ContextOperator, 'in' | 'not in'>;
|
|
124
|
+
value: FieldOf<DeepRecord<Doc>, Paths<Doc>> | any;
|
|
125
|
+
}
|
|
126
|
+
/** A condition that includes the 'in' and 'not in' operators. */
|
|
127
|
+
interface GeneralCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, AllOperators> {
|
|
128
|
+
operator: AllOperators;
|
|
129
|
+
value: any;
|
|
130
|
+
}
|
|
131
|
+
/** A list of general conditions. */
|
|
132
|
+
type GeneralConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<GeneralCondition<Doc, F>>;
|
|
133
|
+
type ContextOperator = Exclude<Operator, '==' | '!='> | 'in' | 'not in';
|
|
134
|
+
type AllOperators = Operator | 'in' | 'not in';
|
|
135
|
+
/** A generic value that can exist in a query. */
|
|
136
|
+
type GenericValue<Doc = any, F extends Paths<Doc> = Paths<Doc>, O extends AllOperators = any> = O extends 'in' ? Array<DeepRecord<Doc>[F]> | null : O extends 'not in' ? Array<DeepRecord<Doc>[F]> | null : DeepRecord<Doc>[F] | null;
|
|
137
|
+
export {};
|