@squidcloud/client 1.0.145 → 1.0.146-beta
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 +1 -53942
- package/dist/esm/index.js +1 -0
- package/dist/internal-common/src/metric-name.d.ts +9 -0
- package/dist/internal-common/src/public-types/ai-agent-integrations.public-types.d.ts +47 -0
- package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +895 -0
- package/dist/internal-common/src/public-types/ai-assistant.public-types.d.ts +31 -0
- package/dist/internal-common/src/public-types/ai-common.public-types.d.ts +185 -0
- package/dist/internal-common/src/public-types/ai-knowledge-base.public-types.d.ts +431 -0
- package/dist/internal-common/src/public-types/ai-matchmaking.public-types.d.ts +186 -0
- package/dist/internal-common/src/public-types/ai-query.public-types.d.ts +170 -0
- package/dist/internal-common/src/public-types/api-client.public-types.d.ts +9 -0
- package/dist/internal-common/src/public-types/api.public-types.d.ts +91 -0
- package/dist/internal-common/src/public-types/backend.public-types.d.ts +50 -0
- package/dist/{common/src/backend-function.schemas.d.ts → internal-common/src/public-types/code-executor.public-types.d.ts} +1 -1
- package/dist/internal-common/src/public-types/communication.public-types.d.ts +30 -0
- package/dist/internal-common/src/public-types/context.public-types.d.ts +83 -0
- package/dist/internal-common/src/public-types/document.public-types.d.ts +71 -0
- package/dist/internal-common/src/public-types/external-auth/external-auth.public-types.d.ts +39 -0
- package/dist/internal-common/src/public-types/extraction.public-types.d.ts +183 -0
- package/dist/internal-common/src/public-types/http-status.public-types.d.ts +415 -0
- package/dist/internal-common/src/public-types/integration.public-types.d.ts +51 -0
- package/dist/internal-common/src/public-types/job.public-types.d.ts +59 -0
- package/dist/internal-common/src/public-types/metric.public-types.d.ts +154 -0
- package/dist/internal-common/src/public-types/openapi.public-types.d.ts +9 -0
- package/dist/internal-common/src/public-types/query.public-types.d.ts +113 -0
- package/dist/internal-common/src/public-types/regions.public-types.d.ts +4 -0
- package/dist/internal-common/src/public-types/scheduler.public-types.d.ts +43 -0
- package/dist/{common/src/schema/schema.types.d.ts → internal-common/src/public-types/schema.public-types.d.ts} +54 -54
- package/dist/internal-common/src/public-types/secret.public-types.d.ts +51 -0
- package/dist/internal-common/src/public-types/serialized-query.public-types.d.ts +60 -0
- package/dist/internal-common/src/public-types/socket.public-types.d.ts +4 -0
- package/dist/{common/src/types.d.ts → internal-common/src/public-types/typescript.public-types.d.ts} +20 -14
- package/dist/internal-common/src/public-types/web.public-types.d.ts +93 -0
- package/dist/internal-common/src/public-types-backend/api-call.public-context.d.ts +30 -0
- package/dist/internal-common/src/public-types-backend/mutation.public-context.d.ts +148 -0
- package/dist/internal-common/src/public-types-backend/native-query.public-context.d.ts +72 -0
- package/dist/{common/src/query/query-context.d.ts → internal-common/src/public-types-backend/query.public-context.d.ts} +177 -137
- package/dist/{common/src/ai-chatbot.schemas.d.ts → internal-common/src/public-utils/context-utils.d.ts} +1 -1
- package/dist/internal-common/src/public-utils/id-utils.d.ts +44 -0
- package/dist/internal-common/src/types/ai-agent.types.d.ts +199 -0
- package/dist/{common/src/mutation.schemas.d.ts → internal-common/src/types/ai-assistant.types.d.ts} +1 -1
- package/dist/internal-common/src/types/ai-knowledge-base.types.d.ts +202 -0
- package/dist/internal-common/src/types/ai-matchmaking.types.d.ts +59 -0
- package/dist/{common/src → internal-common/src/types}/backend-function.types.d.ts +1 -1
- package/dist/internal-common/src/types/communication.types.d.ts +1 -0
- package/dist/internal-common/src/types/document.types.d.ts +1 -0
- package/dist/internal-common/src/types/file.types.d.ts +6 -0
- package/dist/internal-common/src/types/headers.types.d.ts +17 -0
- package/dist/internal-common/src/types/mutation.types.d.ts +1 -0
- package/dist/internal-common/src/types/notification.types.d.ts +5 -0
- package/dist/internal-common/src/types/observability.types.d.ts +78 -0
- package/dist/internal-common/src/types/query.types.d.ts +13 -0
- package/dist/internal-common/src/types/secret.types.d.ts +7 -0
- package/dist/internal-common/src/types/socket.types.d.ts +1 -0
- package/dist/internal-common/src/types/stage.d.ts +9 -0
- package/dist/{common/src → internal-common/src/types}/time-units.d.ts +1 -1
- package/dist/internal-common/src/types/url-shortener.types.d.ts +41 -0
- package/dist/internal-common/src/utils/array.d.ts +7 -0
- package/dist/internal-common/src/utils/e2e-test-utils.d.ts +2 -0
- package/dist/{common → internal-common}/src/utils/global.utils.d.ts +1 -1
- package/dist/internal-common/src/utils/http.d.ts +5 -0
- package/dist/{common → internal-common}/src/utils/lock.manager.d.ts +14 -14
- package/dist/internal-common/src/utils/metric-utils.d.ts +4 -0
- package/dist/internal-common/src/utils/metrics.types.d.ts +7 -0
- package/dist/internal-common/src/utils/object.d.ts +58 -0
- package/dist/internal-common/src/utils/serialization.d.ts +17 -0
- package/dist/internal-common/src/utils/squid.constants.d.ts +1 -0
- package/dist/internal-common/src/utils/trace-id-generator.d.ts +1 -0
- package/dist/internal-common/src/utils/validation.d.ts +19 -0
- package/dist/{common → internal-common}/src/websocket.impl.d.ts +26 -21
- package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -1239
- package/dist/typescript-client/src/admin-client.d.ts +23 -0
- package/dist/typescript-client/src/agent/ai-agent-client-reference.d.ts +181 -0
- package/dist/typescript-client/src/agent/ai-agent-client.d.ts +37 -0
- package/dist/typescript-client/src/agent/ai-agent-client.types.d.ts +69 -0
- package/dist/typescript-client/src/ai-assistant-client.d.ts +72 -73
- package/dist/typescript-client/src/ai-audio-client.d.ts +25 -0
- package/dist/typescript-client/src/ai-client.d.ts +129 -0
- package/dist/typescript-client/src/ai-files-client.d.ts +33 -0
- package/dist/typescript-client/src/ai-image-client.d.ts +25 -0
- package/dist/typescript-client/src/ai-knowledge-base/ai-knowledge-base-client-reference.d.ts +86 -0
- package/dist/typescript-client/src/ai-knowledge-base/ai-knowledge-base-client.d.ts +28 -0
- package/dist/typescript-client/src/ai-matchmaking-client.d.ts +99 -0
- package/dist/typescript-client/src/api-client.d.ts +69 -0
- package/dist/typescript-client/src/auth.manager.d.ts +11 -26
- package/dist/typescript-client/src/backend-function.manager.d.ts +1 -9
- package/dist/typescript-client/src/client-customization.utils.d.ts +1 -0
- package/dist/typescript-client/src/client-id.service.d.ts +1 -27
- package/dist/typescript-client/src/collection-reference.d.ts +105 -80
- package/dist/typescript-client/src/collection-reference.factory.d.ts +1 -13
- package/dist/typescript-client/src/connection-details.d.ts +24 -23
- package/dist/typescript-client/src/console-utils.d.ts +1 -0
- package/dist/typescript-client/src/data.manager.d.ts +1 -173
- package/dist/typescript-client/src/destruct.manager.d.ts +1 -12
- package/dist/typescript-client/src/distributed-lock.manager.d.ts +39 -16
- package/dist/typescript-client/src/document-identity.service.d.ts +1 -12
- package/dist/typescript-client/src/document-reference.d.ts +151 -140
- package/dist/typescript-client/src/document-reference.factory.d.ts +1 -13
- package/dist/typescript-client/src/document-store.d.ts +1 -14
- package/dist/typescript-client/src/execute-function-options.d.ts +73 -0
- package/dist/typescript-client/src/external-auth-client.d.ts +36 -0
- package/dist/typescript-client/src/extraction-client.d.ts +32 -0
- package/dist/typescript-client/src/file-args-transformer.d.ts +1 -0
- package/dist/typescript-client/src/file-utils.d.ts +1 -0
- package/dist/typescript-client/src/index.d.ts +63 -9
- package/dist/typescript-client/src/integration-client.d.ts +60 -0
- package/dist/typescript-client/src/job-client.d.ts +32 -0
- package/dist/typescript-client/src/mutation/mutation-sender.d.ts +1 -10
- package/dist/typescript-client/src/native-query-manager.d.ts +1 -7
- package/dist/typescript-client/src/notification-client.d.ts +20 -0
- package/dist/typescript-client/src/observability-client.d.ts +43 -0
- package/dist/typescript-client/src/public-types.d.ts +30 -0
- package/dist/typescript-client/src/public-utils.d.ts +1 -0
- package/dist/typescript-client/src/query/deserializer.d.ts +10 -3
- package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +316 -161
- package/dist/typescript-client/src/query/local-query-manager.d.ts +1 -9
- package/dist/{common → typescript-client}/src/query/pagination.d.ts +65 -62
- package/dist/typescript-client/src/query/query-builder.factory.d.ts +228 -77
- package/dist/typescript-client/src/query/query-sender.d.ts +1 -33
- package/dist/typescript-client/src/query/query-subscription.manager.d.ts +1 -130
- package/dist/typescript-client/src/query/query.types.d.ts +16 -49
- package/dist/typescript-client/src/query/snapshot-emitter.d.ts +41 -0
- package/dist/typescript-client/src/query-utils.d.ts +18 -0
- package/dist/typescript-client/src/queue.manager.d.ts +12 -0
- package/dist/typescript-client/src/rate-limiter.d.ts +1 -32
- package/dist/typescript-client/src/rpc.manager.d.ts +1 -30
- package/dist/typescript-client/src/scheduler-client.d.ts +31 -0
- package/dist/typescript-client/src/secret.client.d.ts +96 -22
- package/dist/typescript-client/src/socket.manager.d.ts +1 -43
- package/dist/typescript-client/src/squid-http-client.d.ts +11 -0
- package/dist/typescript-client/src/squid.d.ts +378 -269
- package/dist/typescript-client/src/state/state.service.spec.d.ts +1 -1
- package/dist/typescript-client/src/storage-client.d.ts +145 -0
- package/dist/typescript-client/src/types.d.ts +27 -2
- package/dist/typescript-client/src/version.d.ts +5 -0
- package/dist/typescript-client/src/web-client.d.ts +63 -0
- package/dist/typescript-client/src/webhook.manager.d.ts +10 -0
- package/package.json +34 -18
- package/dist/common/src/ai-assistant.types.d.ts +0 -25
- package/dist/common/src/ai-chatbot.context.d.ts +0 -12
- package/dist/common/src/ai-chatbot.types.d.ts +0 -27
- package/dist/common/src/api-call.context.d.ts +0 -13
- package/dist/common/src/api.types.d.ts +0 -4
- package/dist/common/src/application.schemas.d.ts +0 -66
- package/dist/common/src/application.types.d.ts +0 -143
- package/dist/common/src/backend-run.types.d.ts +0 -2
- package/dist/common/src/bundle-api.types.d.ts +0 -43
- package/dist/common/src/bundle-data.types.d.ts +0 -5
- package/dist/common/src/communication.types.d.ts +0 -8
- package/dist/common/src/context.types.d.ts +0 -40
- package/dist/common/src/distributed-lock.context.d.ts +0 -4
- package/dist/common/src/document.types.d.ts +0 -22
- package/dist/common/src/graphql.context.d.ts +0 -7
- package/dist/common/src/graphql.types.d.ts +0 -9
- package/dist/common/src/heartbeat.types.d.ts +0 -1
- package/dist/common/src/http-status.enum.d.ts +0 -50
- package/dist/common/src/index.d.ts +0 -57
- package/dist/common/src/integrations/ai_chatbot.types.d.ts +0 -31
- package/dist/common/src/integrations/api.types.d.ts +0 -80
- package/dist/common/src/integrations/auth.types.d.ts +0 -47
- package/dist/common/src/integrations/database.types.d.ts +0 -274
- package/dist/common/src/integrations/index.d.ts +0 -134
- package/dist/common/src/integrations/observability.types.d.ts +0 -23
- package/dist/common/src/logger.types.d.ts +0 -21
- package/dist/common/src/metrics.types.d.ts +0 -1
- package/dist/common/src/mutation.context.d.ts +0 -14
- package/dist/common/src/mutation.types.d.ts +0 -53
- package/dist/common/src/named-query.context.d.ts +0 -4
- package/dist/common/src/named-query.schemas.d.ts +0 -1
- package/dist/common/src/named-query.types.d.ts +0 -1
- package/dist/common/src/native-query.context.d.ts +0 -7
- package/dist/common/src/native-query.types.d.ts +0 -16
- package/dist/common/src/query/base-query-builder.d.ts +0 -147
- package/dist/common/src/query/index.d.ts +0 -4
- package/dist/common/src/query/serialized-query.types.d.ts +0 -24
- package/dist/common/src/query.types.d.ts +0 -64
- package/dist/common/src/regions.d.ts +0 -1
- package/dist/common/src/secret.schemas.d.ts +0 -1
- package/dist/common/src/secret.types.d.ts +0 -22
- package/dist/common/src/security.types.d.ts +0 -1
- package/dist/common/src/socket.schemas.d.ts +0 -1
- package/dist/common/src/socket.types.d.ts +0 -5
- package/dist/common/src/trigger.types.d.ts +0 -1
- package/dist/common/src/utils/array.d.ts +0 -1
- package/dist/common/src/utils/assert.d.ts +0 -1
- package/dist/common/src/utils/error.d.ts +0 -4
- package/dist/common/src/utils/http.d.ts +0 -2
- package/dist/common/src/utils/id.d.ts +0 -2
- package/dist/common/src/utils/object.d.ts +0 -5
- package/dist/common/src/utils/serialization.d.ts +0 -6
- package/dist/common/src/utils/transforms.d.ts +0 -18
- package/dist/common/src/utils/url.d.ts +0 -1
- package/dist/common/src/utils/validation.d.ts +0 -25
- package/dist/common/src/webhook-response.d.ts +0 -1
- package/dist/typescript-client/src/ai-chatbot-client.d.ts +0 -174
- package/dist/typescript-client/src/ai-chatbot-client.factory.d.ts +0 -8
- package/dist/typescript-client/src/ai.types.d.ts +0 -61
- package/dist/typescript-client/src/api.manager.d.ts +0 -11
- package/dist/typescript-client/src/graphql-client.d.ts +0 -14
- package/dist/typescript-client/src/graphql-client.factory.d.ts +0 -11
- package/dist/typescript-client/src/named-query.manager.d.ts +0 -11
- package/dist/typescript-client/src/state/action.applier.d.ts +0 -7
- package/dist/typescript-client/src/state/actions.d.ts +0 -29
- package/dist/typescript-client/src/state/path_trie.d.ts +0 -27
- package/dist/typescript-client/src/state/state.service.d.ts +0 -22
- package/dist/typescript-client/src/testing/setup-tests.d.ts +0 -1
|
@@ -1,161 +1,316 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { DocumentReference } from '../document-reference';
|
|
3
|
+
import { Alias, DocumentData, FieldName, FieldSort, Operator, PrimitiveFieldType, Query, SerializedJoinQuery, SimpleCondition } from '../public-types';
|
|
4
|
+
import { Pagination, PaginationOptions } from './pagination';
|
|
5
|
+
import { BaseQueryBuilder, HasDereference, QueryBuilder } from './query-builder.factory';
|
|
6
|
+
import { SnapshotEmitter } from './snapshot-emitter';
|
|
7
|
+
/**
|
|
8
|
+
* Represents the result of a join query where each property is a document reference,
|
|
9
|
+
* grouped by alias instead of containing DocumentData.
|
|
10
|
+
* @category Database
|
|
11
|
+
*/
|
|
12
|
+
export type WithDocumentReferences<T extends Record<any, DocumentData>> = {
|
|
13
|
+
[k in keyof T]: DocumentReference<Required<T>[k]>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Defines the fields used for joining two collections in a query.
|
|
17
|
+
* Specifies the left and right fields that establish the join relationship.
|
|
18
|
+
* @category Database
|
|
19
|
+
*/
|
|
20
|
+
export interface JoinFields<ReturnType> {
|
|
21
|
+
/** Field from the left collection to be used in the join. */
|
|
22
|
+
left: FieldName;
|
|
23
|
+
/** Field from the right collection to be used in the join. */
|
|
24
|
+
right: keyof ReturnType & FieldName;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Options for configuring a join query.
|
|
28
|
+
* Specifies aliasing and whether the join is inner or outer.
|
|
29
|
+
* @category Database
|
|
30
|
+
*/
|
|
31
|
+
export interface JoinOptions {
|
|
32
|
+
/** Alias for the left collection in the join. */
|
|
33
|
+
leftAlias: Alias;
|
|
34
|
+
/** Whether the join should be an inner join (default is outer join). */
|
|
35
|
+
isInner?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A join query result that has been grouped by alias.
|
|
39
|
+
* @category Database
|
|
40
|
+
*/
|
|
41
|
+
export 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]>;
|
|
42
|
+
/**
|
|
43
|
+
* A helper type for Groups.
|
|
44
|
+
* @category Database
|
|
45
|
+
*/
|
|
46
|
+
export 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>;
|
|
47
|
+
/**
|
|
48
|
+
* A join query result that has been grouped by alias.
|
|
49
|
+
* @category Database
|
|
50
|
+
*/
|
|
51
|
+
export interface HasGrouped {
|
|
52
|
+
/**
|
|
53
|
+
* Transforms this join query result to a nested data structure. For example, a join between teachers and students
|
|
54
|
+
* normally returns a result of the form:
|
|
55
|
+
* [
|
|
56
|
+
* { teacher: {name: 'Mr. Smith'}, student: {name: 'John Doe'} },
|
|
57
|
+
* { teacher: {name: 'Mr. Smith'}, student: {name: 'Jane Smith'} },
|
|
58
|
+
* { teacher: {name: 'Mr. EmptyClass'}, student: undefined },
|
|
59
|
+
* ]
|
|
60
|
+
* into a result of the form:
|
|
61
|
+
* [
|
|
62
|
+
* { teacher: {name: 'Mr. Smith'}, students: [
|
|
63
|
+
* { name: 'John Doe' },
|
|
64
|
+
* { name: 'Jane Smith' },
|
|
65
|
+
* ]},
|
|
66
|
+
* { teacher: {name: 'Mr. EmptyClass'}, students: [] },
|
|
67
|
+
* ]
|
|
68
|
+
*/
|
|
69
|
+
grouped(): any;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A query builder that can participate in a join.
|
|
73
|
+
* To learn more about join queries, see the
|
|
74
|
+
* {@link https://docs.getsquid.ai/docs/sdk/client-sdk/database/queries#joining-data-across-collections-and-connectors
|
|
75
|
+
* documentation}.
|
|
76
|
+
* @category Database
|
|
77
|
+
*/
|
|
78
|
+
export declare class JoinQueryBuilder<Aliases extends Record<Alias, Alias[]>, ReturnType extends Record<Alias, DocumentData>, LatestAlias extends Alias, RootAlias extends Alias> extends BaseQueryBuilder<ReturnType> implements SnapshotEmitter<WithDocumentReferences<ReturnType>>, HasGrouped, HasDereference {
|
|
79
|
+
private readonly collectionName;
|
|
80
|
+
private readonly integrationId;
|
|
81
|
+
private readonly querySubscriptionManager;
|
|
82
|
+
private readonly documentReferenceFactory;
|
|
83
|
+
private readonly queryBuilderFactory;
|
|
84
|
+
private readonly latestAlias;
|
|
85
|
+
private readonly joins;
|
|
86
|
+
private readonly joinConditions;
|
|
87
|
+
private readonly queryBuilder;
|
|
88
|
+
/**
|
|
89
|
+
* Adds a condition to the query.
|
|
90
|
+
*
|
|
91
|
+
* @param fieldName The name of the field to query
|
|
92
|
+
* @param operator The operator to use
|
|
93
|
+
* @param value The value to compare against
|
|
94
|
+
* @returns The query builder
|
|
95
|
+
*/
|
|
96
|
+
where(fieldName: (keyof ReturnType[LatestAlias] & FieldName) | string, operator: Operator | 'in' | 'not in', value: PrimitiveFieldType | Array<PrimitiveFieldType>): this;
|
|
97
|
+
/**
|
|
98
|
+
* Sets a limit to the number of results returned by the query. The maximum limit is 20,000 and the default is 1,000
|
|
99
|
+
* if none is provided.
|
|
100
|
+
*
|
|
101
|
+
* @param limit The maximum number of results to return
|
|
102
|
+
* @returns The query builder
|
|
103
|
+
*/
|
|
104
|
+
limit(limit: number): this;
|
|
105
|
+
/**
|
|
106
|
+
* Adds a sort order to the query. You can add multiple sort orders to the query. The order in which you add them
|
|
107
|
+
* determines the order in which they are applied.
|
|
108
|
+
* @param fieldName The name of the field to sort by
|
|
109
|
+
* @param asc Whether to sort in ascending order. Defaults to true.
|
|
110
|
+
* @returns The query builder
|
|
111
|
+
*/
|
|
112
|
+
sortBy(fieldName: (keyof ReturnType[RootAlias] & FieldName) | string, asc?: boolean): this;
|
|
113
|
+
/**
|
|
114
|
+
* Joins this query with another collection using a specified alias from the left side of the join,
|
|
115
|
+
* allowing you to build complex multi-level joins. The join is defined by specifying which fields
|
|
116
|
+
* to use on both sides of the relationship.
|
|
117
|
+
*
|
|
118
|
+
* @param queryBuilder - The query builder for the collection you want to join with.
|
|
119
|
+
* @param alias - A unique alias for the joined collection. Must not conflict with existing aliases.
|
|
120
|
+
* @param joinFields - The join condition specifying which fields to join: `left` is from the `leftAlias` collection,
|
|
121
|
+
* `right` is from the joined collection.
|
|
122
|
+
* @param options - Configuration for the join:
|
|
123
|
+
* - `leftAlias`: the alias of the collection on the left-hand side of the join.
|
|
124
|
+
* - `isInner`: whether this should be an inner join (default is outer join).
|
|
125
|
+
* @returns A new `JoinQueryBuilder` instance including the joined collection, allowing you to continue building the
|
|
126
|
+
* query.
|
|
127
|
+
*/
|
|
128
|
+
join<NewAlias extends string, NewReturnType extends DocumentData, LeftAlias extends Extract<keyof ReturnType, Alias>, IsInner extends boolean = false>(queryBuilder: QueryBuilder<NewReturnType>, alias: Exclude<NewAlias, keyof ReturnType>, joinFields: {
|
|
129
|
+
left: keyof Required<ReturnType>[LeftAlias] & FieldName;
|
|
130
|
+
right: keyof NewReturnType & FieldName;
|
|
131
|
+
}, options: {
|
|
132
|
+
leftAlias: LeftAlias;
|
|
133
|
+
isInner?: IsInner;
|
|
134
|
+
}): Omit<JoinQueryBuilder<Omit<Aliases, LeftAlias> & Record<LeftAlias, [...Aliases[LeftAlias], NewAlias]> & Record<NewAlias, []>, ReturnType & (IsInner extends true ? Record<NewAlias, NewReturnType> : Partial<Record<NewAlias, NewReturnType>>), NewAlias, RootAlias>, 'limit' | 'getLimit'>;
|
|
135
|
+
/**
|
|
136
|
+
* Joins this query with another collection using a specified alias from the left side.
|
|
137
|
+
*
|
|
138
|
+
* @param queryBuilder - The query builder for the collection to be joined.
|
|
139
|
+
* @param alias - A unique alias for the joined collection.
|
|
140
|
+
* @param joinFields - Fields that define the join relationship (`left` and `right`).
|
|
141
|
+
* @param options - Options including the left alias to join from and whether the join is inner.
|
|
142
|
+
* @returns A new `JoinQueryBuilder` including the joined collection.
|
|
143
|
+
*/
|
|
144
|
+
join<NewAlias extends string, NewReturnType extends DocumentData, IsInner extends boolean = false>(queryBuilder: QueryBuilder<NewReturnType>, alias: Exclude<NewAlias, keyof ReturnType>, joinFields: {
|
|
145
|
+
left: keyof Required<ReturnType>[LatestAlias] & FieldName;
|
|
146
|
+
right: keyof NewReturnType & FieldName;
|
|
147
|
+
}, options?: {
|
|
148
|
+
isInner?: IsInner;
|
|
149
|
+
}): Omit<JoinQueryBuilder<Omit<Aliases, LatestAlias> & Record<LatestAlias, [...Aliases[LatestAlias], NewAlias]> & Record<NewAlias, []>, ReturnType & (IsInner extends true ? Record<NewAlias, NewReturnType> : Partial<Record<NewAlias, NewReturnType>>), NewAlias, RootAlias>, 'limit' | 'getLimit'>;
|
|
150
|
+
/** @inheritDoc */
|
|
151
|
+
snapshot(): Promise<Array<WithDocumentReferences<ReturnType>>>;
|
|
152
|
+
/** @inheritDoc */
|
|
153
|
+
snapshots(subscribe?: boolean): Observable<Array<WithDocumentReferences<ReturnType>>>;
|
|
154
|
+
/**
|
|
155
|
+
* @inheritDoc
|
|
156
|
+
*/
|
|
157
|
+
peek(): Array<WithDocumentReferences<ReturnType>>;
|
|
158
|
+
/** @inheritDoc */
|
|
159
|
+
grouped(): GroupedJoin<Aliases, ReturnType, RootAlias, LatestAlias>;
|
|
160
|
+
/** @inheritDoc */
|
|
161
|
+
dereference(): DereferencedJoin<Aliases, ReturnType, RootAlias, LatestAlias>;
|
|
162
|
+
/** @inheritDoc */
|
|
163
|
+
build(): Query;
|
|
164
|
+
/**
|
|
165
|
+
* Gets the list of sort orders applied to the query.
|
|
166
|
+
*
|
|
167
|
+
* @returns An array of field sort configurations.
|
|
168
|
+
*/
|
|
169
|
+
getSortOrders(): Array<FieldSort<any>>;
|
|
170
|
+
/**
|
|
171
|
+
* Creates a deep copy of the current query builder.
|
|
172
|
+
*
|
|
173
|
+
* @returns A cloned instance of the query builder.
|
|
174
|
+
*/
|
|
175
|
+
clone(): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>;
|
|
176
|
+
/**
|
|
177
|
+
* Adds a composite condition (AND of multiple conditions) to the query.
|
|
178
|
+
*
|
|
179
|
+
* @param conditions An array of simple conditions to apply.
|
|
180
|
+
* @returns The updated query builder.
|
|
181
|
+
*/
|
|
182
|
+
addCompositeCondition(conditions: Array<SimpleCondition>): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>;
|
|
183
|
+
/**
|
|
184
|
+
* Reverses the current sort order(s) of the query.
|
|
185
|
+
*
|
|
186
|
+
* @returns The updated query builder with reversed sort order(s).
|
|
187
|
+
*/
|
|
188
|
+
flipSortOrder(): JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>;
|
|
189
|
+
/**
|
|
190
|
+
* Extracts the root document's data from a join query result.
|
|
191
|
+
*
|
|
192
|
+
* @param data A result object with document references.
|
|
193
|
+
* @returns The root alias's document reference data.
|
|
194
|
+
*/
|
|
195
|
+
extractData(data: WithDocumentReferences<ReturnType>): Required<ReturnType>[RootAlias];
|
|
196
|
+
/**
|
|
197
|
+
* Serializes the join query into a plain object.
|
|
198
|
+
*
|
|
199
|
+
* @returns A serialized representation of the query, suitable for transport or logging.
|
|
200
|
+
*/
|
|
201
|
+
serialize(): SerializedJoinQuery;
|
|
202
|
+
/**
|
|
203
|
+
* Enables pagination for the join query results.
|
|
204
|
+
*
|
|
205
|
+
* @param options Optional pagination configuration such as page size and cursor.
|
|
206
|
+
* @returns A {@link Pagination} object for fetching paginated results.
|
|
207
|
+
*/
|
|
208
|
+
paginate(options?: Partial<PaginationOptions>): Pagination<WithDocumentReferences<ReturnType>>;
|
|
209
|
+
/**
|
|
210
|
+
* Checks whether the join query contains any inner joins.
|
|
211
|
+
*
|
|
212
|
+
* @returns `true` if at least one join is inner; otherwise `false`.
|
|
213
|
+
*/
|
|
214
|
+
hasIsInner(): boolean;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* A join query result that has been grouped by alias and returns the DocumentData.
|
|
218
|
+
* @category Database
|
|
219
|
+
*/
|
|
220
|
+
export declare class DereferencedJoin<Aliases extends Record<Alias, Alias[]>, ReturnType extends Record<Alias, DocumentData>, RootAlias extends Alias, LatestAlias extends Alias> implements SnapshotEmitter<ReturnType>, HasGrouped {
|
|
221
|
+
private readonly joinQueryBuilder;
|
|
222
|
+
/** @inheritDoc */
|
|
223
|
+
grouped(): SnapshotEmitter<Grouped<Aliases, ReturnType, RootAlias>>;
|
|
224
|
+
/** @inheritDoc */
|
|
225
|
+
snapshot(): Promise<Array<ReturnType>>;
|
|
226
|
+
/** @inheritDoc */
|
|
227
|
+
snapshots(subscribe?: boolean): Observable<Array<ReturnType>>;
|
|
228
|
+
/**
|
|
229
|
+
* @inheritDoc
|
|
230
|
+
*/
|
|
231
|
+
peek(): Array<ReturnType>;
|
|
232
|
+
/**
|
|
233
|
+
* Returns the current sort orders applied to the query.
|
|
234
|
+
*
|
|
235
|
+
* @returns An array of field sort definitions.
|
|
236
|
+
*/
|
|
237
|
+
getSortOrders(): Array<FieldSort<any>>;
|
|
238
|
+
/**
|
|
239
|
+
* Clones the current join query builder instance.
|
|
240
|
+
*
|
|
241
|
+
* @returns A deep copy of the join query builder.
|
|
242
|
+
*/
|
|
243
|
+
clone(): DereferencedJoin<Aliases, ReturnType, RootAlias, LatestAlias>;
|
|
244
|
+
/**
|
|
245
|
+
* Adds multiple conditions that are combined with an AND operator.
|
|
246
|
+
*
|
|
247
|
+
* @param conditions An array of conditions to be applied together.
|
|
248
|
+
* @returns The updated query builder.
|
|
249
|
+
*/
|
|
250
|
+
addCompositeCondition(conditions: Array<SimpleCondition>): DereferencedJoin<Aliases, ReturnType, RootAlias, LatestAlias>;
|
|
251
|
+
/**
|
|
252
|
+
* Reverses the direction of all currently applied sort orders.
|
|
253
|
+
*
|
|
254
|
+
* @returns The updated query builder.
|
|
255
|
+
*/
|
|
256
|
+
flipSortOrder(): DereferencedJoin<Aliases, ReturnType, RootAlias, LatestAlias>;
|
|
257
|
+
/**
|
|
258
|
+
* Extracts the root document's data from the given join result.
|
|
259
|
+
*
|
|
260
|
+
* @param data A record containing document references.
|
|
261
|
+
* @returns The root document's data.
|
|
262
|
+
*/
|
|
263
|
+
extractData(data: ReturnType): any;
|
|
264
|
+
/**
|
|
265
|
+
* Enables pagination for the join query results.
|
|
266
|
+
*
|
|
267
|
+
* @param options Optional pagination configuration such as page size and cursor.
|
|
268
|
+
* @returns A {@link Pagination} object for fetching paginated results.
|
|
269
|
+
*/
|
|
270
|
+
paginate(options?: Partial<PaginationOptions>): Pagination<ReturnType>;
|
|
271
|
+
/**
|
|
272
|
+
* Serializes the join query into a plain object.
|
|
273
|
+
*
|
|
274
|
+
* @returns A serialized representation of the query, suitable for transport or logging.
|
|
275
|
+
*/
|
|
276
|
+
serialize(): SerializedJoinQuery;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* A join query result that has been grouped by alias.
|
|
280
|
+
* @category Database
|
|
281
|
+
*/
|
|
282
|
+
export declare class GroupedJoin<Aliases extends Record<Alias, Alias[]>, ReturnType extends Record<Alias, DocumentData>, RootAlias extends Alias, LatestAlias extends Alias> implements SnapshotEmitter<Grouped<Aliases, WithDocumentReferences<ReturnType>, RootAlias>>, HasDereference {
|
|
283
|
+
readonly joinQueryBuilder: JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>;
|
|
284
|
+
/** internal */
|
|
285
|
+
constructor(joinQueryBuilder: JoinQueryBuilder<Aliases, ReturnType, LatestAlias, RootAlias>);
|
|
286
|
+
/** @inheritDoc */
|
|
287
|
+
snapshot(): Promise<Array<Grouped<Aliases, WithDocumentReferences<ReturnType>, RootAlias>>>;
|
|
288
|
+
/** @inheritDoc */
|
|
289
|
+
snapshots(subscribe?: boolean): Observable<Array<Grouped<Aliases, WithDocumentReferences<ReturnType>, RootAlias>>>;
|
|
290
|
+
/**
|
|
291
|
+
* @inheritDoc
|
|
292
|
+
*/
|
|
293
|
+
peek(): Array<Grouped<Aliases, WithDocumentReferences<ReturnType>, RootAlias>>;
|
|
294
|
+
/** @inheritDoc */
|
|
295
|
+
dereference(): SnapshotEmitter<Grouped<Aliases, ReturnType, RootAlias>>;
|
|
296
|
+
/** @inheritDoc */
|
|
297
|
+
getSortOrders(): Array<FieldSort<any>>;
|
|
298
|
+
/** @inheritDoc */
|
|
299
|
+
clone(): GroupedJoin<Aliases, ReturnType, RootAlias, LatestAlias>;
|
|
300
|
+
/** @inheritDoc */
|
|
301
|
+
addCompositeCondition(conditions: Array<SimpleCondition>): GroupedJoin<Aliases, ReturnType, RootAlias, LatestAlias>;
|
|
302
|
+
/** @inheritDoc */
|
|
303
|
+
flipSortOrder(): GroupedJoin<Aliases, ReturnType, RootAlias, LatestAlias>;
|
|
304
|
+
/** @inheritDoc */
|
|
305
|
+
extractData(data: Grouped<Aliases, WithDocumentReferences<ReturnType>, RootAlias>): any;
|
|
306
|
+
/** @inheritDoc */
|
|
307
|
+
serialize(): SerializedJoinQuery;
|
|
308
|
+
/**
|
|
309
|
+
* Enables pagination for the join query results.
|
|
310
|
+
*
|
|
311
|
+
* @param options Optional pagination configuration such as page size and cursor.
|
|
312
|
+
* @returns A {@link Pagination} object for fetching paginated results.
|
|
313
|
+
*/
|
|
314
|
+
paginate(options?: Partial<PaginationOptions>): Pagination<Grouped<Aliases, WithDocumentReferences<ReturnType>, RootAlias>>;
|
|
315
|
+
private groupData;
|
|
316
|
+
}
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { DocumentStore } from '../document-store';
|
|
3
|
-
import { QuerySubscriptionManager } from './query-subscription.manager';
|
|
4
|
-
export declare class LocalQueryManager {
|
|
5
|
-
private readonly documentStore;
|
|
6
|
-
private readonly documentReferenceFactory;
|
|
7
|
-
private readonly querySubscriptionManager;
|
|
8
|
-
constructor(documentStore: DocumentStore, documentReferenceFactory: DocumentReferenceFactory, querySubscriptionManager: QuerySubscriptionManager);
|
|
9
|
-
}
|
|
1
|
+
export {};
|
|
@@ -1,62 +1,65 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
interface
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
private
|
|
31
|
-
private
|
|
32
|
-
private
|
|
33
|
-
private
|
|
34
|
-
private
|
|
35
|
-
private
|
|
36
|
-
private
|
|
37
|
-
private
|
|
38
|
-
private
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
/**
|
|
3
|
+
* The state of a pagination.
|
|
4
|
+
* @category Database
|
|
5
|
+
*/
|
|
6
|
+
export interface PaginationState<ReturnType> {
|
|
7
|
+
/** The page data. */
|
|
8
|
+
data: Array<ReturnType>;
|
|
9
|
+
/** Whether there is a next page. */
|
|
10
|
+
hasNext: boolean;
|
|
11
|
+
/** Whether there is a previous page. */
|
|
12
|
+
hasPrev: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Pagination options.
|
|
16
|
+
* @category Database
|
|
17
|
+
*/
|
|
18
|
+
export interface PaginationOptions {
|
|
19
|
+
/** Whether to show real-time updates. Defaults to true. */
|
|
20
|
+
subscribe: boolean;
|
|
21
|
+
/** The number of items in a page. Defaults to 100. */
|
|
22
|
+
pageSize: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Pagination provides a paginated view over a dataset, supporting navigation
|
|
26
|
+
* through pages, real-time updates, and sorting based on predefined criteria.
|
|
27
|
+
* @category Database
|
|
28
|
+
*/
|
|
29
|
+
export declare class Pagination<ReturnType> {
|
|
30
|
+
private readonly paginateOptions;
|
|
31
|
+
private internalStateObserver;
|
|
32
|
+
private firstElement;
|
|
33
|
+
private readonly isDestroyed;
|
|
34
|
+
private templateSnapshotEmitter;
|
|
35
|
+
private snapshotSubject;
|
|
36
|
+
private onFirstPage;
|
|
37
|
+
private navigatingToLastPage;
|
|
38
|
+
private lastElement;
|
|
39
|
+
/** Unsubscribes from the pagination. */
|
|
40
|
+
unsubscribe(): void;
|
|
41
|
+
/** Returns a promise that resolves when the previous page of data is available. */
|
|
42
|
+
prev(): Promise<PaginationState<ReturnType>>;
|
|
43
|
+
/** Returns a promise that resolves when the next page of data is available. */
|
|
44
|
+
next(): Promise<PaginationState<ReturnType>>;
|
|
45
|
+
/** Returns a promise that resolves when the page data is available. */
|
|
46
|
+
waitForData(): Promise<PaginationState<ReturnType>>;
|
|
47
|
+
/** Returns an observable that emits the current state of the pagination. */
|
|
48
|
+
observeState(): Observable<PaginationState<ReturnType>>;
|
|
49
|
+
/** Jumps to the first page of the pagination. */
|
|
50
|
+
first(): Promise<PaginationState<ReturnType>>;
|
|
51
|
+
/** Refreshes the current page of the pagination. */
|
|
52
|
+
refreshPage(): Promise<PaginationState<ReturnType>>;
|
|
53
|
+
/**
|
|
54
|
+
* Jumps to the last page of the pagination. This page will always have the last `pageSize` elements of the
|
|
55
|
+
* underlying query, regardless of whether the total document count is evenly divisible by the page size.
|
|
56
|
+
*/
|
|
57
|
+
last(): Promise<PaginationState<ReturnType>>;
|
|
58
|
+
private goToFirstPage;
|
|
59
|
+
private compareObjects;
|
|
60
|
+
private dataReceived;
|
|
61
|
+
private doNewQuery;
|
|
62
|
+
private waitForInternalState;
|
|
63
|
+
private internalStateToState;
|
|
64
|
+
private prevInternal;
|
|
65
|
+
}
|