@squidcloud/client 1.0.63 → 1.0.65

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 (100) hide show
  1. package/dist/common/src/ai-assistant.context.d.ts +11 -11
  2. package/dist/common/src/ai-assistant.schemas.d.ts +210 -210
  3. package/dist/common/src/ai-assistant.types.d.ts +81 -81
  4. package/dist/common/src/api-call.context.d.ts +12 -12
  5. package/dist/common/src/api.types.d.ts +24 -24
  6. package/dist/common/src/application.schemas.d.ts +1060 -1060
  7. package/dist/common/src/application.types.d.ts +224 -224
  8. package/dist/common/src/auth.types.d.ts +4 -4
  9. package/dist/common/src/backend-function.schemas.d.ts +3 -3
  10. package/dist/common/src/backend-function.types.d.ts +7 -7
  11. package/dist/common/src/backend-run.types.d.ts +53 -53
  12. package/dist/common/src/bundle-api.types.d.ts +68 -68
  13. package/dist/common/src/bundle-data.types.d.ts +59 -59
  14. package/dist/common/src/communication.types.d.ts +4 -4
  15. package/dist/common/src/context.types.d.ts +32 -32
  16. package/dist/common/src/distributed-lock.context.d.ts +5 -5
  17. package/dist/common/src/document.types.d.ts +37 -37
  18. package/dist/common/src/graphql.context.d.ts +6 -6
  19. package/dist/common/src/graphql.types.d.ts +11 -11
  20. package/dist/common/src/http-status.enum.d.ts +50 -50
  21. package/dist/common/src/index.d.ts +54 -54
  22. package/dist/common/src/integrations/ai_assistant.types.d.ts +30 -30
  23. package/dist/common/src/integrations/api.types.d.ts +80 -80
  24. package/dist/common/src/integrations/auth.types.d.ts +22 -22
  25. package/dist/common/src/integrations/database.types.d.ts +236 -236
  26. package/dist/common/src/integrations/index.d.ts +97 -97
  27. package/dist/common/src/integrations/observability.types.d.ts +22 -22
  28. package/dist/common/src/logger.types.d.ts +21 -21
  29. package/dist/common/src/metrics.types.d.ts +58 -58
  30. package/dist/common/src/mutation.context.d.ts +10 -10
  31. package/dist/common/src/mutation.schemas.d.ts +5 -5
  32. package/dist/common/src/mutation.types.d.ts +72 -72
  33. package/dist/common/src/named-query.context.d.ts +4 -4
  34. package/dist/common/src/named-query.schemas.d.ts +3 -3
  35. package/dist/common/src/named-query.types.d.ts +9 -9
  36. package/dist/common/src/query/index.d.ts +2 -2
  37. package/dist/common/src/query/query-context.d.ts +37 -37
  38. package/dist/common/src/query/simple-query-builder.d.ts +137 -137
  39. package/dist/common/src/query.schemas.d.ts +5 -5
  40. package/dist/common/src/query.types.d.ts +118 -118
  41. package/dist/common/src/regions.d.ts +22 -22
  42. package/dist/common/src/schema/schema.types.d.ts +54 -54
  43. package/dist/common/src/secret.schemas.d.ts +6 -6
  44. package/dist/common/src/secret.types.d.ts +49 -49
  45. package/dist/common/src/security.types.d.ts +3 -3
  46. package/dist/common/src/socket.schemas.d.ts +3 -3
  47. package/dist/common/src/socket.types.d.ts +108 -108
  48. package/dist/common/src/time-units.d.ts +5 -5
  49. package/dist/common/src/trigger.types.d.ts +15 -15
  50. package/dist/common/src/types.d.ts +15 -15
  51. package/dist/common/src/utils/array.d.ts +8 -8
  52. package/dist/common/src/utils/assert.d.ts +8 -8
  53. package/dist/common/src/utils/error.d.ts +4 -4
  54. package/dist/common/src/utils/http.d.ts +2 -2
  55. package/dist/common/src/utils/id.d.ts +2 -2
  56. package/dist/common/src/utils/lock.manager.d.ts +14 -14
  57. package/dist/common/src/utils/nullish.d.ts +1 -1
  58. package/dist/common/src/utils/object.d.ts +6 -6
  59. package/dist/common/src/utils/serialization.d.ts +6 -6
  60. package/dist/common/src/utils/transforms.d.ts +18 -18
  61. package/dist/common/src/utils/url.d.ts +1 -1
  62. package/dist/common/src/utils/validation.d.ts +30 -30
  63. package/dist/common/src/webhook-response.d.ts +7 -7
  64. package/dist/index.js +1 -1
  65. package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -1239
  66. package/dist/typescript-client/src/ai-assistant-client.d.ts +66 -66
  67. package/dist/typescript-client/src/ai-client.factory.d.ts +13 -13
  68. package/dist/typescript-client/src/api.manager.d.ts +15 -15
  69. package/dist/typescript-client/src/auth.manager.d.ts +23 -23
  70. package/dist/typescript-client/src/backend-function.manager.d.ts +13 -13
  71. package/dist/typescript-client/src/client-id.service.d.ts +24 -24
  72. package/dist/typescript-client/src/collection-reference.d.ts +81 -81
  73. package/dist/typescript-client/src/collection-reference.factory.d.ts +16 -16
  74. package/dist/typescript-client/src/data.manager.d.ts +172 -172
  75. package/dist/typescript-client/src/destruct.manager.d.ts +12 -12
  76. package/dist/typescript-client/src/distributed-lock.manager.d.ts +19 -19
  77. package/dist/typescript-client/src/document-identity.service.d.ts +12 -12
  78. package/dist/typescript-client/src/document-reference.d.ts +134 -134
  79. package/dist/typescript-client/src/document-reference.factory.d.ts +9 -9
  80. package/dist/typescript-client/src/document-store.d.ts +11 -11
  81. package/dist/typescript-client/src/graphql-client.d.ts +12 -12
  82. package/dist/typescript-client/src/graphql-client.factory.d.ts +9 -9
  83. package/dist/typescript-client/src/index.d.ts +8 -8
  84. package/dist/typescript-client/src/mutation/mutation-sender.d.ts +12 -12
  85. package/dist/typescript-client/src/named-query.manager.d.ts +14 -14
  86. package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +72 -72
  87. package/dist/typescript-client/src/query/query-builder.factory.d.ts +83 -83
  88. package/dist/typescript-client/src/query/query-subscription.manager.d.ts +64 -64
  89. package/dist/typescript-client/src/query/query.types.d.ts +14 -14
  90. package/dist/typescript-client/src/rpc.manager.d.ts +28 -28
  91. package/dist/typescript-client/src/socket.manager.d.ts +32 -32
  92. package/dist/typescript-client/src/squid.d.ts +188 -188
  93. package/dist/typescript-client/src/state/action.applier.d.ts +7 -7
  94. package/dist/typescript-client/src/state/actions.d.ts +29 -29
  95. package/dist/typescript-client/src/state/path_trie.d.ts +27 -27
  96. package/dist/typescript-client/src/state/state.service.d.ts +22 -22
  97. package/dist/typescript-client/src/state/state.service.spec.d.ts +1 -1
  98. package/dist/typescript-client/src/testing/setup-tests.d.ts +1 -1
  99. package/dist/typescript-client/src/types.d.ts +2 -2
  100. package/package.json +1 -1
@@ -1,66 +1,66 @@
1
- import { AiAssistantMutateRequest, IntegrationId, OpenAiModelName } from '@squidcloud/common';
2
- import { Observable } from 'rxjs';
3
- import { ClientIdService } from './client-id.service';
4
- import { RpcManager } from './rpc.manager';
5
- import { SocketManager } from './socket.manager';
6
- export declare class AiAssistantClient {
7
- private readonly clientIdService;
8
- private readonly rpcManager;
9
- private readonly socketManager;
10
- private readonly integrationId;
11
- private readonly ongoingChatRequests;
12
- constructor(clientIdService: ClientIdService, rpcManager: RpcManager, socketManager: SocketManager, integrationId: IntegrationId);
13
- profile(id: string): AiAssistantProfileClient;
14
- mutate(request: AiAssistantMutateRequest): Promise<void>;
15
- chat(profileId: string, prompt: string): Observable<string>;
16
- private handleChatResponse;
17
- }
18
- declare class AiAssistantProfileClient {
19
- private readonly client;
20
- private readonly integrationId;
21
- private readonly profileId;
22
- constructor(client: AiAssistantClient, integrationId: IntegrationId, profileId: string);
23
- chat(prompt: string): Observable<string>;
24
- context(id?: string): AiAssistantContextClient;
25
- instruction(id?: string): AiAssistantInstructionClient;
26
- insert(data: {
27
- modelName: OpenAiModelName;
28
- strictContext: boolean;
29
- }): Promise<void>;
30
- update(data: {
31
- modelName?: OpenAiModelName;
32
- strictContext: boolean;
33
- }): Promise<void>;
34
- delete(): Promise<void>;
35
- }
36
- declare class AiAssistantContextClient {
37
- private readonly client;
38
- private readonly integrationId;
39
- private readonly profileId;
40
- private readonly id;
41
- constructor(client: AiAssistantClient, integrationId: IntegrationId, profileId: string, id?: string);
42
- insert(data: {
43
- title: string;
44
- context: string;
45
- }): Promise<void>;
46
- update(data: {
47
- title?: string;
48
- context?: string;
49
- }): Promise<void>;
50
- delete(): Promise<void>;
51
- }
52
- declare class AiAssistantInstructionClient {
53
- private readonly client;
54
- private readonly integrationId;
55
- private readonly profileId;
56
- private readonly id;
57
- constructor(client: AiAssistantClient, integrationId: IntegrationId, profileId: string, id?: string);
58
- insert(data: {
59
- instruction: string;
60
- }): Promise<void>;
61
- update(data: {
62
- instruction: string;
63
- }): Promise<void>;
64
- delete(): Promise<void>;
65
- }
66
- export {};
1
+ import { AiAssistantMutateRequest, IntegrationId, OpenAiModelName } from '@squidcloud/common';
2
+ import { Observable } from 'rxjs';
3
+ import { ClientIdService } from './client-id.service';
4
+ import { RpcManager } from './rpc.manager';
5
+ import { SocketManager } from './socket.manager';
6
+ export declare class AiAssistantClient {
7
+ private readonly clientIdService;
8
+ private readonly rpcManager;
9
+ private readonly socketManager;
10
+ private readonly integrationId;
11
+ private readonly ongoingChatRequests;
12
+ constructor(clientIdService: ClientIdService, rpcManager: RpcManager, socketManager: SocketManager, integrationId: IntegrationId);
13
+ profile(id: string): AiAssistantProfileClient;
14
+ mutate(request: AiAssistantMutateRequest): Promise<void>;
15
+ chat(profileId: string, prompt: string): Observable<string>;
16
+ private handleChatResponse;
17
+ }
18
+ declare class AiAssistantProfileClient {
19
+ private readonly client;
20
+ private readonly integrationId;
21
+ private readonly profileId;
22
+ constructor(client: AiAssistantClient, integrationId: IntegrationId, profileId: string);
23
+ chat(prompt: string): Observable<string>;
24
+ context(id?: string): AiAssistantContextClient;
25
+ instruction(id?: string): AiAssistantInstructionClient;
26
+ insert(data: {
27
+ modelName: OpenAiModelName;
28
+ strictContext: boolean;
29
+ }): Promise<void>;
30
+ update(data: {
31
+ modelName?: OpenAiModelName;
32
+ strictContext: boolean;
33
+ }): Promise<void>;
34
+ delete(): Promise<void>;
35
+ }
36
+ declare class AiAssistantContextClient {
37
+ private readonly client;
38
+ private readonly integrationId;
39
+ private readonly profileId;
40
+ private readonly id;
41
+ constructor(client: AiAssistantClient, integrationId: IntegrationId, profileId: string, id?: string);
42
+ insert(data: {
43
+ title: string;
44
+ context: string;
45
+ }): Promise<void>;
46
+ update(data: {
47
+ title?: string;
48
+ context?: string;
49
+ }): Promise<void>;
50
+ delete(): Promise<void>;
51
+ }
52
+ declare class AiAssistantInstructionClient {
53
+ private readonly client;
54
+ private readonly integrationId;
55
+ private readonly profileId;
56
+ private readonly id;
57
+ constructor(client: AiAssistantClient, integrationId: IntegrationId, profileId: string, id?: string);
58
+ insert(data: {
59
+ instruction: string;
60
+ }): Promise<void>;
61
+ update(data: {
62
+ instruction: string;
63
+ }): Promise<void>;
64
+ delete(): Promise<void>;
65
+ }
66
+ export {};
@@ -1,13 +1,13 @@
1
- import { IntegrationId } from '@squidcloud/common';
2
- import { AiAssistantClient } from './ai-assistant-client';
3
- import { RpcManager } from './rpc.manager';
4
- import { SocketManager } from './socket.manager';
5
- import { ClientIdService } from './client-id.service';
6
- export declare class AiClientFactory {
7
- private readonly clientIdService;
8
- private readonly rpcManager;
9
- private readonly socketManager;
10
- private readonly assistantsMap;
11
- constructor(clientIdService: ClientIdService, rpcManager: RpcManager, socketManager: SocketManager);
12
- getAssistant(integrationId: IntegrationId): AiAssistantClient;
13
- }
1
+ import { IntegrationId } from '@squidcloud/common';
2
+ import { AiAssistantClient } from './ai-assistant-client';
3
+ import { RpcManager } from './rpc.manager';
4
+ import { SocketManager } from './socket.manager';
5
+ import { ClientIdService } from './client-id.service';
6
+ export declare class AiClientFactory {
7
+ private readonly clientIdService;
8
+ private readonly rpcManager;
9
+ private readonly socketManager;
10
+ private readonly assistantsMap;
11
+ constructor(clientIdService: ClientIdService, rpcManager: RpcManager, socketManager: SocketManager);
12
+ getAssistant(integrationId: IntegrationId): AiAssistantClient;
13
+ }
@@ -1,15 +1,15 @@
1
- import { ApiEndpointId, IntegrationId } from '@squidcloud/common';
2
- import { Observable } from 'rxjs';
3
- import { RpcManager } from './rpc.manager';
4
- import { SocketManager } from './socket.manager';
5
- import { ClientIdService } from './client-id.service';
6
- export declare class ApiManager {
7
- private readonly clientIdService;
8
- private readonly rpcManager;
9
- private readonly socketManager;
10
- private readonly apiServerUrlOverrideMapping;
11
- private readonly ongoingApiExecutions;
12
- constructor(clientIdService: ClientIdService, rpcManager: RpcManager, socketManager: SocketManager, apiServerUrlOverrideMapping?: Record<IntegrationId, string>);
13
- callApiAndSubscribe<T>(integrationId: IntegrationId, endpointId: ApiEndpointId, request: Record<string, any>): Observable<T>;
14
- private handleApiResponse;
15
- }
1
+ import { ApiEndpointId, IntegrationId } from '@squidcloud/common';
2
+ import { Observable } from 'rxjs';
3
+ import { RpcManager } from './rpc.manager';
4
+ import { SocketManager } from './socket.manager';
5
+ import { ClientIdService } from './client-id.service';
6
+ export declare class ApiManager {
7
+ private readonly clientIdService;
8
+ private readonly rpcManager;
9
+ private readonly socketManager;
10
+ private readonly apiServerUrlOverrideMapping;
11
+ private readonly ongoingApiExecutions;
12
+ constructor(clientIdService: ClientIdService, rpcManager: RpcManager, socketManager: SocketManager, apiServerUrlOverrideMapping?: Record<IntegrationId, string>);
13
+ callApiAndSubscribe<T>(integrationId: IntegrationId, endpointId: ApiEndpointId, request: Record<string, any>): Observable<T>;
14
+ private handleApiResponse;
15
+ }
@@ -1,23 +1,23 @@
1
- import { ApiKey, AuthToken, IntegrationId } from '@squidcloud/common';
2
- import { Observable } from 'rxjs';
3
- import { DestructManager } from './destruct.manager';
4
- type AuthData = {
5
- token: string | undefined;
6
- integrationId?: IntegrationId;
7
- };
8
- export declare class AuthManager {
9
- private readonly destructManager;
10
- private readonly apiKey;
11
- private readonly authIdTokenSet;
12
- private readonly authIdTokenObservableSubject;
13
- private shouldWaitForAuth;
14
- private idToken;
15
- private integrationId;
16
- constructor(destructManager: DestructManager, apiKey: ApiKey | undefined);
17
- setAuthIdToken(idToken: string | undefined | Promise<string | undefined> | Observable<string | undefined>, integrationId?: IntegrationId): void;
18
- observeAuthIdToken(): Observable<AuthData>;
19
- waitForReadyState(): Promise<void>;
20
- getApiKey(): ApiKey | undefined;
21
- getAuthToken(): AuthToken | undefined;
22
- }
23
- export {};
1
+ import { ApiKey, AuthToken, IntegrationId } from '@squidcloud/common';
2
+ import { Observable } from 'rxjs';
3
+ import { DestructManager } from './destruct.manager';
4
+ type AuthData = {
5
+ token: string | undefined;
6
+ integrationId?: IntegrationId;
7
+ };
8
+ export declare class AuthManager {
9
+ private readonly destructManager;
10
+ private readonly apiKey;
11
+ private readonly authIdTokenSet;
12
+ private readonly authIdTokenObservableSubject;
13
+ private shouldWaitForAuth;
14
+ private idToken;
15
+ private integrationId;
16
+ constructor(destructManager: DestructManager, apiKey: ApiKey | undefined);
17
+ setAuthIdToken(idToken: string | undefined | Promise<string | undefined> | Observable<string | undefined>, integrationId?: IntegrationId): void;
18
+ observeAuthIdToken(): Observable<AuthData>;
19
+ waitForReadyState(): Promise<void>;
20
+ getApiKey(): ApiKey | undefined;
21
+ getAuthToken(): AuthToken | undefined;
22
+ }
23
+ export {};
@@ -1,13 +1,13 @@
1
- import { Observable } from 'rxjs';
2
- import { RpcManager } from './rpc.manager';
3
- import { SocketManager } from './socket.manager';
4
- import { ClientIdService } from './client-id.service';
5
- export declare class BackendFunctionManager {
6
- private readonly clientIdService;
7
- private readonly rpcManager;
8
- private readonly socketManager;
9
- private readonly ongoingFunctionExecutions;
10
- constructor(clientIdService: ClientIdService, rpcManager: RpcManager, socketManager: SocketManager);
11
- executeFunctionAndSubscribe<T>(functionName: string, ...params: any[]): Observable<T>;
12
- private handleFunctionResponse;
13
- }
1
+ import { Observable } from 'rxjs';
2
+ import { RpcManager } from './rpc.manager';
3
+ import { SocketManager } from './socket.manager';
4
+ import { ClientIdService } from './client-id.service';
5
+ export declare class BackendFunctionManager {
6
+ private readonly clientIdService;
7
+ private readonly rpcManager;
8
+ private readonly socketManager;
9
+ private readonly ongoingFunctionExecutions;
10
+ constructor(clientIdService: ClientIdService, rpcManager: RpcManager, socketManager: SocketManager);
11
+ executeFunctionAndSubscribe<T>(functionName: string, ...params: any[]): Observable<T>;
12
+ private handleFunctionResponse;
13
+ }
@@ -1,24 +1,24 @@
1
- import { Observable } from 'rxjs';
2
- import { ClientId } from '@squidcloud/common';
3
- import { DestructManager } from './destruct.manager';
4
- /**
5
- * Whenever a squid client is created, it assigns itself a client id.
6
- * Later on, if the squid client disconnects for a specified time interval, it will generate itself a new client id.
7
- * The client id is generated before the socket is reconnected, so it is possible that the new client id is generated,
8
- * but the socket has not connected yet.
9
- *
10
- * Short-term disconnects/reconnects of the socket do not cause the client id to be regenerated.
11
- */
12
- export declare class ClientIdService {
13
- private readonly destructManager;
14
- private readonly clientTooOldSubject;
15
- private clientId;
16
- constructor(destructManager: DestructManager);
17
- observeClientTooOld(): Observable<void>;
18
- /** there was a long-term disconnection of the socket */
19
- notifyClientTooOld(): void;
20
- notifyClientReadyToBeRegenerated(): void;
21
- observeClientReadyToBeRegenerated(): Observable<void>;
22
- getClientId(): ClientId;
23
- isClientTooOld(): boolean;
24
- }
1
+ import { Observable } from 'rxjs';
2
+ import { ClientId } from '@squidcloud/common';
3
+ import { DestructManager } from './destruct.manager';
4
+ /**
5
+ * Whenever a squid client is created, it assigns itself a client id.
6
+ * Later on, if the squid client disconnects for a specified time interval, it will generate itself a new client id.
7
+ * The client id is generated before the socket is reconnected, so it is possible that the new client id is generated,
8
+ * but the socket has not connected yet.
9
+ *
10
+ * Short-term disconnects/reconnects of the socket do not cause the client id to be regenerated.
11
+ */
12
+ export declare class ClientIdService {
13
+ private readonly destructManager;
14
+ private readonly clientTooOldSubject;
15
+ private clientId;
16
+ constructor(destructManager: DestructManager);
17
+ observeClientTooOld(): Observable<void>;
18
+ /** there was a long-term disconnection of the socket */
19
+ notifyClientTooOld(): void;
20
+ notifyClientReadyToBeRegenerated(): void;
21
+ observeClientReadyToBeRegenerated(): Observable<void>;
22
+ getClientId(): ClientId;
23
+ isClientTooOld(): boolean;
24
+ }
@@ -1,81 +1,81 @@
1
- import { DocId, DocIdObj, DocumentData } from '@squidcloud/common';
2
- import { DocumentReference } from './document-reference';
3
- import { JoinQueryBuilder } from './query/join-query-builder.factory';
4
- import { QueryActions, QueryBuilder } from './query/query-builder.factory';
5
- import { Alias } from './query/query.types';
6
- /**
7
- * Holds a reference to a data collection. a collection reference is a reference to a collection in a database. You
8
- * can
9
- * use it to read or write data to the collection. A collection can refer to a table in a relational database or a
10
- * collection in a NoSQL database.
11
- *
12
- * Read more about collection references in the
13
- * [documentation]{@link https://docs.squid.cloud/docs/client-sdk/collection-reference}.
14
- * @typeParam T The type of the document data.
15
- */
16
- export declare class CollectionReference<T extends DocumentData> {
17
- private readonly collectionName;
18
- private integrationId;
19
- private readonly documentReferenceFactory;
20
- private readonly queryBuilderFactory;
21
- private readonly joinQueryBuilderFactory;
22
- /** A string that uniquely identifies this collection reference. */
23
- refId: string;
24
- private readonly documents;
25
- /**
26
- * Returns a document reference for the given document id.
27
- * The document id is an object that maps the primary keys of the collection (as defined in the Squid Cloud Console)
28
- * to their values. There are a few exceptions:
29
- * 1 - String document id is only supported for the `built_in_db` when a schema was not defined.
30
- * 2 - Not all the fields in the document id are required. If a field is not provided, it will be generated on the
31
- * server once the document is created (if the integration supports it).
32
- * 3 - When a document id is not provided, it will be treated as an empty object or empty string.
33
- * 4 - When the document id is just a `string` and not provided (applies only for the `built_in_db`), it will be
34
- * generated on the server.
35
- * 5 - If the collection in the `built_in_db` does not have a schema, the document id must be provided as a string.
36
- *
37
- * Examples:
38
- * ```typescript
39
- * // For a collection in the built_in_db that does not have a schema
40
- * const docRef = collectionRef.doc('my-doc-id');
41
- *
42
- * // For a collection with a single primary key field called "id"
43
- * const docRef = collectionRef.doc({id: 'my-doc-id'});
44
- *
45
- * // For a collection with a composite primary key
46
- * const docRef = collectionRef.doc({id1: 'my-doc-id1', id2: 'my-doc-id2'});
47
- * const docRef = collectionRef.doc({id1: 'my-doc-id1'}); // id2 will be generated on the server if the integration supports it
48
- *
49
- * // For a collection from the `built_in_db` without a defined schema when an id is not provided
50
- * const docRef = collectionRef.doc(); // The id will be generated on the server
51
- * ```
52
- *
53
- * @param docId The document id as an object for the different fields in the primary key or a string.
54
- * @returns A document reference for the given document id.
55
- */
56
- doc(docId?: DocId | DocIdObj): DocumentReference<T>;
57
- /**
58
- * Creates a `QueryBuilder` that can be used to query the collection.
59
- *
60
- * @returns A `QueryBuilder` that can be used to query the collection.
61
- */
62
- query(): QueryBuilder<T>;
63
- /**
64
- * Creates a `JoinQueryBuilder` that can be used to query the collection
65
- * Note that when using a join query, you have to provide an alias for the query and for every other query
66
- * participating in the join.
67
- *
68
- * @param alias The alias for the query.
69
- * @returns A `JoinQueryBuilder` that can be used to query the collection and joins with other queries.
70
- */
71
- joinQuery<A extends Alias>(alias: A): JoinQueryBuilder<T, A, Record<A, DocumentReference<T>>>;
72
- /**
73
- * Performs `or` on a list of queries. All the queries need to be on the same collection.
74
- * The result will be a merge of all the queries sorted by the same sort condition of the first query.
75
- * Duplicate items will be removed.
76
- * @param builders The list of query builders to merge. (A query builder can be returned from the {@link query}
77
- * method.
78
- * @returns A query builder that can be used to perform the `or` operation.
79
- */
80
- or(...builders: QueryActions<T>[]): QueryActions<T>;
81
- }
1
+ import { DocId, DocIdObj, DocumentData } from '@squidcloud/common';
2
+ import { DocumentReference } from './document-reference';
3
+ import { JoinQueryBuilder } from './query/join-query-builder.factory';
4
+ import { QueryActions, QueryBuilder } from './query/query-builder.factory';
5
+ import { Alias } from './query/query.types';
6
+ /**
7
+ * Holds a reference to a data collection. a collection reference is a reference to a collection in a database. You
8
+ * can
9
+ * use it to read or write data to the collection. A collection can refer to a table in a relational database or a
10
+ * collection in a NoSQL database.
11
+ *
12
+ * Read more about collection references in the
13
+ * [documentation]{@link https://docs.squid.cloud/docs/client-sdk/collection-reference}.
14
+ * @typeParam T The type of the document data.
15
+ */
16
+ export declare class CollectionReference<T extends DocumentData> {
17
+ private readonly collectionName;
18
+ private integrationId;
19
+ private readonly documentReferenceFactory;
20
+ private readonly queryBuilderFactory;
21
+ private readonly joinQueryBuilderFactory;
22
+ /** A string that uniquely identifies this collection reference. */
23
+ refId: string;
24
+ private readonly documents;
25
+ /**
26
+ * Returns a document reference for the given document id.
27
+ * The document id is an object that maps the primary keys of the collection (as defined in the Squid Cloud Console)
28
+ * to their values. There are a few exceptions:
29
+ * 1 - String document id is only supported for the `built_in_db` when a schema was not defined.
30
+ * 2 - Not all the fields in the document id are required. If a field is not provided, it will be generated on the
31
+ * server once the document is created (if the integration supports it).
32
+ * 3 - When a document id is not provided, it will be treated as an empty object or empty string.
33
+ * 4 - When the document id is just a `string` and not provided (applies only for the `built_in_db`), it will be
34
+ * generated on the server.
35
+ * 5 - If the collection in the `built_in_db` does not have a schema, the document id must be provided as a string.
36
+ *
37
+ * Examples:
38
+ * ```typescript
39
+ * // For a collection in the built_in_db that does not have a schema
40
+ * const docRef = collectionRef.doc('my-doc-id');
41
+ *
42
+ * // For a collection with a single primary key field called "id"
43
+ * const docRef = collectionRef.doc({id: 'my-doc-id'});
44
+ *
45
+ * // For a collection with a composite primary key
46
+ * const docRef = collectionRef.doc({id1: 'my-doc-id1', id2: 'my-doc-id2'});
47
+ * const docRef = collectionRef.doc({id1: 'my-doc-id1'}); // id2 will be generated on the server if the integration supports it
48
+ *
49
+ * // For a collection from the `built_in_db` without a defined schema when an id is not provided
50
+ * const docRef = collectionRef.doc(); // The id will be generated on the server
51
+ * ```
52
+ *
53
+ * @param docId The document id as an object for the different fields in the primary key or a string.
54
+ * @returns A document reference for the given document id.
55
+ */
56
+ doc(docId?: DocId | DocIdObj): DocumentReference<T>;
57
+ /**
58
+ * Creates a `QueryBuilder` that can be used to query the collection.
59
+ *
60
+ * @returns A `QueryBuilder` that can be used to query the collection.
61
+ */
62
+ query(): QueryBuilder<T>;
63
+ /**
64
+ * Creates a `JoinQueryBuilder` that can be used to query the collection
65
+ * Note that when using a join query, you have to provide an alias for the query and for every other query
66
+ * participating in the join.
67
+ *
68
+ * @param alias The alias for the query.
69
+ * @returns A `JoinQueryBuilder` that can be used to query the collection and joins with other queries.
70
+ */
71
+ joinQuery<A extends Alias>(alias: A): JoinQueryBuilder<T, A, Record<A, DocumentReference<T>>>;
72
+ /**
73
+ * Performs `or` on a list of queries. All the queries need to be on the same collection.
74
+ * The result will be a merge of all the queries sorted by the same sort condition of the first query.
75
+ * Duplicate items will be removed.
76
+ * @param builders The list of query builders to merge. (A query builder can be returned from the {@link query}
77
+ * method.
78
+ * @returns A query builder that can be used to perform the `or` operation.
79
+ */
80
+ or(...builders: QueryActions<T>[]): QueryActions<T>;
81
+ }
@@ -1,16 +1,16 @@
1
- import { CollectionName, DocumentData, IntegrationId } from '@squidcloud/common';
2
- import { CollectionReference } from './collection-reference';
3
- import DocumentIdentityService from './document-identity.service';
4
- import { DocumentReferenceFactory } from './document-reference.factory';
5
- import { JoinQueryBuilderFactory } from './query/join-query-builder.factory';
6
- import { QueryBuilderFactory } from './query/query-builder.factory';
7
- export declare class CollectionReferenceFactory {
8
- private readonly documentReferenceFactory;
9
- private readonly queryBuilderFactory;
10
- private readonly joinQueryBuilderFactory;
11
- private readonly documentIdentityService;
12
- private readonly collections;
13
- constructor(documentReferenceFactory: DocumentReferenceFactory, queryBuilderFactory: QueryBuilderFactory, joinQueryBuilderFactory: JoinQueryBuilderFactory, documentIdentityService: DocumentIdentityService);
14
- get<T extends DocumentData>(collectionName: CollectionName, integrationId: IntegrationId): CollectionReference<T>;
15
- private migrateDocIds;
16
- }
1
+ import { CollectionName, DocumentData, IntegrationId } from '@squidcloud/common';
2
+ import { CollectionReference } from './collection-reference';
3
+ import DocumentIdentityService from './document-identity.service';
4
+ import { DocumentReferenceFactory } from './document-reference.factory';
5
+ import { JoinQueryBuilderFactory } from './query/join-query-builder.factory';
6
+ import { QueryBuilderFactory } from './query/query-builder.factory';
7
+ export declare class CollectionReferenceFactory {
8
+ private readonly documentReferenceFactory;
9
+ private readonly queryBuilderFactory;
10
+ private readonly joinQueryBuilderFactory;
11
+ private readonly documentIdentityService;
12
+ private readonly collections;
13
+ constructor(documentReferenceFactory: DocumentReferenceFactory, queryBuilderFactory: QueryBuilderFactory, joinQueryBuilderFactory: JoinQueryBuilderFactory, documentIdentityService: DocumentIdentityService);
14
+ get<T extends DocumentData>(collectionName: CollectionName, integrationId: IntegrationId): CollectionReference<T>;
15
+ private migrateDocIds;
16
+ }