@squidcloud/client 1.0.34 → 1.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/common/src/api-call.context.d.ts +12 -12
  2. package/dist/common/src/api.types.d.ts +23 -23
  3. package/dist/common/src/application.schemas.d.ts +883 -883
  4. package/dist/common/src/application.types.d.ts +205 -205
  5. package/dist/common/src/backend-function.schemas.d.ts +3 -3
  6. package/dist/common/src/backend-function.types.d.ts +7 -7
  7. package/dist/common/src/backend-run.types.d.ts +66 -66
  8. package/dist/common/src/bundle-api.types.d.ts +64 -64
  9. package/dist/common/src/bundle-data.types.d.ts +46 -46
  10. package/dist/common/src/communication.types.d.ts +4 -4
  11. package/dist/common/src/context.types.d.ts +31 -31
  12. package/dist/common/src/document.types.d.ts +35 -35
  13. package/dist/common/src/graphql.context.d.ts +6 -6
  14. package/dist/common/src/graphql.types.d.ts +16 -16
  15. package/dist/common/src/http-status.enum.d.ts +50 -50
  16. package/dist/common/src/index.d.ts +49 -49
  17. package/dist/common/src/integration.types.d.ts +316 -319
  18. package/dist/common/src/logger.types.d.ts +21 -21
  19. package/dist/common/src/metrics.types.d.ts +58 -58
  20. package/dist/common/src/mutation.context.d.ts +10 -10
  21. package/dist/common/src/mutation.schemas.d.ts +5 -5
  22. package/dist/common/src/mutation.types.d.ts +72 -72
  23. package/dist/common/src/named-query.context.d.ts +4 -4
  24. package/dist/common/src/named-query.schemas.d.ts +3 -3
  25. package/dist/common/src/named-query.types.d.ts +9 -9
  26. package/dist/common/src/query/index.d.ts +2 -2
  27. package/dist/common/src/query/query-context.d.ts +37 -37
  28. package/dist/common/src/query/simple-query-builder.d.ts +90 -90
  29. package/dist/common/src/query.schemas.d.ts +5 -5
  30. package/dist/common/src/query.types.d.ts +118 -118
  31. package/dist/common/src/regions.d.ts +22 -22
  32. package/dist/common/src/schema/schema.types.d.ts +54 -54
  33. package/dist/common/src/secret.schemas.d.ts +6 -6
  34. package/dist/common/src/secret.types.d.ts +40 -40
  35. package/dist/common/src/security.types.d.ts +3 -3
  36. package/dist/common/src/socket.schemas.d.ts +3 -3
  37. package/dist/common/src/socket.types.d.ts +68 -68
  38. package/dist/common/src/time-units.d.ts +5 -5
  39. package/dist/common/src/trigger.types.d.ts +15 -15
  40. package/dist/common/src/types.d.ts +15 -15
  41. package/dist/common/src/utils/array.d.ts +8 -8
  42. package/dist/common/src/utils/assert.d.ts +8 -8
  43. package/dist/common/src/utils/error.d.ts +4 -4
  44. package/dist/common/src/utils/http.d.ts +2 -2
  45. package/dist/common/src/utils/id.d.ts +2 -2
  46. package/dist/common/src/utils/lock.manager.d.ts +14 -14
  47. package/dist/common/src/utils/nullish.d.ts +1 -1
  48. package/dist/common/src/utils/object.d.ts +6 -6
  49. package/dist/common/src/utils/serialization.d.ts +6 -6
  50. package/dist/common/src/utils/transforms.d.ts +18 -18
  51. package/dist/common/src/utils/validation.d.ts +30 -30
  52. package/dist/common/src/webhook-response.d.ts +7 -7
  53. package/dist/index.js +1 -1
  54. package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -1239
  55. package/dist/typescript-client/src/api.manager.d.ts +14 -14
  56. package/dist/typescript-client/src/backend-function.manager.d.ts +13 -13
  57. package/dist/typescript-client/src/collection-reference.d.ts +53 -53
  58. package/dist/typescript-client/src/collection-reference.factory.d.ts +16 -16
  59. package/dist/typescript-client/src/data.manager.d.ts +166 -166
  60. package/dist/typescript-client/src/destruct.manager.d.ts +12 -12
  61. package/dist/typescript-client/src/document-identity.service.d.ts +12 -12
  62. package/dist/typescript-client/src/document-reference.d.ts +100 -100
  63. package/dist/typescript-client/src/document-reference.factory.d.ts +9 -9
  64. package/dist/typescript-client/src/document-store.d.ts +11 -11
  65. package/dist/typescript-client/src/graphql-client.d.ts +12 -12
  66. package/dist/typescript-client/src/graphql-client.factory.d.ts +9 -9
  67. package/dist/typescript-client/src/index.d.ts +7 -7
  68. package/dist/typescript-client/src/mutation/mutation-sender.d.ts +11 -11
  69. package/dist/typescript-client/src/mutation/mutation.spec.d.ts +1 -1
  70. package/dist/typescript-client/src/named-query.manager.d.ts +13 -13
  71. package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +71 -71
  72. package/dist/typescript-client/src/query/query-builder.factory.d.ts +67 -60
  73. package/dist/typescript-client/src/query/query-subscription.manager.d.ts +59 -59
  74. package/dist/typescript-client/src/query/query-subscription.manager.spec.d.ts +1 -1
  75. package/dist/typescript-client/src/query/query.spec.d.ts +1 -1
  76. package/dist/typescript-client/src/query/query.types.d.ts +14 -14
  77. package/dist/typescript-client/src/rpc.manager.d.ts +30 -30
  78. package/dist/typescript-client/src/socket.manager.d.ts +27 -27
  79. package/dist/typescript-client/src/squid.d.ts +173 -173
  80. package/dist/typescript-client/src/state/action.applier.d.ts +7 -7
  81. package/dist/typescript-client/src/state/actions.d.ts +29 -29
  82. package/dist/typescript-client/src/state/path_trie.d.ts +27 -27
  83. package/dist/typescript-client/src/state/state.service.d.ts +22 -22
  84. package/dist/typescript-client/src/state/state.service.spec.d.ts +1 -1
  85. package/dist/typescript-client/src/testing/fake-rpc.manager.d.ts +20 -20
  86. package/dist/typescript-client/src/testing/fake-socket.manager.d.ts +9 -9
  87. package/dist/typescript-client/src/testing/setup-tests.d.ts +1 -1
  88. package/dist/typescript-client/src/testing/squid-env-setup.d.ts +79 -79
  89. package/dist/typescript-client/src/types.d.ts +2 -2
  90. package/package.json +1 -1
@@ -1,100 +1,100 @@
1
- import { DocumentData, Paths } from '@squidcloud/common';
2
- import { Observable } from 'rxjs';
3
- import { TransactionId } from './types';
4
- /**
5
- * Holds a reference to a document. A document reference is a reference to a specific record in a collection. You can
6
- * use it to read or write data to the document. A document can refer to a row in a table in a relational database or a
7
- * document in a NoSQL database. Additionally, a document reference can refer to a non-existent document, which you can
8
- * use to create a new document.
9
- *
10
- * Read more about document references in the
11
- * [documentation]{@link https://docs.squid.cloud/docs/client-sdk/document-reference}.
12
- * @typeParam T The type of the document data.
13
- */
14
- export declare class DocumentReference<T extends DocumentData = any> {
15
- private _squidDocId;
16
- private readonly dataManager;
17
- private readonly queryBuilderFactory;
18
- /** A string that uniquely identifies this document reference. */
19
- refId: string;
20
- /**
21
- * Returns the document data. Throws an error if the document does not exist.
22
- *
23
- * @returns The document data.
24
- * @throws Error if the document does not exist.
25
- */
26
- get data(): T;
27
- /**
28
- * Returns whether data has been populated for this document reference. Data
29
- * will not present if a document has not been queried, does not exist, or
30
- * has been deleted.
31
- *
32
- * @returns Whether the document has data.
33
- */
34
- get hasData(): boolean;
35
- /**
36
- * Returns a document reference with the latest data from the server or undefined if the document does not exist on
37
- * the server.
38
- *
39
- * @returns A document reference with the latest data from the server or undefined if the document does not exist on
40
- * the server.
41
- */
42
- snapshot(): Promise<DocumentReference<T> | undefined>;
43
- /**
44
- * Returns an observable that emits a document reference with the latest data from the server or undefined if the
45
- * document is deleted or does not exist on the server.
46
- *
47
- * @returns An observable that emits a document reference with the latest data from the server or undefined if the
48
- * document is deleted or does not exist on the server.
49
- */
50
- snapshots(): Observable<DocumentReference<T> | undefined>;
51
- /**
52
- * Returns whether the locally available version of the document may not be the latest version on the server.
53
- *
54
- * @returns Whether the locally available version of the document may not be the latest version on the server.
55
- */
56
- isDirty(): boolean;
57
- private isTracked;
58
- /**
59
- * Updates the document with the given data.
60
- * The `update` will be reflected optimistically locally and will be applied to the server later.
61
- * If a transactionId is provided, the `update` will be applied to the server as an atomic operation together with
62
- * the rest of the operations in the transaction and the `update` will not reflect locally until the transaction is
63
- * completed locally.
64
- *
65
- * The returned promise will resolve once the `update` has been applied to the server or immediately if the `update`
66
- * is part of a transaction.
67
- *
68
- * @param data The data to update - can be partial.
69
- */
70
- update(data: Partial<Record<Paths<T>, any>>, transactionId?: TransactionId): Promise<void>;
71
- /**
72
- * Similar to {@link update}, but only updates the given path.
73
- */
74
- setInPath(path: Paths<T>, value: any, transactionId?: TransactionId): Promise<void>;
75
- /** Similar to `update`, but only deletes the given path. */
76
- deleteInPath(path: Paths<T>, transactionId?: TransactionId): Promise<void>;
77
- /**
78
- * Inserts the document with the given data. If the document already exists, the operation will be treated as
79
- * `upsert`. The `insert` will be reflected optimistically locally and will be applied to the server later. If a
80
- * transactionId is provided, the `insert` will be applied to the server as an atomic operation together with the
81
- * rest
82
- * of the operations in the transaction and the `insert` will not reflect locally until the transaction is completed
83
- * locally.
84
- *
85
- * The returned promise will resolve once the `insert` has been applied to the server or immediately if the `insert`
86
- * is part of a transaction.
87
- */
88
- insert(data: T, transactionId?: TransactionId): Promise<void>;
89
- /**
90
- * Deletes the document.
91
- * The `delete` will be reflected optimistically locally and will be applied to the server later.
92
- * If a transactionId is provided, the `delete` will be applied to the server as an atomic operation together with
93
- * the rest of the operations in the transaction and the `delete` will not reflect locally until the transaction is
94
- * completed locally.
95
- *
96
- * The returned promise will resolve once the `delete` has been applied to the server or immediately if the `delete`
97
- * is part of a transaction.
98
- */
99
- delete(transactionId?: TransactionId): Promise<void>;
100
- }
1
+ import { DocumentData, Paths } from '@squidcloud/common';
2
+ import { Observable } from 'rxjs';
3
+ import { TransactionId } from './types';
4
+ /**
5
+ * Holds a reference to a document. A document reference is a reference to a specific record in a collection. You can
6
+ * use it to read or write data to the document. A document can refer to a row in a table in a relational database or a
7
+ * document in a NoSQL database. Additionally, a document reference can refer to a non-existent document, which you can
8
+ * use to create a new document.
9
+ *
10
+ * Read more about document references in the
11
+ * [documentation]{@link https://docs.squid.cloud/docs/client-sdk/document-reference}.
12
+ * @typeParam T The type of the document data.
13
+ */
14
+ export declare class DocumentReference<T extends DocumentData = any> {
15
+ private _squidDocId;
16
+ private readonly dataManager;
17
+ private readonly queryBuilderFactory;
18
+ /** A string that uniquely identifies this document reference. */
19
+ refId: string;
20
+ /**
21
+ * Returns the document data. Throws an error if the document does not exist.
22
+ *
23
+ * @returns The document data.
24
+ * @throws Error if the document does not exist.
25
+ */
26
+ get data(): T;
27
+ /**
28
+ * Returns whether data has been populated for this document reference. Data
29
+ * will not present if a document has not been queried, does not exist, or
30
+ * has been deleted.
31
+ *
32
+ * @returns Whether the document has data.
33
+ */
34
+ get hasData(): boolean;
35
+ /**
36
+ * Returns a document reference with the latest data from the server or undefined if the document does not exist on
37
+ * the server.
38
+ *
39
+ * @returns A document reference with the latest data from the server or undefined if the document does not exist on
40
+ * the server.
41
+ */
42
+ snapshot(): Promise<DocumentReference<T> | undefined>;
43
+ /**
44
+ * Returns an observable that emits a document reference with the latest data from the server or undefined if the
45
+ * document is deleted or does not exist on the server.
46
+ *
47
+ * @returns An observable that emits a document reference with the latest data from the server or undefined if the
48
+ * document is deleted or does not exist on the server.
49
+ */
50
+ snapshots(): Observable<DocumentReference<T> | undefined>;
51
+ /**
52
+ * Returns whether the locally available version of the document may not be the latest version on the server.
53
+ *
54
+ * @returns Whether the locally available version of the document may not be the latest version on the server.
55
+ */
56
+ isDirty(): boolean;
57
+ private isTracked;
58
+ /**
59
+ * Updates the document with the given data.
60
+ * The `update` will be reflected optimistically locally and will be applied to the server later.
61
+ * If a transactionId is provided, the `update` will be applied to the server as an atomic operation together with
62
+ * the rest of the operations in the transaction and the `update` will not reflect locally until the transaction is
63
+ * completed locally.
64
+ *
65
+ * The returned promise will resolve once the `update` has been applied to the server or immediately if the `update`
66
+ * is part of a transaction.
67
+ *
68
+ * @param data The data to update - can be partial.
69
+ */
70
+ update(data: Partial<Record<Paths<T>, any>>, transactionId?: TransactionId): Promise<void>;
71
+ /**
72
+ * Similar to {@link update}, but only updates the given path.
73
+ */
74
+ setInPath(path: Paths<T>, value: any, transactionId?: TransactionId): Promise<void>;
75
+ /** Similar to `update`, but only deletes the given path. */
76
+ deleteInPath(path: Paths<T>, transactionId?: TransactionId): Promise<void>;
77
+ /**
78
+ * Inserts the document with the given data. If the document already exists, the operation will be treated as
79
+ * `upsert`. The `insert` will be reflected optimistically locally and will be applied to the server later. If a
80
+ * transactionId is provided, the `insert` will be applied to the server as an atomic operation together with the
81
+ * rest
82
+ * of the operations in the transaction and the `insert` will not reflect locally until the transaction is completed
83
+ * locally.
84
+ *
85
+ * The returned promise will resolve once the `insert` has been applied to the server or immediately if the `insert`
86
+ * is part of a transaction.
87
+ */
88
+ insert(data: T, transactionId?: TransactionId): Promise<void>;
89
+ /**
90
+ * Deletes the document.
91
+ * The `delete` will be reflected optimistically locally and will be applied to the server later.
92
+ * If a transactionId is provided, the `delete` will be applied to the server as an atomic operation together with
93
+ * the rest of the operations in the transaction and the `delete` will not reflect locally until the transaction is
94
+ * completed locally.
95
+ *
96
+ * The returned promise will resolve once the `delete` has been applied to the server or immediately if the `delete`
97
+ * is part of a transaction.
98
+ */
99
+ delete(transactionId?: TransactionId): Promise<void>;
100
+ }
@@ -1,9 +1,9 @@
1
- import { SquidDocId } from '@squidcloud/common';
2
- import { DataManager } from './data.manager';
3
- import { DocumentReference } from './document-reference';
4
- import { QueryBuilderFactory } from './query/query-builder.factory';
5
- export declare class DocumentReferenceFactory {
6
- private dataManager;
7
- create(squidDocId: SquidDocId, queryBuilderFactory: QueryBuilderFactory): DocumentReference;
8
- setDataManager(dataManager: DataManager): void;
9
- }
1
+ import { SquidDocId } from '@squidcloud/common';
2
+ import { DataManager } from './data.manager';
3
+ import { DocumentReference } from './document-reference';
4
+ import { QueryBuilderFactory } from './query/query-builder.factory';
5
+ export declare class DocumentReferenceFactory {
6
+ private dataManager;
7
+ create(squidDocId: SquidDocId, queryBuilderFactory: QueryBuilderFactory): DocumentReference;
8
+ setDataManager(dataManager: DataManager): void;
9
+ }
@@ -1,11 +1,11 @@
1
- import { Query, SquidDocId, SquidDocument } from '@squidcloud/common';
2
- export declare class DocumentStore {
3
- private readonly squidDocIdToDoc;
4
- saveDocument(squidDocId: SquidDocId, properties: SquidDocument | undefined): SquidDocument | undefined;
5
- hasData(squidDocId: SquidDocId): boolean;
6
- getDocument(squidDocId: SquidDocId): SquidDocument;
7
- getDocumentOrUndefined(squidDocId: SquidDocId): SquidDocument | undefined;
8
- sortAndLimitDocs(docIdSet: Set<SquidDocId> | undefined, query: Query): Array<SquidDocument>;
9
- private removeInternalProperties;
10
- migrateDocId(squidDocId: SquidDocId, newSquidDocId: SquidDocId): void;
11
- }
1
+ import { Query, SquidDocId, SquidDocument } from '@squidcloud/common';
2
+ export declare class DocumentStore {
3
+ private readonly squidDocIdToDoc;
4
+ saveDocument(squidDocId: SquidDocId, properties: SquidDocument | undefined): SquidDocument | undefined;
5
+ hasData(squidDocId: SquidDocId): boolean;
6
+ getDocument(squidDocId: SquidDocId): SquidDocument;
7
+ getDocumentOrUndefined(squidDocId: SquidDocId): SquidDocument | undefined;
8
+ sortAndLimitDocs(docIdSet: Set<SquidDocId> | undefined, query: Query): Array<SquidDocument>;
9
+ private removeInternalProperties;
10
+ migrateDocId(squidDocId: SquidDocId, newSquidDocId: SquidDocId): void;
11
+ }
@@ -1,12 +1,12 @@
1
- import { GraphQLRequest, IntegrationId } from '@squidcloud/common';
2
- import { RpcManager } from './rpc.manager';
3
- /** A GraphQL client that can be used to query and mutate data. */
4
- export declare class GraphQLClient {
5
- private readonly rpcManager;
6
- private readonly client;
7
- constructor(rpcManager: RpcManager, integrationId: IntegrationId);
8
- /** Executes a GraphQL query and returns a promise with the result. */
9
- query<T = any>(request: GraphQLRequest): Promise<T>;
10
- /** Executes a GraphQL mutation and returns a promise with the result. */
11
- mutate<T = Record<string, any>>(request: GraphQLRequest): Promise<T | null | undefined>;
12
- }
1
+ import { GraphQLRequest, IntegrationId } from '@squidcloud/common';
2
+ import { RpcManager } from './rpc.manager';
3
+ /** A GraphQL client that can be used to query and mutate data. */
4
+ export declare class GraphQLClient {
5
+ private readonly rpcManager;
6
+ private readonly client;
7
+ constructor(rpcManager: RpcManager, integrationId: IntegrationId);
8
+ /** Executes a GraphQL query and returns a promise with the result. */
9
+ query<T = any>(request: GraphQLRequest): Promise<T>;
10
+ /** Executes a GraphQL mutation and returns a promise with the result. */
11
+ mutate<T = Record<string, any>>(request: GraphQLRequest): Promise<T | null | undefined>;
12
+ }
@@ -1,9 +1,9 @@
1
- import { IntegrationId } from '@squidcloud/common';
2
- import { GraphQLClient } from './graphql-client';
3
- import { RpcManager } from './rpc.manager';
4
- export declare class GraphQLClientFactory {
5
- private readonly rpcManager;
6
- private readonly clientsMap;
7
- constructor(rpcManager: RpcManager);
8
- get(integrationId: IntegrationId): GraphQLClient;
9
- }
1
+ import { IntegrationId } from '@squidcloud/common';
2
+ import { GraphQLClient } from './graphql-client';
3
+ import { RpcManager } from './rpc.manager';
4
+ export declare class GraphQLClientFactory {
5
+ private readonly rpcManager;
6
+ private readonly clientsMap;
7
+ constructor(rpcManager: RpcManager);
8
+ get(integrationId: IntegrationId): GraphQLClient;
9
+ }
@@ -1,7 +1,7 @@
1
- export { CollectionReference } from './collection-reference';
2
- export { DocumentReference } from './document-reference';
3
- export { JoinQueryBuilder } from './query/join-query-builder.factory';
4
- export { Changes, QueryBuilder } from './query/query-builder.factory';
5
- export { Alias, JoinCondition } from './query/query.types';
6
- export { Squid, SquidOptions } from './squid';
7
- export { TransactionId } from './types';
1
+ export { CollectionReference } from './collection-reference';
2
+ export { DocumentReference } from './document-reference';
3
+ export { JoinQueryBuilder } from './query/join-query-builder.factory';
4
+ export { Changes, QueryBuilder } from './query/query-builder.factory';
5
+ export { Alias, JoinCondition } from './query/query.types';
6
+ export { Squid, SquidOptions } from './squid';
7
+ export { TransactionId } from './types';
@@ -1,11 +1,11 @@
1
- import { ClientId, IntegrationId, LockManager, MutateResponse, Mutation } from '@squidcloud/common';
2
- import { QuerySubscriptionManager } from '../query/query-subscription.manager';
3
- import { RpcManager } from '../rpc.manager';
4
- export declare class MutationSender {
5
- private readonly clientId;
6
- private readonly rpcManager;
7
- private readonly lockManager;
8
- private readonly querySubscriptionManager;
9
- constructor(clientId: ClientId, rpcManager: RpcManager, lockManager: LockManager, querySubscriptionManager: QuerySubscriptionManager);
10
- sendMutations(mutations: Array<Mutation>, integrationId: IntegrationId): Promise<MutateResponse>;
11
- }
1
+ import { ClientId, IntegrationId, LockManager, MutateResponse, Mutation } from '@squidcloud/common';
2
+ import { QuerySubscriptionManager } from '../query/query-subscription.manager';
3
+ import { RpcManager } from '../rpc.manager';
4
+ export declare class MutationSender {
5
+ private readonly clientId;
6
+ private readonly rpcManager;
7
+ private readonly lockManager;
8
+ private readonly querySubscriptionManager;
9
+ constructor(clientId: ClientId, rpcManager: RpcManager, lockManager: LockManager, querySubscriptionManager: QuerySubscriptionManager);
10
+ sendMutations(mutations: Array<Mutation>, integrationId: IntegrationId): Promise<MutateResponse>;
11
+ }
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,13 +1,13 @@
1
- import { ClientId, IntegrationId, QueryName } from '@squidcloud/common';
2
- import { Observable } from 'rxjs';
3
- import { RpcManager } from './rpc.manager';
4
- import { SocketManager } from './socket.manager';
5
- export declare class NamedQueryManager {
6
- private readonly clientId;
7
- private readonly rpcManager;
8
- private readonly socketManager;
9
- private readonly ongoingNamedQueryExecutions;
10
- constructor(clientId: ClientId, rpcManager: RpcManager, socketManager: SocketManager);
11
- executeNamedQueryAndSubscribe<T>(integrationId: IntegrationId, queryName: QueryName, params: Record<string, any>): Observable<T>;
12
- private handleNamedQueryResponse;
13
- }
1
+ import { ClientId, IntegrationId, QueryName } from '@squidcloud/common';
2
+ import { Observable } from 'rxjs';
3
+ import { RpcManager } from './rpc.manager';
4
+ import { SocketManager } from './socket.manager';
5
+ export declare class NamedQueryManager {
6
+ private readonly clientId;
7
+ private readonly rpcManager;
8
+ private readonly socketManager;
9
+ private readonly ongoingNamedQueryExecutions;
10
+ constructor(clientId: ClientId, rpcManager: RpcManager, socketManager: SocketManager);
11
+ executeNamedQueryAndSubscribe<T>(integrationId: IntegrationId, queryName: QueryName, params: Record<string, any>): Observable<T>;
12
+ private handleNamedQueryResponse;
13
+ }
@@ -1,71 +1,71 @@
1
- import { DocumentData, FieldName, Operator, PrimitiveFieldType } from '@squidcloud/common';
2
- import { Observable } from 'rxjs';
3
- import { DocumentReference } from '../document-reference';
4
- import { Alias } from './query.types';
5
- /**
6
- * A query builder that can participate in a join.
7
- * To learn more about join queries, see {@link https://docs.squid.cloud/docs/client-sdk/queries#joining-data-across-collections-and-integrations}.
8
- */
9
- export declare class JoinQueryBuilder<DocumentType extends DocumentData, MyAlias extends Alias, ReturnType extends Record<MyAlias, DocumentReference<DocumentType> | undefined>> {
10
- private readonly collectionName;
11
- private readonly integrationId;
12
- private readonly querySubscriptionManager;
13
- private readonly documentReferenceFactory;
14
- private readonly alias;
15
- private readonly joinQueryBuilderFactory;
16
- private readonly queryBuilderFactory;
17
- private readonly simpleQueryBuilder;
18
- private readonly joins;
19
- /** Record that maps the right alias to the left condition */
20
- private readonly joinConditions;
21
- /**
22
- * Adds a condition to the query.
23
- *
24
- * @param fieldName The name of the field to query
25
- * @param operator The operator to use
26
- * @param value The value to compare against
27
- * @returns The query builder
28
- */
29
- where(fieldName: (keyof DocumentType & FieldName) | string, operator: Operator | 'in' | 'not in', value: PrimitiveFieldType | Array<PrimitiveFieldType>): this;
30
- /**
31
- * Sets a limit to the number of results returned by the query. The maximum limit is 1000 and this is the default if
32
- * none is provided.
33
- *
34
- * @param limit The maximum number of results to return
35
- * @returns The query builder
36
- */
37
- limit(limit: number): this;
38
- /**
39
- * Adds a sort order to the query. You can add multiple sort orders to the query. The order in which you add them
40
- * determines the order in which they are applied.
41
- * @param fieldName The name of the field to sort by
42
- * @param asc Whether to sort in ascending order. Defaults to true.
43
- * @returns The query builder
44
- */
45
- sortBy(fieldName: keyof DocumentType & FieldName, asc?: boolean): this;
46
- /**
47
- * Joins this query with another join query and return a new query builder that can be used to query the joined
48
- * documents.
49
- * @param queryBuilder The query builder to join with
50
- * @param leftFieldName The name of the field on the left side of the join
51
- * @param rightFieldName The name of the field on the right side of the join
52
- * @returns A new query builder that can be used to query the joined documents
53
- */
54
- join<J extends DocumentData, RightAlias extends Alias, RightReturnType extends Record<RightAlias, DocumentReference<J> | undefined>>(queryBuilder: JoinQueryBuilder<J, RightAlias, RightReturnType>, leftFieldName: keyof DocumentType & FieldName, rightFieldName: keyof J & FieldName): JoinQueryBuilder<DocumentType, MyAlias, ReturnType & Partial<RightReturnType>>;
55
- /**
56
- * Returns a promise that resolves to the query results.
57
- *
58
- * @returns A promise that resolves to the query results
59
- */
60
- snapshot(): Promise<Array<ReturnType>>;
61
- /**
62
- * Returns an observable that emits the query results and updates whenever the query results change unless
63
- * `subscribe=false` is provided.
64
- *
65
- * Important: Make sure to unsubscribe from the observable when you are done with it.
66
- *
67
- * @param subscribe Whether to subscribe to the query. Defaults to true.
68
- * @returns An observable for the query results
69
- */
70
- snapshots(subscribe?: boolean): Observable<Array<ReturnType>>;
71
- }
1
+ import { DocumentData, FieldName, Operator, PrimitiveFieldType } from '@squidcloud/common';
2
+ import { Observable } from 'rxjs';
3
+ import { DocumentReference } from '../document-reference';
4
+ import { Alias } from './query.types';
5
+ /**
6
+ * A query builder that can participate in a join.
7
+ * To learn more about join queries, see {@link https://docs.squid.cloud/docs/client-sdk/queries#joining-data-across-collections-and-integrations}.
8
+ */
9
+ export declare class JoinQueryBuilder<DocumentType extends DocumentData, MyAlias extends Alias, ReturnType extends Record<MyAlias, DocumentReference<DocumentType> | undefined>> {
10
+ private readonly collectionName;
11
+ private readonly integrationId;
12
+ private readonly querySubscriptionManager;
13
+ private readonly documentReferenceFactory;
14
+ private readonly alias;
15
+ private readonly joinQueryBuilderFactory;
16
+ private readonly queryBuilderFactory;
17
+ private readonly simpleQueryBuilder;
18
+ private readonly joins;
19
+ /** Record that maps the right alias to the left condition */
20
+ private readonly joinConditions;
21
+ /**
22
+ * Adds a condition to the query.
23
+ *
24
+ * @param fieldName The name of the field to query
25
+ * @param operator The operator to use
26
+ * @param value The value to compare against
27
+ * @returns The query builder
28
+ */
29
+ where(fieldName: (keyof DocumentType & FieldName) | string, operator: Operator | 'in' | 'not in', value: PrimitiveFieldType | Array<PrimitiveFieldType>): this;
30
+ /**
31
+ * Sets a limit to the number of results returned by the query. The maximum limit is 1000 and this is the default if
32
+ * none is provided.
33
+ *
34
+ * @param limit The maximum number of results to return
35
+ * @returns The query builder
36
+ */
37
+ limit(limit: number): this;
38
+ /**
39
+ * Adds a sort order to the query. You can add multiple sort orders to the query. The order in which you add them
40
+ * determines the order in which they are applied.
41
+ * @param fieldName The name of the field to sort by
42
+ * @param asc Whether to sort in ascending order. Defaults to true.
43
+ * @returns The query builder
44
+ */
45
+ sortBy(fieldName: keyof DocumentType & FieldName, asc?: boolean): this;
46
+ /**
47
+ * Joins this query with another join query and return a new query builder that can be used to query the joined
48
+ * documents.
49
+ * @param queryBuilder The query builder to join with
50
+ * @param leftFieldName The name of the field on the left side of the join
51
+ * @param rightFieldName The name of the field on the right side of the join
52
+ * @returns A new query builder that can be used to query the joined documents
53
+ */
54
+ join<J extends DocumentData, RightAlias extends Alias, RightReturnType extends Record<RightAlias, DocumentReference<J> | undefined>>(queryBuilder: JoinQueryBuilder<J, RightAlias, RightReturnType>, leftFieldName: keyof DocumentType & FieldName, rightFieldName: keyof J & FieldName): JoinQueryBuilder<DocumentType, MyAlias, ReturnType & Partial<RightReturnType>>;
55
+ /**
56
+ * Returns a promise that resolves to the query results.
57
+ *
58
+ * @returns A promise that resolves to the query results
59
+ */
60
+ snapshot(): Promise<Array<ReturnType>>;
61
+ /**
62
+ * Returns an observable that emits the query results and updates whenever the query results change unless
63
+ * `subscribe=false` is provided.
64
+ *
65
+ * Important: Make sure to unsubscribe from the observable when you are done with it.
66
+ *
67
+ * @param subscribe Whether to subscribe to the query. Defaults to true.
68
+ * @returns An observable for the query results
69
+ */
70
+ snapshots(subscribe?: boolean): Observable<Array<ReturnType>>;
71
+ }
@@ -1,60 +1,67 @@
1
- import { CollectionName, DocumentData, IntegrationId, SimpleQueryBuilder, SquidDocId } from '@squidcloud/common';
2
- import { Observable } from 'rxjs';
3
- import DocumentIdentityService from '../document-identity.service';
4
- import { DocumentReference } from '../document-reference';
5
- import { DocumentReferenceFactory } from '../document-reference.factory';
6
- import { QuerySubscriptionManager } from './query-subscription.manager';
7
- export declare class QueryBuilderFactory {
8
- private readonly querySubscriptionManager;
9
- private readonly documentReferenceFactory;
10
- private readonly documentIdentityService;
11
- constructor(querySubscriptionManager: QuerySubscriptionManager, documentReferenceFactory: DocumentReferenceFactory, documentIdentityService: DocumentIdentityService);
12
- getForDocument<DocumentType extends DocumentData>(squidDocId: SquidDocId): QueryBuilder<DocumentType>;
13
- get<DocumentType extends DocumentData>(collectionName: CollectionName, integrationId: IntegrationId): QueryBuilder<DocumentType>;
14
- }
15
- /** A query builder that can be used to build a query that returns a list of documents. */
16
- export declare class QueryBuilder<DocumentType extends DocumentData> extends SimpleQueryBuilder<DocumentType> {
17
- private readonly querySubscriptionManager;
18
- private readonly documentReferenceFactory;
19
- private readonly queryBuilderFactory;
20
- private readonly documentIdentityService;
21
- /**
22
- * Returns a promise that resolves to the query results.
23
- *
24
- * @returns A promise that resolves to the query results.
25
- */
26
- snapshot(): Promise<Array<DocumentReference<DocumentType>>>;
27
- /**
28
- * Returns an observable that emits the query results and updates whenever the query results change unless
29
- * `subscribe=false` is provided.
30
- *
31
- * Important: Make sure to unsubscribe from the observable when you are done with it.
32
- *
33
- * @param subscribe Whether to subscribe to changes to the query results. Defaults to `true`.
34
- * @returns An observable for the query results.
35
- */
36
- snapshots(subscribe?: boolean): Observable<Array<DocumentReference<DocumentType>>>;
37
- /**
38
- * Similar to `snapshots` but returns an observable that emits the changes to the query results. The first result
39
- * will contain only inserts.
40
- *
41
- * @returns An observable for the query changes.
42
- */
43
- changes(): Observable<Changes<DocumentType>>;
44
- /**
45
- * A unique hash for the query. Identical queries should return the same hash
46
- * value.
47
- *
48
- * @returns The query's hash string.
49
- */
50
- get hash(): string;
51
- }
52
- /** Describes the changes to a query result. */
53
- export interface Changes<DocumentType extends DocumentData> {
54
- /** The newly inserted documents to the query result */
55
- inserts: Array<DocumentReference<DocumentType>>;
56
- /** The documents that were updated in the query result */
57
- updates: Array<DocumentReference<DocumentType>>;
58
- /** The actual document data that was deleted from the query result */
59
- deletes: Array<DocumentType>;
60
- }
1
+ import { CollectionName, DocumentData, IntegrationId, SimpleQueryBuilder, SquidDocId } from '@squidcloud/common';
2
+ import { Observable } from 'rxjs';
3
+ import DocumentIdentityService from '../document-identity.service';
4
+ import { DocumentReference } from '../document-reference';
5
+ import { DocumentReferenceFactory } from '../document-reference.factory';
6
+ import { QuerySubscriptionManager } from './query-subscription.manager';
7
+ export declare class QueryBuilderFactory {
8
+ private readonly querySubscriptionManager;
9
+ private readonly documentReferenceFactory;
10
+ private readonly documentIdentityService;
11
+ constructor(querySubscriptionManager: QuerySubscriptionManager, documentReferenceFactory: DocumentReferenceFactory, documentIdentityService: DocumentIdentityService);
12
+ getForDocument<DocumentType extends DocumentData>(squidDocId: SquidDocId): QueryBuilder<DocumentType>;
13
+ get<DocumentType extends DocumentData>(collectionName: CollectionName, integrationId: IntegrationId): QueryBuilder<DocumentType>;
14
+ }
15
+ /** A query builder that can be used to build a query that returns a list of documents. */
16
+ export declare class QueryBuilder<DocumentType extends DocumentData> extends SimpleQueryBuilder<DocumentType> {
17
+ private readonly querySubscriptionManager;
18
+ private readonly documentReferenceFactory;
19
+ private readonly queryBuilderFactory;
20
+ private readonly documentIdentityService;
21
+ /**
22
+ * Returns a promise that resolves to the query results.
23
+ *
24
+ * @returns A promise that resolves to the query results.
25
+ */
26
+ snapshot(): Promise<Array<DocumentReference<DocumentType>>>;
27
+ /**
28
+ * Returns an observable that emits the query results and updates whenever the query results change unless
29
+ * `subscribe=false` is provided.
30
+ *
31
+ * Important: Make sure to unsubscribe from the observable when you are done with it.
32
+ *
33
+ * @param subscribe Whether to subscribe to changes to the query results. Defaults to `true`.
34
+ * @returns An observable for the query results.
35
+ */
36
+ snapshots(subscribe?: boolean): Observable<Array<DocumentReference<DocumentType>>>;
37
+ /**
38
+ * Similar to `snapshots` but returns an observable that emits the changes to the query results. The first result
39
+ * will contain only inserts.
40
+ *
41
+ * @returns An observable for the query changes.
42
+ */
43
+ changes(): Observable<Changes<DocumentType>>;
44
+ /**
45
+ * A unique hash for the query. Identical queries should return the same hash
46
+ * value.
47
+ *
48
+ * @returns The query's hash string.
49
+ */
50
+ get hash(): string;
51
+ }
52
+ /** Describes the changes to a query result. */
53
+ export declare class Changes<DocumentType extends DocumentData> {
54
+ /** The newly inserted documents to the query result */
55
+ readonly inserts: Array<DocumentReference<DocumentType>>;
56
+ /** The documents that were updated in the query result */
57
+ readonly updates: Array<DocumentReference<DocumentType>>;
58
+ /** The actual document data that was deleted from the query result */
59
+ readonly deletes: Array<DocumentType>;
60
+ constructor(
61
+ /** The newly inserted documents to the query result */
62
+ inserts: Array<DocumentReference<DocumentType>>,
63
+ /** The documents that were updated in the query result */
64
+ updates: Array<DocumentReference<DocumentType>>,
65
+ /** The actual document data that was deleted from the query result */
66
+ deletes: Array<DocumentType>);
67
+ }