@squidcloud/client 1.0.102 → 1.0.104

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 (108) hide show
  1. package/dist/cjs/index.js +48968 -12
  2. package/dist/common/src/ai-assistant.context.d.ts +12 -12
  3. package/dist/common/src/ai-assistant.schemas.d.ts +1 -1
  4. package/dist/common/src/ai-assistant.types.d.ts +12 -12
  5. package/dist/common/src/api-call.context.d.ts +13 -13
  6. package/dist/common/src/api.types.d.ts +4 -4
  7. package/dist/common/src/application.schemas.d.ts +66 -66
  8. package/dist/common/src/application.types.d.ts +140 -140
  9. package/dist/common/src/backend-function.schemas.d.ts +1 -1
  10. package/dist/common/src/backend-function.types.d.ts +1 -1
  11. package/dist/common/src/backend-run.types.d.ts +2 -2
  12. package/dist/common/src/bundle-api.types.d.ts +36 -36
  13. package/dist/common/src/bundle-data.types.d.ts +4 -4
  14. package/dist/common/src/communication.types.d.ts +12 -12
  15. package/dist/common/src/context.types.d.ts +40 -40
  16. package/dist/common/src/distributed-lock.context.d.ts +5 -5
  17. package/dist/common/src/document.types.d.ts +22 -22
  18. package/dist/common/src/graphql.context.d.ts +7 -7
  19. package/dist/common/src/graphql.types.d.ts +9 -9
  20. package/dist/common/src/heartbeat.types.d.ts +1 -1
  21. package/dist/common/src/http-status.enum.d.ts +50 -50
  22. package/dist/common/src/index.d.ts +55 -53
  23. package/dist/common/src/integrations/ai_assistant.types.d.ts +24 -24
  24. package/dist/common/src/integrations/api.types.d.ts +80 -80
  25. package/dist/common/src/integrations/auth.types.d.ts +39 -39
  26. package/dist/common/src/integrations/database.types.d.ts +231 -231
  27. package/dist/common/src/integrations/index.d.ts +124 -124
  28. package/dist/common/src/integrations/observability.types.d.ts +23 -23
  29. package/dist/common/src/logger.types.d.ts +21 -21
  30. package/dist/common/src/metrics.types.d.ts +1 -1
  31. package/dist/common/src/mutation.context.d.ts +14 -14
  32. package/dist/common/src/mutation.schemas.d.ts +1 -1
  33. package/dist/common/src/mutation.types.d.ts +53 -53
  34. package/dist/common/src/named-query.context.d.ts +4 -4
  35. package/dist/common/src/named-query.schemas.d.ts +1 -1
  36. package/dist/common/src/named-query.types.d.ts +1 -1
  37. package/dist/common/src/query/base-query-builder.d.ts +147 -147
  38. package/dist/common/src/query/index.d.ts +4 -4
  39. package/dist/common/src/query/pagination.d.ts +44 -44
  40. package/dist/common/src/query/query-context.d.ts +137 -137
  41. package/dist/common/src/query/serialized-query.types.d.ts +24 -24
  42. package/dist/common/src/query.types.d.ts +64 -64
  43. package/dist/common/src/regions.d.ts +1 -1
  44. package/dist/common/src/schema/schema.types.d.ts +54 -54
  45. package/dist/common/src/secret.schemas.d.ts +1 -1
  46. package/dist/common/src/secret.types.d.ts +8 -8
  47. package/dist/common/src/security.types.d.ts +1 -1
  48. package/dist/common/src/socket.schemas.d.ts +1 -1
  49. package/dist/common/src/socket.types.d.ts +1 -1
  50. package/dist/common/src/time-units.d.ts +1 -1
  51. package/dist/common/src/trigger.types.d.ts +1 -1
  52. package/dist/common/src/types.d.ts +14 -14
  53. package/dist/common/src/utils/array.d.ts +1 -1
  54. package/dist/common/src/utils/assert.d.ts +1 -1
  55. package/dist/common/src/utils/error.d.ts +4 -4
  56. package/dist/common/src/utils/global.utils.d.ts +1 -0
  57. package/dist/common/src/utils/http.d.ts +2 -2
  58. package/dist/common/src/utils/id.d.ts +2 -2
  59. package/dist/common/src/utils/lock.manager.d.ts +14 -14
  60. package/dist/common/src/utils/nullish.d.ts +2 -2
  61. package/dist/common/src/utils/object.d.ts +5 -5
  62. package/dist/common/src/utils/serialization.d.ts +6 -6
  63. package/dist/common/src/utils/transforms.d.ts +18 -18
  64. package/dist/common/src/utils/url.d.ts +1 -1
  65. package/dist/common/src/utils/validation.d.ts +30 -30
  66. package/dist/common/src/webhook-response.d.ts +1 -1
  67. package/dist/common/src/websocket.impl.d.ts +21 -0
  68. package/dist/esm/index.js +48888 -12
  69. package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -1239
  70. package/dist/typescript-client/src/ai-assistant-client.d.ts +167 -167
  71. package/dist/typescript-client/src/ai-client.factory.d.ts +11 -11
  72. package/dist/typescript-client/src/api.manager.d.ts +15 -15
  73. package/dist/typescript-client/src/auth.manager.d.ts +23 -23
  74. package/dist/typescript-client/src/backend-function.manager.d.ts +13 -13
  75. package/dist/typescript-client/src/client-id.service.d.ts +27 -25
  76. package/dist/typescript-client/src/collection-reference.d.ts +81 -81
  77. package/dist/typescript-client/src/collection-reference.factory.d.ts +13 -13
  78. package/dist/typescript-client/src/connection-details.d.ts +23 -23
  79. package/dist/typescript-client/src/data.manager.d.ts +171 -172
  80. package/dist/typescript-client/src/destruct.manager.d.ts +12 -12
  81. package/dist/typescript-client/src/distributed-lock.manager.d.ts +16 -19
  82. package/dist/typescript-client/src/document-identity.service.d.ts +12 -12
  83. package/dist/typescript-client/src/document-reference.d.ts +140 -140
  84. package/dist/typescript-client/src/document-reference.factory.d.ts +13 -13
  85. package/dist/typescript-client/src/document-store.d.ts +11 -11
  86. package/dist/typescript-client/src/graphql-client.d.ts +14 -14
  87. package/dist/typescript-client/src/graphql-client.factory.d.ts +11 -11
  88. package/dist/typescript-client/src/index.d.ts +8 -8
  89. package/dist/typescript-client/src/mutation/mutation-sender.d.ts +10 -10
  90. package/dist/typescript-client/src/named-query.manager.d.ts +12 -12
  91. package/dist/typescript-client/src/query/deserializer.d.ts +3 -3
  92. package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +161 -161
  93. package/dist/typescript-client/src/query/local-query-manager.d.ts +9 -9
  94. package/dist/typescript-client/src/query/query-builder.factory.d.ts +76 -76
  95. package/dist/typescript-client/src/query/query-subscription.manager.d.ts +186 -186
  96. package/dist/typescript-client/src/rpc.manager.d.ts +28 -29
  97. package/dist/typescript-client/src/socket.manager.d.ts +36 -33
  98. package/dist/typescript-client/src/squid.d.ts +218 -218
  99. package/dist/typescript-client/src/state/action.applier.d.ts +7 -7
  100. package/dist/typescript-client/src/state/actions.d.ts +29 -29
  101. package/dist/typescript-client/src/state/path_trie.d.ts +27 -27
  102. package/dist/typescript-client/src/state/state.service.d.ts +22 -22
  103. package/dist/typescript-client/src/state/state.service.spec.d.ts +1 -1
  104. package/dist/typescript-client/src/testing/setup-tests.d.ts +1 -1
  105. package/dist/typescript-client/src/types.d.ts +2 -2
  106. package/package.json +2 -2
  107. package/dist/cjs/index.js.LICENSE.txt +0 -10
  108. package/dist/esm/index.js.LICENSE.txt +0 -10
@@ -1,218 +1,218 @@
1
- import { ApiEndpointId, ApiKey, AppId, CollectionName, DocumentData, EnvironmentId, IntegrationId, QueryName, SquidDeveloperId, SupportedSquidRegion } from '@squidcloud/common';
2
- import { Observable } from 'rxjs';
3
- import { AiAssistantClient } from './ai-assistant-client';
4
- import { CollectionReference } from './collection-reference';
5
- import { ConnectionDetails } from './connection-details';
6
- import { DistributedLock } from './distributed-lock.manager';
7
- import { GraphQLClient } from './graphql-client';
8
- import { TransactionId } from './types';
9
- /** The different options that can be used to initialize a Squid instance. */
10
- export interface SquidOptions {
11
- /**
12
- * A function that can be used to wrap messages coming from Squid to the application. This is useful for
13
- * different frameworks that need to wrap messages in order to detect changes (like Angular).
14
- * @param fn The function to wrap.
15
- */
16
- messageNotificationWrapper?: (fn: () => any) => any;
17
- /**
18
- * The application ID that is used to identify the application in Squid. The ID can be found in the Squid Cloud
19
- * Console.
20
- */
21
- appId: AppId;
22
- /**
23
- * The application API key, using the API key can be used to bypass security rules and other restrictions.
24
- * The API key can be found in the Squid Cloud Console.
25
- */
26
- apiKey?: ApiKey;
27
- /**
28
- * The region that the application is running in. This is used to determine the URL of the Squid Cloud API.
29
- */
30
- region: SupportedSquidRegion;
31
- /**
32
- * The environment ID to work with, if not specified the default environment (prod) will be used.
33
- */
34
- environmentId?: EnvironmentId;
35
- /**
36
- * The user ID of the developer that runs the environment locally.
37
- */
38
- squidDeveloperId?: SquidDeveloperId;
39
- /**
40
- * A list of API endpoints that can be used for overriding the default API endpoints for the different integrations.
41
- * This is useful for APIs that have multiple base urls hosted in different regions.
42
- */
43
- apiServerUrlOverrideMapping?: Record<IntegrationId, string>;
44
- }
45
- /**
46
- * The main entry point to the Squid Client SDK.
47
- *
48
- * The Squid class provides a comprehensive array of functionality for accessing the different integrations, executing
49
- * backend functions, managing data, and more. Upon instantiating the Squid class, you will have access to all of these
50
- * capabilities.
51
- */
52
- export declare class Squid {
53
- private readonly socketManager;
54
- private readonly rpcManager;
55
- private readonly dataManager;
56
- private readonly documentReferenceFactory;
57
- private readonly documentStore;
58
- private readonly lockManager;
59
- private readonly querySubscriptionManager;
60
- private readonly localQueryManager;
61
- private readonly queryBuilderFactory;
62
- private readonly collectionReferenceFactory;
63
- private readonly backendFunctionManager;
64
- private readonly namedQueryManager;
65
- private readonly apiManager;
66
- private readonly graphqlClientFactory;
67
- private readonly destructManager;
68
- private readonly documentIdentityService;
69
- private readonly distributedLockManager;
70
- private readonly authManager;
71
- private readonly clientIdService;
72
- private readonly aiClientFactory;
73
- private readonly _connectionDetails;
74
- private static readonly squidInstancesMap;
75
- /**
76
- * Creates a new instance of Squid with the given options.
77
- *
78
- * @param options The options for initializing the Squid instance.
79
- */
80
- constructor(options: SquidOptions);
81
- /**
82
- * Returns the global Squid instance with the given options, creating a new instance if one with the same options
83
- * does not exist.
84
- *
85
- * @param options The options for initializing the Squid instance.
86
- * @returns A global Squid instance with the given options.
87
- */
88
- static getInstance(options: SquidOptions): Squid;
89
- /**
90
- * Returns all the global Squid instances.
91
- *
92
- * @returns An array of all the global Squid instances.
93
- */
94
- static getInstances(): Array<Squid>;
95
- /**
96
- * Sets the auth id token (OpenId) that will be sent to the server and will be used for providing the `auth` object
97
- * to the security rules.
98
- *
99
- * @param idToken The auth id token, a promise that resolves with the id token, or an observable that emits the id
100
- * token. Undefined if the user is not authenticated.
101
- * @param integrationId The id of the integration.
102
- * @returns void
103
- */
104
- setAuthIdToken: (idToken: string | undefined | Promise<string | undefined> | Observable<string | undefined>, integrationId?: IntegrationId) => void;
105
- /**
106
- * Returns a reference to the collection in the provided integration.
107
- *
108
- * If the integrationId is not provided, the `built_in_db` integration id will be used.
109
- *
110
- * For more information on the CollectionReference object, please refer to the
111
- * documentation at {@link https://docs.squid.cloud/docs/development-tools/client-sdk/collection-reference}.
112
- *
113
- * @param collectionName The name of the collection.
114
- * @param integrationId The id of the integration, default to `built_in_db`.
115
- * @returns A reference to the collection in the provided integration.
116
- * @typeParam T The type of the documents in the collection.
117
- */
118
- collection: <T extends DocumentData>(collectionName: CollectionName, integrationId?: IntegrationId) => CollectionReference<T>;
119
- /**
120
- * Runs the given callback as an atomic change. All the mutations that are executed using the provided transactionId
121
- * will be atomic. Note that mutations for different integrations will not be atomic.
122
- *
123
- * For more information about transactions in Squid, please refer to the
124
- * documentation at {@link https://docs.squid.cloud/docs/development-tools/client-sdk/transactions}.
125
- *
126
- * @param fn The callback to run as an atomic change. The function receives a transactionId that should be used for
127
- * all the mutations that should be atomic. The function should return a promise.
128
- *
129
- * @returns A promise that resolves when the transactions are committed on the server.
130
- */
131
- runInTransaction: (fn: (transactionId: TransactionId) => Promise<void>) => Promise<void>;
132
- /**
133
- * Executes the given backend function with the given parameters and returns a promise with the result.
134
- *
135
- * For more information about backend functions in Squid, please refer to the
136
- * documentation at {@link https://docs.squid.cloud/docs/development-tools/backend/executables}.
137
- *
138
- * @param functionName The name of the function to execute on the server.
139
- * @param params The parameters to pass to the function.
140
- * @returns A promise that resolves with the result of the function.
141
- * @typeParam T The type of the result of the function.
142
- */
143
- executeFunction: <T = any>(functionName: string, ...params: any[]) => Promise<T>;
144
- /**
145
- * Executes the given named query with the given parameters and returns a promise with the result.
146
- *
147
- * For more information about named queries in Squid, please refer to the
148
- * documentation at {@link https://docs.squid.cloud/docs/development-tools/backend/named-queries}.
149
- *
150
- * @param integrationId The id of the integration that the named query is defined with.
151
- * @param queryName The name of the named query.
152
- * @param params The parameters to pass to the named query.
153
- * @returns A promise that resolves with the result of the named query.
154
- * @typeParam T The type of the result of the named query.
155
- */
156
- executeNamedQuery: <T = any>(integrationId: IntegrationId, queryName: QueryName, params: Record<string, any>) => Promise<T>;
157
- /**
158
- * Invokes the given HTTP API (defined by the integration ID and the endpoint ID) with the given request parameters
159
- * and returns a promise with the response. The structure of the request and the response is defined in the
160
- * integration's schema page.
161
- *
162
- * For more information about API integrations in Squid, please refer to the
163
- * documentation at {@link https://docs.squid.cloud/docs/integrations/api/httpapi}.
164
- *
165
- * @param integrationId The id of the integration that the API is defined with.
166
- * @param endpointId The id of the endpoint in the API integration.
167
- * @param request The request parameters to pass to the API.
168
- * @returns A promise that resolves with the response of the API.
169
- * @typeParam T The type of the response of the API.
170
- */
171
- callApi: <T = any>(integrationId: IntegrationId, endpointId: ApiEndpointId, request?: Record<string, any>) => Promise<T>;
172
- /**
173
- * Returns a GraphQL client for the given integration. The GraphQL client can be used to execute GraphQL queries and
174
- * mutations. For more information about GraphQL in Squid, please refer to the documentation at
175
- * {@link https://docs.squid.cloud/docs/integrations/api/graphql}.
176
- *
177
- * @param integrationId The id of the integration that the GraphQL API is defined with.
178
- * @returns A GraphQL client for the given integration.
179
- */
180
- graphql: (integrationId: IntegrationId) => GraphQLClient;
181
- /**
182
- * Returns a set of AI specific clients. Currently, the only supported client is the AI Assistant, which is accessed
183
- * through the `assistant`.
184
- *
185
- * @returns A set of AI specific clients.
186
- */
187
- ai: () => {
188
- /**
189
- * Returns an AI Assistant client for the given integration. The AI Assistant client can be used to build and chat
190
- * with custom AI profiles. For more information about the AI Assistant in Squid, please refer to the documentation
191
- * at {@link https://docs.squid.cloud/docs/ai/ai-assistant}.
192
- *
193
- * @param integrationId The id of the AI Assistant integration.
194
- * @returns An AI Assistant client.
195
- */
196
- assistant: (integrationId: IntegrationId) => AiAssistantClient;
197
- };
198
- /**
199
- * Returns a distributed lock for the given mutex. The lock can be used to synchronize access to a shared resource.
200
- * The lock will be released when the release method on the returned object is invoked or whenever the connection
201
- * with the server is lost.
202
- * @param mutex A string that uniquely identifies the lock.
203
- * @param exclusive Whether the lock should be exclusive or not. If the lock is exclusive, only one client can hold
204
- * the lock.
205
- * @returns A promise that resolves with the lock object. The promise will reject if failed to acquire the lock.
206
- */
207
- acquireLock: (mutex: string, exclusive?: boolean) => Promise<DistributedLock>;
208
- /**
209
- * Destructs the Squid Client. Unsubscribes from all ongoing queries or requests, and clears the local data.
210
- * After invoking this method, the Squid client will not be usable.
211
- *
212
- * @returns A promise that resolves when the destruct process is complete.
213
- */
214
- destruct: () => Promise<void>;
215
- /** Provides information about the connection to the Squid Server. */
216
- connectionDetails: () => ConnectionDetails;
217
- private validateNotDestructed;
218
- }
1
+ import { ApiEndpointId, ApiKey, AppId, CollectionName, DocumentData, EnvironmentId, IntegrationId, QueryName, SquidDeveloperId, SupportedSquidRegion } from '@squidcloud/common';
2
+ import { Observable } from 'rxjs';
3
+ import { AiAssistantClient } from './ai-assistant-client';
4
+ import { CollectionReference } from './collection-reference';
5
+ import { ConnectionDetails } from './connection-details';
6
+ import { DistributedLock } from './distributed-lock.manager';
7
+ import { GraphQLClient } from './graphql-client';
8
+ import { TransactionId } from './types';
9
+ /** The different options that can be used to initialize a Squid instance. */
10
+ export interface SquidOptions {
11
+ /**
12
+ * A function that can be used to wrap messages coming from Squid to the application. This is useful for
13
+ * different frameworks that need to wrap messages in order to detect changes (like Angular).
14
+ * @param fn The function to wrap.
15
+ */
16
+ messageNotificationWrapper?: (fn: () => any) => any;
17
+ /**
18
+ * The application ID that is used to identify the application in Squid. The ID can be found in the Squid Cloud
19
+ * Console.
20
+ */
21
+ appId: AppId;
22
+ /**
23
+ * The application API key, using the API key can be used to bypass security rules and other restrictions.
24
+ * The API key can be found in the Squid Cloud Console.
25
+ */
26
+ apiKey?: ApiKey;
27
+ /**
28
+ * The region that the application is running in. This is used to determine the URL of the Squid Cloud API.
29
+ */
30
+ region: SupportedSquidRegion;
31
+ /**
32
+ * The environment ID to work with, if not specified the default environment (prod) will be used.
33
+ */
34
+ environmentId?: EnvironmentId;
35
+ /**
36
+ * The user ID of the developer that runs the environment locally.
37
+ */
38
+ squidDeveloperId?: SquidDeveloperId;
39
+ /**
40
+ * A list of API endpoints that can be used for overriding the default API endpoints for the different integrations.
41
+ * This is useful for APIs that have multiple base urls hosted in different regions.
42
+ */
43
+ apiServerUrlOverrideMapping?: Record<IntegrationId, string>;
44
+ }
45
+ /**
46
+ * The main entry point to the Squid Client SDK.
47
+ *
48
+ * The Squid class provides a comprehensive array of functionality for accessing the different integrations, executing
49
+ * backend functions, managing data, and more. Upon instantiating the Squid class, you will have access to all of these
50
+ * capabilities.
51
+ */
52
+ export declare class Squid {
53
+ private readonly socketManager;
54
+ private readonly rpcManager;
55
+ private readonly dataManager;
56
+ private readonly documentReferenceFactory;
57
+ private readonly documentStore;
58
+ private readonly lockManager;
59
+ private readonly querySubscriptionManager;
60
+ private readonly localQueryManager;
61
+ private readonly queryBuilderFactory;
62
+ private readonly collectionReferenceFactory;
63
+ private readonly backendFunctionManager;
64
+ private readonly namedQueryManager;
65
+ private readonly apiManager;
66
+ private readonly graphqlClientFactory;
67
+ private readonly destructManager;
68
+ private readonly documentIdentityService;
69
+ private readonly distributedLockManager;
70
+ private readonly authManager;
71
+ private readonly clientIdService;
72
+ private readonly aiClientFactory;
73
+ private readonly _connectionDetails;
74
+ private static readonly squidInstancesMap;
75
+ /**
76
+ * Creates a new instance of Squid with the given options.
77
+ *
78
+ * @param options The options for initializing the Squid instance.
79
+ */
80
+ constructor(options: SquidOptions);
81
+ /**
82
+ * Returns the global Squid instance with the given options, creating a new instance if one with the same options
83
+ * does not exist.
84
+ *
85
+ * @param options The options for initializing the Squid instance.
86
+ * @returns A global Squid instance with the given options.
87
+ */
88
+ static getInstance(options: SquidOptions): Squid;
89
+ /**
90
+ * Returns all the global Squid instances.
91
+ *
92
+ * @returns An array of all the global Squid instances.
93
+ */
94
+ static getInstances(): Array<Squid>;
95
+ /**
96
+ * Sets the auth id token (OpenId) that will be sent to the server and will be used for providing the `auth` object
97
+ * to the security rules.
98
+ *
99
+ * @param idToken The auth id token, a promise that resolves with the id token, or an observable that emits the id
100
+ * token. Undefined if the user is not authenticated.
101
+ * @param integrationId The id of the integration.
102
+ * @returns void
103
+ */
104
+ setAuthIdToken: (idToken: string | undefined | Promise<string | undefined> | Observable<string | undefined>, integrationId?: IntegrationId) => void;
105
+ /**
106
+ * Returns a reference to the collection in the provided integration.
107
+ *
108
+ * If the integrationId is not provided, the `built_in_db` integration id will be used.
109
+ *
110
+ * For more information on the CollectionReference object, please refer to the
111
+ * documentation at {@link https://docs.squid.cloud/docs/development-tools/client-sdk/collection-reference}.
112
+ *
113
+ * @param collectionName The name of the collection.
114
+ * @param integrationId The id of the integration, default to `built_in_db`.
115
+ * @returns A reference to the collection in the provided integration.
116
+ * @typeParam T The type of the documents in the collection.
117
+ */
118
+ collection: <T extends DocumentData>(collectionName: CollectionName, integrationId?: IntegrationId) => CollectionReference<T>;
119
+ /**
120
+ * Runs the given callback as an atomic change. All the mutations that are executed using the provided transactionId
121
+ * will be atomic. Note that mutations for different integrations will not be atomic.
122
+ *
123
+ * For more information about transactions in Squid, please refer to the
124
+ * documentation at {@link https://docs.squid.cloud/docs/development-tools/client-sdk/transactions}.
125
+ *
126
+ * @param fn The callback to run as an atomic change. The function receives a transactionId that should be used for
127
+ * all the mutations that should be atomic. The function should return a promise.
128
+ *
129
+ * @returns A promise that resolves when the transactions are committed on the server.
130
+ */
131
+ runInTransaction: (fn: (transactionId: TransactionId) => Promise<void>) => Promise<void>;
132
+ /**
133
+ * Executes the given backend function with the given parameters and returns a promise with the result.
134
+ *
135
+ * For more information about backend functions in Squid, please refer to the
136
+ * documentation at {@link https://docs.squid.cloud/docs/development-tools/backend/executables}.
137
+ *
138
+ * @param functionName The name of the function to execute on the server.
139
+ * @param params The parameters to pass to the function.
140
+ * @returns A promise that resolves with the result of the function.
141
+ * @typeParam T The type of the result of the function.
142
+ */
143
+ executeFunction: <T = any>(functionName: string, ...params: any[]) => Promise<T>;
144
+ /**
145
+ * Executes the given named query with the given parameters and returns a promise with the result.
146
+ *
147
+ * For more information about named queries in Squid, please refer to the
148
+ * documentation at {@link https://docs.squid.cloud/docs/development-tools/backend/named-queries}.
149
+ *
150
+ * @param integrationId The id of the integration that the named query is defined with.
151
+ * @param queryName The name of the named query.
152
+ * @param params The parameters to pass to the named query.
153
+ * @returns A promise that resolves with the result of the named query.
154
+ * @typeParam T The type of the result of the named query.
155
+ */
156
+ executeNamedQuery: <T = any>(integrationId: IntegrationId, queryName: QueryName, params: Record<string, any>) => Promise<T>;
157
+ /**
158
+ * Invokes the given HTTP API (defined by the integration ID and the endpoint ID) with the given request parameters
159
+ * and returns a promise with the response. The structure of the request and the response is defined in the
160
+ * integration's schema page.
161
+ *
162
+ * For more information about API integrations in Squid, please refer to the
163
+ * documentation at {@link https://docs.squid.cloud/docs/integrations/api/httpapi}.
164
+ *
165
+ * @param integrationId The id of the integration that the API is defined with.
166
+ * @param endpointId The id of the endpoint in the API integration.
167
+ * @param request The request parameters to pass to the API.
168
+ * @returns A promise that resolves with the response of the API.
169
+ * @typeParam T The type of the response of the API.
170
+ */
171
+ callApi: <T = any>(integrationId: IntegrationId, endpointId: ApiEndpointId, request?: Record<string, any>) => Promise<T>;
172
+ /**
173
+ * Returns a GraphQL client for the given integration. The GraphQL client can be used to execute GraphQL queries and
174
+ * mutations. For more information about GraphQL in Squid, please refer to the documentation at
175
+ * {@link https://docs.squid.cloud/docs/integrations/api/graphql}.
176
+ *
177
+ * @param integrationId The id of the integration that the GraphQL API is defined with.
178
+ * @returns A GraphQL client for the given integration.
179
+ */
180
+ graphql: (integrationId: IntegrationId) => GraphQLClient;
181
+ /**
182
+ * Returns a set of AI specific clients. Currently, the only supported client is the AI Assistant, which is accessed
183
+ * through the `assistant`.
184
+ *
185
+ * @returns A set of AI specific clients.
186
+ */
187
+ ai: () => {
188
+ /**
189
+ * Returns an AI Assistant client for the given integration. The AI Assistant client can be used to build and chat
190
+ * with custom AI profiles. For more information about the AI Assistant in Squid, please refer to the documentation
191
+ * at {@link https://docs.squid.cloud/docs/ai/ai-assistant}.
192
+ *
193
+ * @param integrationId The id of the AI Assistant integration.
194
+ * @returns An AI Assistant client.
195
+ */
196
+ assistant: (integrationId: IntegrationId) => AiAssistantClient;
197
+ };
198
+ /**
199
+ * Returns a distributed lock for the given mutex. The lock can be used to synchronize access to a shared resource.
200
+ * The lock will be released when the release method on the returned object is invoked or whenever the connection
201
+ * with the server is lost.
202
+ * @param mutex A string that uniquely identifies the lock.
203
+ * @param exclusive Whether the lock should be exclusive or not. If the lock is exclusive, only one client can hold
204
+ * the lock.
205
+ * @returns A promise that resolves with the lock object. The promise will reject if failed to acquire the lock.
206
+ */
207
+ acquireLock: (mutex: string, exclusive?: boolean) => Promise<DistributedLock>;
208
+ /**
209
+ * Destructs the Squid Client. Unsubscribes from all ongoing queries or requests, and clears the local data.
210
+ * After invoking this method, the Squid client will not be usable.
211
+ *
212
+ * @returns A promise that resolves when the destruct process is complete.
213
+ */
214
+ destruct: () => Promise<void>;
215
+ /** Provides information about the connection to the Squid Server. */
216
+ connectionDetails: () => ConnectionDetails;
217
+ private validateNotDestructed;
218
+ }
@@ -1,7 +1,7 @@
1
- import { BaseAction } from './actions';
2
- export type StateLeafNode = string | boolean | number | null | undefined | object | Array<StateLeafNode> | State;
3
- export type State = {
4
- [key: string]: StateLeafNode;
5
- };
6
- export declare function apply(state: State, action: BaseAction): State;
7
- export declare function isStateObject(state: StateLeafNode): state is State;
1
+ import { BaseAction } from './actions';
2
+ export type StateLeafNode = string | boolean | number | null | undefined | object | Array<StateLeafNode> | State;
3
+ export type State = {
4
+ [key: string]: StateLeafNode;
5
+ };
6
+ export declare function apply(state: State, action: BaseAction): State;
7
+ export declare function isStateObject(state: StateLeafNode): state is State;
@@ -1,29 +1,29 @@
1
- import { StateLeafNode } from './action.applier';
2
- export declare enum ActionType {
3
- DELETE_PATH = "DELETE_PATH",
4
- SET_PATH = "SET_PATH",
5
- BATCH_ACTION = "BATCH_ACTION"
6
- }
7
- export declare interface BaseAction {
8
- type: ActionType;
9
- }
10
- export declare interface PathAction extends BaseAction {
11
- path: string[];
12
- }
13
- export type DeletePathAction = PathAction;
14
- export declare interface SetPathAction extends PathAction {
15
- payload?: StateLeafNode;
16
- }
17
- export declare interface BatchAction extends BaseAction {
18
- payload: BaseAction[];
19
- }
20
- export declare interface StateMessage {
21
- type: 'ACTIONS';
22
- payload: BaseAction[];
23
- }
24
- export declare function isPathAction(action: BaseAction): action is PathAction;
25
- export declare function isSetPathAction(action: BaseAction): action is SetPathAction;
26
- export declare function isDeletePathAction(action: BaseAction): action is DeletePathAction;
27
- export declare function isBatchAction(action: BaseAction): action is BatchAction;
28
- export declare function extractAllPathActions(action: BaseAction): PathAction[];
29
- export declare function getSingleAction(actions: BaseAction[]): BaseAction;
1
+ import { StateLeafNode } from './action.applier';
2
+ export declare enum ActionType {
3
+ DELETE_PATH = "DELETE_PATH",
4
+ SET_PATH = "SET_PATH",
5
+ BATCH_ACTION = "BATCH_ACTION"
6
+ }
7
+ export declare interface BaseAction {
8
+ type: ActionType;
9
+ }
10
+ export declare interface PathAction extends BaseAction {
11
+ path: string[];
12
+ }
13
+ export type DeletePathAction = PathAction;
14
+ export declare interface SetPathAction extends PathAction {
15
+ payload?: StateLeafNode;
16
+ }
17
+ export declare interface BatchAction extends BaseAction {
18
+ payload: BaseAction[];
19
+ }
20
+ export declare interface StateMessage {
21
+ type: 'ACTIONS';
22
+ payload: BaseAction[];
23
+ }
24
+ export declare function isPathAction(action: BaseAction): action is PathAction;
25
+ export declare function isSetPathAction(action: BaseAction): action is SetPathAction;
26
+ export declare function isDeletePathAction(action: BaseAction): action is DeletePathAction;
27
+ export declare function isBatchAction(action: BaseAction): action is BatchAction;
28
+ export declare function extractAllPathActions(action: BaseAction): PathAction[];
29
+ export declare function getSingleAction(actions: BaseAction[]): BaseAction;
@@ -1,27 +1,27 @@
1
- import { BaseAction } from './actions';
2
- export declare class PathTrie<T> {
3
- private root;
4
- getOrCreatePathTrieNode(path: string[], nodeData?: T): PathTrieNode<T>;
5
- getPathTrieNode(path: string[]): PathTrieNode<T> | undefined;
6
- getPathTrie(path: string[]): PathTrie<T> | undefined;
7
- /**
8
- * If the callback returns false, it will not iterate into the children of the current node.
9
- */
10
- iterateBfs(callback: (data: T, path: string[]) => void | boolean): void;
11
- removeNode(path: string[]): void;
12
- clearNodeData(path: string[]): void;
13
- getNodeList(path: string[]): Array<PathTrieNode<T>>;
14
- private iterateInternal;
15
- }
16
- export declare class PathTrieNode<T> {
17
- children: Map<string, PathTrieNode<T>>;
18
- nodeData: T | undefined;
19
- }
20
- /**
21
- * Returns a trie which contains all the paths affected by the action. For
22
- * example, if the action contains a path action applied on path [A, B, C], then
23
- * [A], [A, B], [A, B, C] will be in the returned trie. Moreover, if
24
- * subscriptionTree is provided and contains [A, B, C, ...], then [A, B, C, ...]
25
- * will also be included in the returned trie.
26
- */
27
- export declare function getPathTrieFromAction(action: BaseAction, subscriptionTree?: PathTrie<{}>): PathTrie<boolean>;
1
+ import { BaseAction } from './actions';
2
+ export declare class PathTrie<T> {
3
+ private root;
4
+ getOrCreatePathTrieNode(path: string[], nodeData?: T): PathTrieNode<T>;
5
+ getPathTrieNode(path: string[]): PathTrieNode<T> | undefined;
6
+ getPathTrie(path: string[]): PathTrie<T> | undefined;
7
+ /**
8
+ * If the callback returns false, it will not iterate into the children of the current node.
9
+ */
10
+ iterateBfs(callback: (data: T, path: string[]) => void | boolean): void;
11
+ removeNode(path: string[]): void;
12
+ clearNodeData(path: string[]): void;
13
+ getNodeList(path: string[]): Array<PathTrieNode<T>>;
14
+ private iterateInternal;
15
+ }
16
+ export declare class PathTrieNode<T> {
17
+ children: Map<string, PathTrieNode<T>>;
18
+ nodeData: T | undefined;
19
+ }
20
+ /**
21
+ * Returns a trie which contains all the paths affected by the action. For
22
+ * example, if the action contains a path action applied on path [A, B, C], then
23
+ * [A], [A, B], [A, B, C] will be in the returned trie. Moreover, if
24
+ * subscriptionTree is provided and contains [A, B, C, ...], then [A, B, C, ...]
25
+ * will also be included in the returned trie.
26
+ */
27
+ export declare function getPathTrieFromAction(action: BaseAction, subscriptionTree?: PathTrie<{}>): PathTrie<boolean>;
@@ -1,22 +1,22 @@
1
- import { Observable } from 'rxjs';
2
- import { State, StateLeafNode } from './action.applier';
3
- import { BaseAction } from './actions';
4
- export declare class StateService {
5
- private readonly subscriptionsTree;
6
- private state;
7
- private batchCount;
8
- private readonly batchedActions;
9
- dispatch(action: BaseAction): void;
10
- runInBatch(fn: () => unknown): void;
11
- observePath<T>(path: string[], pathsToExcludeFn?: () => Array<string[]>): Observable<T>;
12
- setKeyInPath<T extends State>(path: string[], key: keyof T & string, value: T[keyof T] & StateLeafNode, noopIfSame?: boolean): void;
13
- setPartial<T extends State>(path: string[], partialState: Partial<T>, noopIfSame?: boolean): void;
14
- setInPath(path: string[], payload: StateLeafNode, noopIfSame?: boolean): void;
15
- pushToArray(path: string[], payload: StateLeafNode): void;
16
- deletePath(path: string[]): void;
17
- getState(): State;
18
- getStateInPath<T extends StateLeafNode>(path: string[]): T;
19
- destroy(): void;
20
- private getOrCreateSubjectForPath;
21
- private dispatchSubscriptions;
22
- }
1
+ import { Observable } from 'rxjs';
2
+ import { State, StateLeafNode } from './action.applier';
3
+ import { BaseAction } from './actions';
4
+ export declare class StateService {
5
+ private readonly subscriptionsTree;
6
+ private state;
7
+ private batchCount;
8
+ private readonly batchedActions;
9
+ dispatch(action: BaseAction): void;
10
+ runInBatch(fn: () => unknown): void;
11
+ observePath<T>(path: string[], pathsToExcludeFn?: () => Array<string[]>): Observable<T>;
12
+ setKeyInPath<T extends State>(path: string[], key: keyof T & string, value: T[keyof T] & StateLeafNode, noopIfSame?: boolean): void;
13
+ setPartial<T extends State>(path: string[], partialState: Partial<T>, noopIfSame?: boolean): void;
14
+ setInPath(path: string[], payload: StateLeafNode, noopIfSame?: boolean): void;
15
+ pushToArray(path: string[], payload: StateLeafNode): void;
16
+ deletePath(path: string[]): void;
17
+ getState(): State;
18
+ getStateInPath<T extends StateLeafNode>(path: string[]): T;
19
+ destroy(): void;
20
+ private getOrCreateSubjectForPath;
21
+ private dispatchSubscriptions;
22
+ }
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1 +1 @@
1
- declare const nodeCrypto: any;
1
+ declare const nodeCrypto: any;
@@ -1,2 +1,2 @@
1
- /** A transactionId - alias for string */
2
- export type TransactionId = string;
1
+ /** A transactionId - alias for string */
2
+ export type TransactionId = string;