@squidcloud/local-backend 1.0.148 → 1.0.151
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/common/src/ai-assistant.types.d.ts +50 -50
- package/dist/common/src/ai-assistant.types.js +2 -2
- package/dist/common/src/ai-chatbot.context.d.ts +13 -13
- package/dist/common/src/ai-chatbot.context.js +19 -19
- package/dist/common/src/ai-chatbot.schemas.d.ts +18 -18
- package/dist/common/src/ai-chatbot.schemas.js +21 -21
- package/dist/common/src/ai-chatbot.types.d.ts +125 -123
- package/dist/common/src/ai-chatbot.types.js +18 -18
- package/dist/common/src/api-call.context.d.ts +13 -13
- package/dist/common/src/api-call.context.js +16 -16
- package/dist/common/src/api.types.d.ts +22 -22
- package/dist/common/src/api.types.js +2 -2
- package/dist/common/src/application.schemas.d.ts +1648 -1648
- package/dist/common/src/application.schemas.js +948 -948
- package/dist/common/src/application.types.d.ts +193 -193
- package/dist/common/src/application.types.js +89 -89
- package/dist/common/src/application.types.js.map +1 -1
- package/dist/common/src/backend-function.schemas.d.ts +3 -3
- package/dist/common/src/backend-function.schemas.js +11 -11
- package/dist/common/src/backend-function.types.d.ts +4 -4
- package/dist/common/src/backend-function.types.js +2 -2
- package/dist/common/src/backend-run.types.d.ts +54 -54
- package/dist/common/src/backend-run.types.js +92 -95
- package/dist/common/src/backend-run.types.js.map +1 -1
- package/dist/common/src/bundle-api.types.d.ts +65 -69
- package/dist/common/src/bundle-api.types.js +2 -2
- package/dist/common/src/bundle-data.types.d.ts +69 -74
- package/dist/common/src/bundle-data.types.js +2 -2
- package/dist/common/src/communication.types.d.ts +20 -19
- package/dist/common/src/communication.types.js +41 -40
- package/dist/common/src/communication.types.js.map +1 -1
- package/dist/common/src/context.types.d.ts +24 -24
- package/dist/common/src/context.types.js +2 -2
- package/dist/common/src/distributed-lock.context.d.ts +4 -4
- package/dist/common/src/distributed-lock.context.js +9 -9
- package/dist/common/src/document.types.d.ts +32 -32
- package/dist/common/src/document.types.js +50 -50
- package/dist/common/src/graphql.context.d.ts +14 -14
- package/dist/common/src/graphql.context.js +12 -12
- package/dist/common/src/graphql.types.d.ts +11 -11
- package/dist/common/src/graphql.types.js +34 -34
- package/dist/common/src/heartbeat.types.d.ts +4 -4
- package/dist/common/src/heartbeat.types.js +16 -16
- package/dist/common/src/http-status.enum.d.ts +50 -50
- package/dist/common/src/http-status.enum.js +54 -54
- package/dist/common/src/http-status.enum.js.map +1 -1
- package/dist/common/src/index.d.ts +54 -57
- package/dist/common/src/index.js +70 -73
- package/dist/common/src/index.js.map +1 -1
- package/dist/common/src/integrations/ai_chatbot.types.d.ts +31 -31
- package/dist/common/src/integrations/ai_chatbot.types.js +2 -2
- package/dist/common/src/integrations/api.types.d.ts +80 -80
- package/dist/common/src/integrations/api.types.js +2 -2
- package/dist/common/src/integrations/auth.types.d.ts +39 -39
- package/dist/common/src/integrations/auth.types.js +2 -2
- package/dist/common/src/integrations/database.types.d.ts +274 -274
- package/dist/common/src/integrations/database.types.js +2 -2
- package/dist/common/src/integrations/index.d.ts +134 -134
- package/dist/common/src/integrations/index.js +119 -119
- package/dist/common/src/integrations/index.js.map +1 -1
- package/dist/common/src/integrations/observability.types.d.ts +23 -23
- package/dist/common/src/integrations/observability.types.js +23 -23
- package/dist/common/src/logger.types.d.ts +21 -21
- package/dist/common/src/logger.types.js +11 -11
- package/dist/common/src/logger.types.js.map +1 -1
- package/dist/common/src/metrics.types.d.ts +73 -73
- package/dist/common/src/metrics.types.js +11 -11
- package/dist/common/src/mutation.context.d.ts +13 -13
- package/dist/common/src/mutation.context.js +26 -26
- package/dist/common/src/mutation.schemas.d.ts +5 -5
- package/dist/common/src/mutation.schemas.js +114 -114
- package/dist/common/src/mutation.types.d.ts +63 -63
- package/dist/common/src/mutation.types.js +142 -142
- package/dist/common/src/native-query.context.d.ts +7 -7
- package/dist/common/src/native-query.context.js +11 -11
- package/dist/common/src/native-query.types.d.ts +16 -16
- package/dist/common/src/native-query.types.js +2 -2
- package/dist/common/src/query/base-query-builder.d.ts +38 -38
- package/dist/common/src/query/base-query-builder.js +39 -39
- package/dist/common/src/query/index.d.ts +4 -4
- package/dist/common/src/query/index.js +20 -20
- package/dist/common/src/query/pagination.d.ts +46 -46
- package/dist/common/src/query/pagination.js +211 -211
- package/dist/common/src/query/query-context.d.ts +47 -47
- package/dist/common/src/query/query-context.js +159 -159
- package/dist/common/src/query/serialized-query.types.d.ts +24 -24
- package/dist/common/src/query/serialized-query.types.js +2 -2
- package/dist/common/src/query.types.d.ts +86 -86
- package/dist/common/src/query.types.js +97 -97
- package/dist/common/src/regions.d.ts +21 -21
- package/dist/common/src/regions.js +46 -46
- package/dist/common/src/schema/schema.types.d.ts +30 -30
- package/dist/common/src/schema/schema.types.js +173 -173
- package/dist/common/src/secret.schemas.d.ts +4 -4
- package/dist/common/src/secret.schemas.js +17 -17
- package/dist/common/src/secret.types.d.ts +68 -68
- package/dist/common/src/secret.types.js +5 -5
- package/dist/common/src/security.types.d.ts +3 -3
- package/dist/common/src/security.types.js +2 -2
- package/dist/common/src/socket.schemas.d.ts +3 -3
- package/dist/common/src/socket.schemas.js +57 -57
- package/dist/common/src/socket.types.d.ts +126 -126
- package/dist/common/src/socket.types.js +9 -9
- package/dist/common/src/socket.types.js.map +1 -1
- package/dist/common/src/time-units.d.ts +11 -11
- package/dist/common/src/time-units.js +14 -14
- package/dist/common/src/trigger.types.d.ts +15 -15
- package/dist/common/src/trigger.types.js +2 -2
- package/dist/common/src/types.d.ts +21 -21
- package/dist/common/src/types.js +2 -2
- package/dist/common/src/utils/array.d.ts +8 -8
- package/dist/common/src/utils/array.js +54 -54
- package/dist/common/src/utils/assert.d.ts +3 -3
- package/dist/common/src/utils/assert.js +14 -14
- package/dist/common/src/utils/error.d.ts +4 -4
- package/dist/common/src/utils/error.js +10 -10
- package/dist/common/src/utils/global.utils.d.ts +11 -11
- package/dist/common/src/utils/global.utils.js +50 -50
- package/dist/common/src/utils/http.d.ts +2 -2
- package/dist/common/src/utils/http.js +51 -51
- package/dist/common/src/utils/id.d.ts +2 -2
- package/dist/common/src/utils/id.js +21 -21
- package/dist/common/src/utils/lock.manager.d.ts +9 -9
- package/dist/common/src/utils/lock.manager.js +39 -39
- package/dist/common/src/utils/object.d.ts +5 -5
- package/dist/common/src/utils/object.js +75 -75
- package/dist/common/src/utils/serialization.d.ts +5 -5
- package/dist/common/src/utils/serialization.js +73 -73
- package/dist/common/src/utils/transforms.d.ts +18 -18
- package/dist/common/src/utils/transforms.js +104 -104
- package/dist/common/src/utils/url.d.ts +1 -1
- package/dist/common/src/utils/url.js +15 -15
- package/dist/common/src/utils/validation.d.ts +17 -17
- package/dist/common/src/utils/validation.js +199 -199
- package/dist/common/src/webhook-response.d.ts +6 -6
- package/dist/common/src/webhook-response.js +2 -2
- package/dist/common/src/websocket.impl.d.ts +21 -21
- package/dist/common/src/websocket.impl.js +79 -79
- package/dist/internal-common/src/code-executor.types.d.ts +13 -13
- package/dist/internal-common/src/code-executor.types.js +2 -2
- package/dist/internal-common/src/local-dev.types.d.ts +35 -35
- package/dist/internal-common/src/local-dev.types.js +2 -2
- package/dist/local-backend/package.json +48 -48
- package/dist/local-backend/src/index.d.ts +4 -4
- package/dist/local-backend/src/index.js +26 -26
- package/dist/local-backend/src/local-backend-socket.service.d.ts +18 -18
- package/dist/local-backend/src/local-backend-socket.service.js +107 -108
- package/dist/local-backend/src/local-backend-socket.service.js.map +1 -1
- package/dist/local-backend/src/local-backend.app.d.ts +2 -2
- package/dist/local-backend/src/local-backend.app.js +19 -19
- package/dist/local-backend/src/local-backend.controller.d.ts +8 -8
- package/dist/local-backend/src/local-backend.controller.js +48 -49
- package/dist/local-backend/src/local-backend.controller.js.map +1 -1
- package/dist/local-backend/src/local-backend.module.d.ts +8 -8
- package/dist/local-backend/src/local-backend.module.js +51 -53
- package/dist/local-backend/src/local-backend.module.js.map +1 -1
- package/dist/local-backend/src/local-backend.service.d.ts +15 -15
- package/dist/local-backend/src/local-backend.service.js +173 -176
- package/dist/local-backend/src/local-backend.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/common/src/named-query.context.d.ts +0 -4
- package/dist/common/src/named-query.context.js +0 -10
- package/dist/common/src/named-query.context.js.map +0 -1
- package/dist/common/src/named-query.schemas.d.ts +0 -3
- package/dist/common/src/named-query.schemas.js +0 -14
- package/dist/common/src/named-query.schemas.js.map +0 -1
- package/dist/common/src/named-query.types.d.ts +0 -8
- package/dist/common/src/named-query.types.js +0 -3
- package/dist/common/src/named-query.types.js.map +0 -1
- package/dist/internal-common/src/utils/logger-utils.d.ts +0 -3
- package/dist/internal-common/src/utils/logger-utils.js +0 -29
- package/dist/internal-common/src/utils/logger-utils.js.map +0 -1
|
@@ -1,47 +1,47 @@
|
|
|
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
|
-
constructor(query: Query<T>);
|
|
9
|
-
get integrationId(): IntegrationId;
|
|
10
|
-
get collectionName(): CollectionName;
|
|
11
|
-
get limit(): number;
|
|
12
|
-
sortedBy(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
|
|
13
|
-
sortedByExact(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
|
|
14
|
-
isSubqueryOf<F extends Paths<T>, O extends AllOperators>(fieldName: F, operator: O, value: GenericValue<T, F, O> | null): boolean;
|
|
15
|
-
isSubqueryOfCondition(condition: GeneralCondition<T>): boolean;
|
|
16
|
-
isSubqueryOfConditions(conditions: GeneralConditions<T>): boolean;
|
|
17
|
-
isSubqueryOfQuery(query: Query<T>): boolean;
|
|
18
|
-
getConditionsFor<K extends Paths<T>>(...fieldNames: Array<K>): ContextConditions<T, K>;
|
|
19
|
-
getConditionsForField<K extends Paths<T>>(fieldName: K): ContextConditions<T>;
|
|
20
|
-
documentMatchesQuery(doc: DocumentData): boolean;
|
|
21
|
-
private evaluateSubset;
|
|
22
|
-
private evaluateIncludes;
|
|
23
|
-
private parseConditions;
|
|
24
|
-
}
|
|
25
|
-
export type ContextConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<ContextCondition<Doc, F>>;
|
|
26
|
-
type ContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = InContextCondition<Doc, F> | NotInContextCondition<Doc, F> | OtherContextCondition<Doc, F>;
|
|
27
|
-
interface InContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'in'> {
|
|
28
|
-
operator: 'in';
|
|
29
|
-
value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
|
|
30
|
-
}
|
|
31
|
-
interface NotInContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'not in'> {
|
|
32
|
-
operator: 'not in';
|
|
33
|
-
value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
|
|
34
|
-
}
|
|
35
|
-
interface OtherContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, Exclude<ContextOperator, 'in' | 'not in'>> {
|
|
36
|
-
operator: Exclude<ContextOperator, 'in' | 'not in'>;
|
|
37
|
-
value: FieldOf<DeepRecord<Doc>, Paths<Doc>> | any;
|
|
38
|
-
}
|
|
39
|
-
interface GeneralCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, AllOperators> {
|
|
40
|
-
operator: AllOperators;
|
|
41
|
-
value: any;
|
|
42
|
-
}
|
|
43
|
-
type GeneralConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<GeneralCondition<Doc, F>>;
|
|
44
|
-
type ContextOperator = Exclude<Operator, '==' | '!='> | 'in' | 'not in';
|
|
45
|
-
type AllOperators = Operator | 'in' | 'not in';
|
|
46
|
-
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;
|
|
47
|
-
export {};
|
|
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
|
+
constructor(query: Query<T>);
|
|
9
|
+
get integrationId(): IntegrationId;
|
|
10
|
+
get collectionName(): CollectionName;
|
|
11
|
+
get limit(): number;
|
|
12
|
+
sortedBy(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
|
|
13
|
+
sortedByExact(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
|
|
14
|
+
isSubqueryOf<F extends Paths<T>, O extends AllOperators>(fieldName: F, operator: O, value: GenericValue<T, F, O> | null): boolean;
|
|
15
|
+
isSubqueryOfCondition(condition: GeneralCondition<T>): boolean;
|
|
16
|
+
isSubqueryOfConditions(conditions: GeneralConditions<T>): boolean;
|
|
17
|
+
isSubqueryOfQuery(query: Query<T>): boolean;
|
|
18
|
+
getConditionsFor<K extends Paths<T>>(...fieldNames: Array<K>): ContextConditions<T, K>;
|
|
19
|
+
getConditionsForField<K extends Paths<T>>(fieldName: K): ContextConditions<T>;
|
|
20
|
+
documentMatchesQuery(doc: DocumentData): boolean;
|
|
21
|
+
private evaluateSubset;
|
|
22
|
+
private evaluateIncludes;
|
|
23
|
+
private parseConditions;
|
|
24
|
+
}
|
|
25
|
+
export type ContextConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<ContextCondition<Doc, F>>;
|
|
26
|
+
type ContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = InContextCondition<Doc, F> | NotInContextCondition<Doc, F> | OtherContextCondition<Doc, F>;
|
|
27
|
+
interface InContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'in'> {
|
|
28
|
+
operator: 'in';
|
|
29
|
+
value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
|
|
30
|
+
}
|
|
31
|
+
interface NotInContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'not in'> {
|
|
32
|
+
operator: 'not in';
|
|
33
|
+
value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
|
|
34
|
+
}
|
|
35
|
+
interface OtherContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, Exclude<ContextOperator, 'in' | 'not in'>> {
|
|
36
|
+
operator: Exclude<ContextOperator, 'in' | 'not in'>;
|
|
37
|
+
value: FieldOf<DeepRecord<Doc>, Paths<Doc>> | any;
|
|
38
|
+
}
|
|
39
|
+
interface GeneralCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, AllOperators> {
|
|
40
|
+
operator: AllOperators;
|
|
41
|
+
value: any;
|
|
42
|
+
}
|
|
43
|
+
type GeneralConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<GeneralCondition<Doc, F>>;
|
|
44
|
+
type ContextOperator = Exclude<Operator, '==' | '!='> | 'in' | 'not in';
|
|
45
|
+
type AllOperators = Operator | 'in' | 'not in';
|
|
46
|
+
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;
|
|
47
|
+
export {};
|
|
@@ -1,160 +1,160 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QueryContext = void 0;
|
|
4
|
-
const _ = require("lodash");
|
|
5
|
-
const lodash_1 = require("lodash");
|
|
6
|
-
const query_types_1 = require("../query.types");
|
|
7
|
-
const CompareTable = {
|
|
8
|
-
'in:in': (a, b) => a.every((c) => b.includes(c)),
|
|
9
|
-
'in:not in': (a, b) => a.every((c) => !b.includes(c)),
|
|
10
|
-
'not in:not in': (a, b) => b.every((c) => a.includes(c)),
|
|
11
|
-
'>:not in': (a, b) => b.every((c) => a >= c),
|
|
12
|
-
'>=:not in': (a, b) => b.every((c) => a > c),
|
|
13
|
-
'<:not in': (a, b) => b.every((c) => a <= c),
|
|
14
|
-
'<=:not in': (a, b) => b.every((c) => a < c),
|
|
15
|
-
'>:>': (a, b) => a >= b,
|
|
16
|
-
'>=:>': (a, b) => a > b,
|
|
17
|
-
'in:>': (a, b) => a.every((c) => c > b),
|
|
18
|
-
'>:>=': (a, b) => a >= b,
|
|
19
|
-
'>=:>=': (a, b) => a >= b,
|
|
20
|
-
'in:>=': (a, b) => a.every((c) => c >= b),
|
|
21
|
-
'<:<': (a, b) => a <= b,
|
|
22
|
-
'<=:<': (a, b) => a < b,
|
|
23
|
-
'in:<': (a, b) => a.every((c) => c < b),
|
|
24
|
-
'<:<=': (a, b) => a <= b,
|
|
25
|
-
'<=:<=': (a, b) => a <= b,
|
|
26
|
-
'in:<=': (a, b) => a.every((c) => c <= b),
|
|
27
|
-
};
|
|
28
|
-
class QueryContext {
|
|
29
|
-
constructor(query) {
|
|
30
|
-
this.query = query;
|
|
31
|
-
this.query = query;
|
|
32
|
-
this.parsedConditions = this.parseConditions(this.query.conditions.filter(query_types_1.isSimpleCondition));
|
|
33
|
-
}
|
|
34
|
-
get integrationId() {
|
|
35
|
-
return this.query.integrationId;
|
|
36
|
-
}
|
|
37
|
-
get collectionName() {
|
|
38
|
-
return this.query.collectionName;
|
|
39
|
-
}
|
|
40
|
-
get limit() {
|
|
41
|
-
return this.query.limit;
|
|
42
|
-
}
|
|
43
|
-
sortedBy(sorts) {
|
|
44
|
-
const mismatch = sorts.find((fieldSort, index) => {
|
|
45
|
-
var _a;
|
|
46
|
-
return !(0, lodash_1.isEqual)(this.query.sortOrder[index], Object.assign(Object.assign({}, fieldSort), { asc: (_a = fieldSort.asc) !== null && _a !== void 0 ? _a : true }));
|
|
47
|
-
});
|
|
48
|
-
return !mismatch;
|
|
49
|
-
}
|
|
50
|
-
sortedByExact(sorts) {
|
|
51
|
-
if (sorts.length !== this.query.sortOrder.length)
|
|
52
|
-
return false;
|
|
53
|
-
return this.sortedBy(sorts);
|
|
54
|
-
}
|
|
55
|
-
isSubqueryOf(fieldName, operator, value) {
|
|
56
|
-
return this.isSubqueryOfCondition({
|
|
57
|
-
fieldName,
|
|
58
|
-
operator,
|
|
59
|
-
value,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
isSubqueryOfCondition(condition) {
|
|
63
|
-
const conditions = this.parsedConditions.filter(c => c.fieldName === condition.fieldName);
|
|
64
|
-
return !!conditions.find(c => this.evaluateSubset(c, condition));
|
|
65
|
-
}
|
|
66
|
-
isSubqueryOfConditions(conditions) {
|
|
67
|
-
const parsedConditions = this.parseConditions(conditions);
|
|
68
|
-
return parsedConditions.every(c => this.isSubqueryOfCondition(c));
|
|
69
|
-
}
|
|
70
|
-
isSubqueryOfQuery(query) {
|
|
71
|
-
if (query.collectionName !== this.collectionName || query.integrationId !== this.integrationId)
|
|
72
|
-
return false;
|
|
73
|
-
const simpleConditions = query.conditions.filter(query_types_1.isSimpleCondition);
|
|
74
|
-
const subsetOfConditions = this.isSubqueryOfConditions(simpleConditions);
|
|
75
|
-
const subsetOfOrder = this.sortedBy(query.sortOrder);
|
|
76
|
-
const withinLimit = query.limit === -1 || (this.limit > -1 && this.limit < query.limit);
|
|
77
|
-
return subsetOfConditions && subsetOfOrder && withinLimit;
|
|
78
|
-
}
|
|
79
|
-
getConditionsFor(...fieldNames) {
|
|
80
|
-
return this.parsedConditions.filter(cond => fieldNames.includes(cond.fieldName));
|
|
81
|
-
}
|
|
82
|
-
getConditionsForField(fieldName) {
|
|
83
|
-
return this.parsedConditions.filter(cond => cond.fieldName === fieldName);
|
|
84
|
-
}
|
|
85
|
-
documentMatchesQuery(doc) {
|
|
86
|
-
for (const contextCondition of this.parsedConditions) {
|
|
87
|
-
const fieldNameOrPath = contextCondition.fieldName;
|
|
88
|
-
const operator = contextCondition.operator;
|
|
89
|
-
const valueInDoc = _.get(doc, fieldNameOrPath);
|
|
90
|
-
if (operator === 'in') {
|
|
91
|
-
if (contextCondition.value.includes(valueInDoc)) {
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
else if (operator === 'not in') {
|
|
97
|
-
if (contextCondition.value.includes(valueInDoc)) {
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
if (!(0, query_types_1.compareOperator)(contextCondition.value, valueInDoc, operator)) {
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
evaluateSubset(queryCondition, testCondition) {
|
|
109
|
-
const { operator: queryOperator, value: queryValue } = queryCondition;
|
|
110
|
-
const { operator, value } = this.parseConditions([testCondition])[0];
|
|
111
|
-
const compareFunction = CompareTable[`${queryOperator}:${operator}`];
|
|
112
|
-
if (!compareFunction)
|
|
113
|
-
return false;
|
|
114
|
-
return compareFunction(queryValue, value);
|
|
115
|
-
}
|
|
116
|
-
evaluateIncludes(queryCondition, testCondition) {
|
|
117
|
-
const { operator: queryOperator, value: queryValue } = queryCondition;
|
|
118
|
-
const { operator, value } = this.parseConditions([testCondition])[0];
|
|
119
|
-
const sortedQueryValue = Array.isArray(queryValue) ? queryValue.sort() : queryValue;
|
|
120
|
-
const sortedValue = Array.isArray(value) ? value.sort() : value;
|
|
121
|
-
return operator === queryOperator && (0, lodash_1.isEqual)(sortedValue, sortedQueryValue);
|
|
122
|
-
}
|
|
123
|
-
parseConditions(conditions) {
|
|
124
|
-
const parsedConditions = [];
|
|
125
|
-
const inMap = new Map();
|
|
126
|
-
const notInMap = new Map();
|
|
127
|
-
conditions.forEach(c => {
|
|
128
|
-
switch (c.operator) {
|
|
129
|
-
case '==':
|
|
130
|
-
case 'in':
|
|
131
|
-
inMap.set(c.fieldName, (inMap.get(c.fieldName) || []).concat(c.value));
|
|
132
|
-
break;
|
|
133
|
-
case '!=':
|
|
134
|
-
case 'not in':
|
|
135
|
-
notInMap.set(c.fieldName, (notInMap.get(c.fieldName) || []).concat(c.value));
|
|
136
|
-
break;
|
|
137
|
-
default:
|
|
138
|
-
parsedConditions.push(c);
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
inMap.forEach((value, fieldName) => {
|
|
143
|
-
parsedConditions.push({
|
|
144
|
-
fieldName: fieldName,
|
|
145
|
-
operator: 'in',
|
|
146
|
-
value: value,
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
notInMap.forEach((value, fieldName) => {
|
|
150
|
-
parsedConditions.push({
|
|
151
|
-
fieldName: fieldName,
|
|
152
|
-
operator: 'not in',
|
|
153
|
-
value: value,
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
return parsedConditions;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
exports.QueryContext = QueryContext;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryContext = void 0;
|
|
4
|
+
const _ = require("lodash");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const query_types_1 = require("../query.types");
|
|
7
|
+
const CompareTable = {
|
|
8
|
+
'in:in': (a, b) => a.every((c) => b.includes(c)),
|
|
9
|
+
'in:not in': (a, b) => a.every((c) => !b.includes(c)),
|
|
10
|
+
'not in:not in': (a, b) => b.every((c) => a.includes(c)),
|
|
11
|
+
'>:not in': (a, b) => b.every((c) => a >= c),
|
|
12
|
+
'>=:not in': (a, b) => b.every((c) => a > c),
|
|
13
|
+
'<:not in': (a, b) => b.every((c) => a <= c),
|
|
14
|
+
'<=:not in': (a, b) => b.every((c) => a < c),
|
|
15
|
+
'>:>': (a, b) => a >= b,
|
|
16
|
+
'>=:>': (a, b) => a > b,
|
|
17
|
+
'in:>': (a, b) => a.every((c) => c > b),
|
|
18
|
+
'>:>=': (a, b) => a >= b,
|
|
19
|
+
'>=:>=': (a, b) => a >= b,
|
|
20
|
+
'in:>=': (a, b) => a.every((c) => c >= b),
|
|
21
|
+
'<:<': (a, b) => a <= b,
|
|
22
|
+
'<=:<': (a, b) => a < b,
|
|
23
|
+
'in:<': (a, b) => a.every((c) => c < b),
|
|
24
|
+
'<:<=': (a, b) => a <= b,
|
|
25
|
+
'<=:<=': (a, b) => a <= b,
|
|
26
|
+
'in:<=': (a, b) => a.every((c) => c <= b),
|
|
27
|
+
};
|
|
28
|
+
class QueryContext {
|
|
29
|
+
constructor(query) {
|
|
30
|
+
this.query = query;
|
|
31
|
+
this.query = query;
|
|
32
|
+
this.parsedConditions = this.parseConditions(this.query.conditions.filter(query_types_1.isSimpleCondition));
|
|
33
|
+
}
|
|
34
|
+
get integrationId() {
|
|
35
|
+
return this.query.integrationId;
|
|
36
|
+
}
|
|
37
|
+
get collectionName() {
|
|
38
|
+
return this.query.collectionName;
|
|
39
|
+
}
|
|
40
|
+
get limit() {
|
|
41
|
+
return this.query.limit;
|
|
42
|
+
}
|
|
43
|
+
sortedBy(sorts) {
|
|
44
|
+
const mismatch = sorts.find((fieldSort, index) => {
|
|
45
|
+
var _a;
|
|
46
|
+
return !(0, lodash_1.isEqual)(this.query.sortOrder[index], Object.assign(Object.assign({}, fieldSort), { asc: (_a = fieldSort.asc) !== null && _a !== void 0 ? _a : true }));
|
|
47
|
+
});
|
|
48
|
+
return !mismatch;
|
|
49
|
+
}
|
|
50
|
+
sortedByExact(sorts) {
|
|
51
|
+
if (sorts.length !== this.query.sortOrder.length)
|
|
52
|
+
return false;
|
|
53
|
+
return this.sortedBy(sorts);
|
|
54
|
+
}
|
|
55
|
+
isSubqueryOf(fieldName, operator, value) {
|
|
56
|
+
return this.isSubqueryOfCondition({
|
|
57
|
+
fieldName,
|
|
58
|
+
operator,
|
|
59
|
+
value,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
isSubqueryOfCondition(condition) {
|
|
63
|
+
const conditions = this.parsedConditions.filter(c => c.fieldName === condition.fieldName);
|
|
64
|
+
return !!conditions.find(c => this.evaluateSubset(c, condition));
|
|
65
|
+
}
|
|
66
|
+
isSubqueryOfConditions(conditions) {
|
|
67
|
+
const parsedConditions = this.parseConditions(conditions);
|
|
68
|
+
return parsedConditions.every(c => this.isSubqueryOfCondition(c));
|
|
69
|
+
}
|
|
70
|
+
isSubqueryOfQuery(query) {
|
|
71
|
+
if (query.collectionName !== this.collectionName || query.integrationId !== this.integrationId)
|
|
72
|
+
return false;
|
|
73
|
+
const simpleConditions = query.conditions.filter(query_types_1.isSimpleCondition);
|
|
74
|
+
const subsetOfConditions = this.isSubqueryOfConditions(simpleConditions);
|
|
75
|
+
const subsetOfOrder = this.sortedBy(query.sortOrder);
|
|
76
|
+
const withinLimit = query.limit === -1 || (this.limit > -1 && this.limit < query.limit);
|
|
77
|
+
return subsetOfConditions && subsetOfOrder && withinLimit;
|
|
78
|
+
}
|
|
79
|
+
getConditionsFor(...fieldNames) {
|
|
80
|
+
return this.parsedConditions.filter(cond => fieldNames.includes(cond.fieldName));
|
|
81
|
+
}
|
|
82
|
+
getConditionsForField(fieldName) {
|
|
83
|
+
return this.parsedConditions.filter(cond => cond.fieldName === fieldName);
|
|
84
|
+
}
|
|
85
|
+
documentMatchesQuery(doc) {
|
|
86
|
+
for (const contextCondition of this.parsedConditions) {
|
|
87
|
+
const fieldNameOrPath = contextCondition.fieldName;
|
|
88
|
+
const operator = contextCondition.operator;
|
|
89
|
+
const valueInDoc = _.get(doc, fieldNameOrPath);
|
|
90
|
+
if (operator === 'in') {
|
|
91
|
+
if (contextCondition.value.includes(valueInDoc)) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
else if (operator === 'not in') {
|
|
97
|
+
if (contextCondition.value.includes(valueInDoc)) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (!(0, query_types_1.compareOperator)(contextCondition.value, valueInDoc, operator)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
evaluateSubset(queryCondition, testCondition) {
|
|
109
|
+
const { operator: queryOperator, value: queryValue } = queryCondition;
|
|
110
|
+
const { operator, value } = this.parseConditions([testCondition])[0];
|
|
111
|
+
const compareFunction = CompareTable[`${queryOperator}:${operator}`];
|
|
112
|
+
if (!compareFunction)
|
|
113
|
+
return false;
|
|
114
|
+
return compareFunction(queryValue, value);
|
|
115
|
+
}
|
|
116
|
+
evaluateIncludes(queryCondition, testCondition) {
|
|
117
|
+
const { operator: queryOperator, value: queryValue } = queryCondition;
|
|
118
|
+
const { operator, value } = this.parseConditions([testCondition])[0];
|
|
119
|
+
const sortedQueryValue = Array.isArray(queryValue) ? queryValue.sort() : queryValue;
|
|
120
|
+
const sortedValue = Array.isArray(value) ? value.sort() : value;
|
|
121
|
+
return operator === queryOperator && (0, lodash_1.isEqual)(sortedValue, sortedQueryValue);
|
|
122
|
+
}
|
|
123
|
+
parseConditions(conditions) {
|
|
124
|
+
const parsedConditions = [];
|
|
125
|
+
const inMap = new Map();
|
|
126
|
+
const notInMap = new Map();
|
|
127
|
+
conditions.forEach(c => {
|
|
128
|
+
switch (c.operator) {
|
|
129
|
+
case '==':
|
|
130
|
+
case 'in':
|
|
131
|
+
inMap.set(c.fieldName, (inMap.get(c.fieldName) || []).concat(c.value));
|
|
132
|
+
break;
|
|
133
|
+
case '!=':
|
|
134
|
+
case 'not in':
|
|
135
|
+
notInMap.set(c.fieldName, (notInMap.get(c.fieldName) || []).concat(c.value));
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
138
|
+
parsedConditions.push(c);
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
inMap.forEach((value, fieldName) => {
|
|
143
|
+
parsedConditions.push({
|
|
144
|
+
fieldName: fieldName,
|
|
145
|
+
operator: 'in',
|
|
146
|
+
value: value,
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
notInMap.forEach((value, fieldName) => {
|
|
150
|
+
parsedConditions.push({
|
|
151
|
+
fieldName: fieldName,
|
|
152
|
+
operator: 'not in',
|
|
153
|
+
value: value,
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
return parsedConditions;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.QueryContext = QueryContext;
|
|
160
160
|
//# sourceMappingURL=query-context.js.map
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { DocumentData } from '../document.types';
|
|
2
|
-
import { Query, Alias, JoinCondition } from '../query.types';
|
|
3
|
-
export type SerializedSimpleQuery = {
|
|
4
|
-
type: 'simple';
|
|
5
|
-
query: Query;
|
|
6
|
-
dereference: boolean;
|
|
7
|
-
};
|
|
8
|
-
export type SerializedJoinQuery = {
|
|
9
|
-
type: 'join';
|
|
10
|
-
grouped: boolean;
|
|
11
|
-
dereference: boolean;
|
|
12
|
-
root: {
|
|
13
|
-
alias: Alias;
|
|
14
|
-
query: Query;
|
|
15
|
-
};
|
|
16
|
-
leftToRight: Record<Alias, Alias[]>;
|
|
17
|
-
joins: Record<Alias, Query<DocumentData>>;
|
|
18
|
-
joinConditions: Record<Alias, JoinCondition>;
|
|
19
|
-
};
|
|
20
|
-
export type SerializedMergedQuery = {
|
|
21
|
-
type: 'merged';
|
|
22
|
-
queries: Array<SerializedQuery>;
|
|
23
|
-
};
|
|
24
|
-
export type SerializedQuery = SerializedSimpleQuery | SerializedJoinQuery | SerializedMergedQuery;
|
|
1
|
+
import { DocumentData } from '../document.types';
|
|
2
|
+
import { Query, Alias, JoinCondition } from '../query.types';
|
|
3
|
+
export type SerializedSimpleQuery = {
|
|
4
|
+
type: 'simple';
|
|
5
|
+
query: Query;
|
|
6
|
+
dereference: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type SerializedJoinQuery = {
|
|
9
|
+
type: 'join';
|
|
10
|
+
grouped: boolean;
|
|
11
|
+
dereference: boolean;
|
|
12
|
+
root: {
|
|
13
|
+
alias: Alias;
|
|
14
|
+
query: Query;
|
|
15
|
+
};
|
|
16
|
+
leftToRight: Record<Alias, Alias[]>;
|
|
17
|
+
joins: Record<Alias, Query<DocumentData>>;
|
|
18
|
+
joinConditions: Record<Alias, JoinCondition>;
|
|
19
|
+
};
|
|
20
|
+
export type SerializedMergedQuery = {
|
|
21
|
+
type: 'merged';
|
|
22
|
+
queries: Array<SerializedQuery>;
|
|
23
|
+
};
|
|
24
|
+
export type SerializedQuery = SerializedSimpleQuery | SerializedJoinQuery | SerializedMergedQuery;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=serialized-query.types.js.map
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import { TriggerId } from './application.types';
|
|
2
|
-
import { AppId, ClientId, ClientRequestId } from './communication.types';
|
|
3
|
-
import { CollectionName, DocumentData, FieldName, PrimitiveFieldType } from './document.types';
|
|
4
|
-
import { Paths } from './types';
|
|
5
|
-
export type Alias = string;
|
|
6
|
-
export interface JoinCondition {
|
|
7
|
-
leftAlias: Alias;
|
|
8
|
-
left: FieldName;
|
|
9
|
-
right: FieldName;
|
|
10
|
-
isInner: boolean;
|
|
11
|
-
}
|
|
12
|
-
export type Condition<Doc extends DocumentData = any> = SimpleCondition<Doc> | CompositeCondition<Doc>;
|
|
13
|
-
export type Conditions<Doc extends DocumentData = any> = Array<Condition<Doc>>;
|
|
14
|
-
export interface SimpleCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>, MyOperator = Operator> {
|
|
15
|
-
fieldName: F;
|
|
16
|
-
operator: MyOperator;
|
|
17
|
-
value: any;
|
|
18
|
-
}
|
|
19
|
-
export interface CompositeCondition<Doc extends DocumentData = any> {
|
|
20
|
-
fields: Array<SimpleCondition<Doc, Paths<Doc>, CompositeConditionOperator>>;
|
|
21
|
-
}
|
|
22
|
-
export declare function isSimpleCondition(condition: Condition): condition is SimpleCondition;
|
|
23
|
-
type CompositeConditionOperator = '>=' | '<=' | '>' | '<';
|
|
24
|
-
export type Operator = '==' | '!=' | CompositeConditionOperator | 'like' | 'not like' | 'like_cs' | 'not like_cs';
|
|
25
|
-
export interface FieldSort<Doc> {
|
|
26
|
-
fieldName: FieldName<Doc>;
|
|
27
|
-
asc: boolean;
|
|
28
|
-
}
|
|
29
|
-
interface RegularQueryKey {
|
|
30
|
-
queryType: 'query';
|
|
31
|
-
clientId: string;
|
|
32
|
-
clientRequestId: string;
|
|
33
|
-
}
|
|
34
|
-
interface TriggerKey {
|
|
35
|
-
queryType: 'trigger';
|
|
36
|
-
triggerId: TriggerId;
|
|
37
|
-
}
|
|
38
|
-
export type QueryKey = RegularQueryKey | TriggerKey;
|
|
39
|
-
export interface Query<Doc extends DocumentData = any> {
|
|
40
|
-
collectionName: CollectionName;
|
|
41
|
-
integrationId: string;
|
|
42
|
-
conditions: Conditions<Doc>;
|
|
43
|
-
sortOrder: Array<FieldSort<Doc>>;
|
|
44
|
-
limit: number;
|
|
45
|
-
limitBy?: {
|
|
46
|
-
limit: number;
|
|
47
|
-
fields: Array<FieldName<Doc>>;
|
|
48
|
-
reverseSort: boolean;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
export type QuerySubscriptionId = `${ClientId}_${ClientRequestId}`;
|
|
52
|
-
export interface QueryRequest {
|
|
53
|
-
clientRequestId: ClientRequestId;
|
|
54
|
-
query: Query;
|
|
55
|
-
subscribe: boolean;
|
|
56
|
-
}
|
|
57
|
-
export interface QueryUnsubscribeRequest {
|
|
58
|
-
clientRequestId: ClientRequestId;
|
|
59
|
-
}
|
|
60
|
-
export interface QueryRegisterRequest {
|
|
61
|
-
clientRequestId: ClientRequestId;
|
|
62
|
-
query: Query;
|
|
63
|
-
parentClientRequestId: ClientRequestId;
|
|
64
|
-
}
|
|
65
|
-
interface QueryMetadata {
|
|
66
|
-
condCount: number;
|
|
67
|
-
}
|
|
68
|
-
export declare function encodeCondition(condition: Condition<any>): EncodedCondition;
|
|
69
|
-
export type EncodedCondition = string;
|
|
70
|
-
export type QueryMapping<QueryReferenceType extends string> = {
|
|
71
|
-
unconditional: Array<QueryReferenceType>;
|
|
72
|
-
conditional: Record<EncodedCondition, Array<QueryReferenceType>>;
|
|
73
|
-
queriesMetadata: Record<QueryReferenceType, QueryMetadata>;
|
|
74
|
-
};
|
|
75
|
-
export declare abstract class QueryMappingManager<T> {
|
|
76
|
-
abstract addQuery(appId: AppId, query: Query, key: T): Promise<void>;
|
|
77
|
-
abstract removeQuery(appId: AppId, key: T): Promise<Query | undefined>;
|
|
78
|
-
abstract removeLocalDevAppData(appId: AppId): Promise<void>;
|
|
79
|
-
}
|
|
80
|
-
export declare function compareOperator(conditionValue: PrimitiveFieldType, valueInDocument: PrimitiveFieldType, operator: Operator): boolean;
|
|
81
|
-
export declare function getQuerySubscriptionId(clientId: string, clientRequestId: string): QuerySubscriptionId;
|
|
82
|
-
export declare function parseQuerySubscriptionId(querySubscriptionId: QuerySubscriptionId): {
|
|
83
|
-
clientId: string;
|
|
84
|
-
clientRequestId: string;
|
|
85
|
-
};
|
|
86
|
-
export {};
|
|
1
|
+
import { TriggerId } from './application.types';
|
|
2
|
+
import { AppId, ClientId, ClientRequestId } from './communication.types';
|
|
3
|
+
import { CollectionName, DocumentData, FieldName, PrimitiveFieldType } from './document.types';
|
|
4
|
+
import { Paths } from './types';
|
|
5
|
+
export type Alias = string;
|
|
6
|
+
export interface JoinCondition {
|
|
7
|
+
leftAlias: Alias;
|
|
8
|
+
left: FieldName;
|
|
9
|
+
right: FieldName;
|
|
10
|
+
isInner: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type Condition<Doc extends DocumentData = any> = SimpleCondition<Doc> | CompositeCondition<Doc>;
|
|
13
|
+
export type Conditions<Doc extends DocumentData = any> = Array<Condition<Doc>>;
|
|
14
|
+
export interface SimpleCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>, MyOperator = Operator> {
|
|
15
|
+
fieldName: F;
|
|
16
|
+
operator: MyOperator;
|
|
17
|
+
value: any;
|
|
18
|
+
}
|
|
19
|
+
export interface CompositeCondition<Doc extends DocumentData = any> {
|
|
20
|
+
fields: Array<SimpleCondition<Doc, Paths<Doc>, CompositeConditionOperator>>;
|
|
21
|
+
}
|
|
22
|
+
export declare function isSimpleCondition(condition: Condition): condition is SimpleCondition;
|
|
23
|
+
type CompositeConditionOperator = '>=' | '<=' | '>' | '<';
|
|
24
|
+
export type Operator = '==' | '!=' | CompositeConditionOperator | 'like' | 'not like' | 'like_cs' | 'not like_cs';
|
|
25
|
+
export interface FieldSort<Doc> {
|
|
26
|
+
fieldName: FieldName<Doc>;
|
|
27
|
+
asc: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface RegularQueryKey {
|
|
30
|
+
queryType: 'query';
|
|
31
|
+
clientId: string;
|
|
32
|
+
clientRequestId: string;
|
|
33
|
+
}
|
|
34
|
+
interface TriggerKey {
|
|
35
|
+
queryType: 'trigger';
|
|
36
|
+
triggerId: TriggerId;
|
|
37
|
+
}
|
|
38
|
+
export type QueryKey = RegularQueryKey | TriggerKey;
|
|
39
|
+
export interface Query<Doc extends DocumentData = any> {
|
|
40
|
+
collectionName: CollectionName;
|
|
41
|
+
integrationId: string;
|
|
42
|
+
conditions: Conditions<Doc>;
|
|
43
|
+
sortOrder: Array<FieldSort<Doc>>;
|
|
44
|
+
limit: number;
|
|
45
|
+
limitBy?: {
|
|
46
|
+
limit: number;
|
|
47
|
+
fields: Array<FieldName<Doc>>;
|
|
48
|
+
reverseSort: boolean;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export type QuerySubscriptionId = `${ClientId}_${ClientRequestId}`;
|
|
52
|
+
export interface QueryRequest {
|
|
53
|
+
clientRequestId: ClientRequestId;
|
|
54
|
+
query: Query;
|
|
55
|
+
subscribe: boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface QueryUnsubscribeRequest {
|
|
58
|
+
clientRequestId: ClientRequestId;
|
|
59
|
+
}
|
|
60
|
+
export interface QueryRegisterRequest {
|
|
61
|
+
clientRequestId: ClientRequestId;
|
|
62
|
+
query: Query;
|
|
63
|
+
parentClientRequestId: ClientRequestId;
|
|
64
|
+
}
|
|
65
|
+
interface QueryMetadata {
|
|
66
|
+
condCount: number;
|
|
67
|
+
}
|
|
68
|
+
export declare function encodeCondition(condition: Condition<any>): EncodedCondition;
|
|
69
|
+
export type EncodedCondition = string;
|
|
70
|
+
export type QueryMapping<QueryReferenceType extends string> = {
|
|
71
|
+
unconditional: Array<QueryReferenceType>;
|
|
72
|
+
conditional: Record<EncodedCondition, Array<QueryReferenceType>>;
|
|
73
|
+
queriesMetadata: Record<QueryReferenceType, QueryMetadata>;
|
|
74
|
+
};
|
|
75
|
+
export declare abstract class QueryMappingManager<T> {
|
|
76
|
+
abstract addQuery(appId: AppId, query: Query, key: T): Promise<void>;
|
|
77
|
+
abstract removeQuery(appId: AppId, key: T): Promise<Query | undefined>;
|
|
78
|
+
abstract removeLocalDevAppData(appId: AppId): Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
export declare function compareOperator(conditionValue: PrimitiveFieldType, valueInDocument: PrimitiveFieldType, operator: Operator): boolean;
|
|
81
|
+
export declare function getQuerySubscriptionId(clientId: string, clientRequestId: string): QuerySubscriptionId;
|
|
82
|
+
export declare function parseQuerySubscriptionId(querySubscriptionId: QuerySubscriptionId): {
|
|
83
|
+
clientId: string;
|
|
84
|
+
clientRequestId: string;
|
|
85
|
+
};
|
|
86
|
+
export {};
|