@squidcloud/client 1.0.79 → 1.0.81
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/query/{simple-query-builder.d.ts → base-query-builder.d.ts} +23 -18
- package/dist/common/src/query/index.d.ts +1 -1
- package/dist/common/src/query/query-context.d.ts +77 -10
- package/dist/esm/index.js +5 -5
- package/dist/typescript-client/src/collection-reference.d.ts +8 -7
- package/dist/typescript-client/src/collection-reference.factory.d.ts +3 -6
- package/dist/typescript-client/src/data.manager.d.ts +1 -1
- package/dist/typescript-client/src/document-reference.factory.d.ts +3 -0
- package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +62 -24
- package/dist/typescript-client/src/query/query-builder.factory.d.ts +14 -39
- package/dist/typescript-client/src/query/query.types.d.ts +2 -2
- package/dist/typescript-client/src/squid.d.ts +0 -1
- package/package.json +1 -1
|
@@ -1,8 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { DocumentData, FieldName, PrimitiveFieldType } from '../document.types';
|
|
2
|
+
import { Operator } from '../query.types';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
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
|
+
/** Query builder base class. */
|
|
23
|
+
export declare abstract class BaseQueryBuilder<MyDocType extends DocumentData> {
|
|
6
24
|
/**
|
|
7
25
|
* Adds a condition to the query.
|
|
8
26
|
* @param fieldName The name of the field to query.
|
|
@@ -102,16 +120,3 @@ export declare abstract class BaseQueryBuilderInterface<MyDocType extends Docume
|
|
|
102
120
|
*/
|
|
103
121
|
abstract sortBy(fieldName: keyof MyDocType & FieldName, asc?: boolean): this;
|
|
104
122
|
}
|
|
105
|
-
/** A query builder that can be used to build a query that returns a list of documents. */
|
|
106
|
-
export declare class SimpleQueryBuilder<MyDocType extends DocumentData> extends BaseQueryBuilderInterface<MyDocType> {
|
|
107
|
-
protected readonly collectionName: CollectionName;
|
|
108
|
-
protected readonly integrationId: IntegrationId;
|
|
109
|
-
protected readonly query: Query<MyDocType>;
|
|
110
|
-
/** @inheritDoc */
|
|
111
|
-
where(fieldName: (keyof MyDocType & FieldName) | string, operator: Operator | 'in' | 'not in', value: PrimitiveFieldType | Array<PrimitiveFieldType>): this;
|
|
112
|
-
/** @inheritDoc */
|
|
113
|
-
limit(limit: number): this;
|
|
114
|
-
/** @inheritDoc */
|
|
115
|
-
sortBy(fieldName: keyof MyDocType & FieldName, asc?: boolean): this;
|
|
116
|
-
private mergeConditions;
|
|
117
|
-
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './query-context';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './base-query-builder';
|
|
@@ -1,25 +1,92 @@
|
|
|
1
1
|
import { IntegrationId } from '../communication.types';
|
|
2
2
|
import { CollectionName, DocumentData, FieldName } from '../document.types';
|
|
3
|
-
import { AllOperators,
|
|
3
|
+
import { AllOperators, ContextConditions, FieldSort, GeneralCondition, GeneralConditions, GenericValue, Query } from '../query.types';
|
|
4
4
|
import { PartialBy, Paths } from '../types';
|
|
5
5
|
export declare class QueryContext<T = any> {
|
|
6
6
|
readonly query: Query<T>;
|
|
7
7
|
private readonly parsedConditions;
|
|
8
|
+
/**
|
|
9
|
+
* The ID of the integration being queried.
|
|
10
|
+
*/
|
|
8
11
|
get integrationId(): IntegrationId;
|
|
12
|
+
/**
|
|
13
|
+
* The name of the collection being queried.
|
|
14
|
+
*/
|
|
9
15
|
get collectionName(): CollectionName;
|
|
16
|
+
/**
|
|
17
|
+
* The query limit if one exists, -1 otherwise.
|
|
18
|
+
*/
|
|
10
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
|
+
*/
|
|
11
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
|
+
*/
|
|
12
37
|
sortedByExact(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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 FieldName<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
|
+
*/
|
|
22
82
|
getConditionsFor<K extends FieldName<T>>(...fieldNames: 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
|
+
*/
|
|
23
90
|
getConditionsForField<K extends Paths<T>>(fieldName: K): ContextConditions<T>;
|
|
24
91
|
/**
|
|
25
92
|
* Returns true if the given document can be a result of the query.
|