@squidcloud/client 1.0.145 → 1.0.146-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/dist/cjs/index.js +1 -53942
  2. package/dist/esm/index.js +1 -0
  3. package/dist/internal-common/src/metric-name.d.ts +9 -0
  4. package/dist/internal-common/src/public-types/ai-agent-integrations.public-types.d.ts +47 -0
  5. package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +895 -0
  6. package/dist/internal-common/src/public-types/ai-assistant.public-types.d.ts +31 -0
  7. package/dist/internal-common/src/public-types/ai-common.public-types.d.ts +185 -0
  8. package/dist/internal-common/src/public-types/ai-knowledge-base.public-types.d.ts +431 -0
  9. package/dist/internal-common/src/public-types/ai-matchmaking.public-types.d.ts +186 -0
  10. package/dist/internal-common/src/public-types/ai-query.public-types.d.ts +170 -0
  11. package/dist/internal-common/src/public-types/api-client.public-types.d.ts +9 -0
  12. package/dist/internal-common/src/public-types/api.public-types.d.ts +91 -0
  13. package/dist/internal-common/src/public-types/backend.public-types.d.ts +50 -0
  14. package/dist/{common/src/backend-function.schemas.d.ts → internal-common/src/public-types/code-executor.public-types.d.ts} +1 -1
  15. package/dist/internal-common/src/public-types/communication.public-types.d.ts +30 -0
  16. package/dist/internal-common/src/public-types/context.public-types.d.ts +83 -0
  17. package/dist/internal-common/src/public-types/document.public-types.d.ts +71 -0
  18. package/dist/internal-common/src/public-types/external-auth/external-auth.public-types.d.ts +39 -0
  19. package/dist/internal-common/src/public-types/extraction.public-types.d.ts +183 -0
  20. package/dist/internal-common/src/public-types/http-status.public-types.d.ts +415 -0
  21. package/dist/internal-common/src/public-types/integration.public-types.d.ts +51 -0
  22. package/dist/internal-common/src/public-types/job.public-types.d.ts +59 -0
  23. package/dist/internal-common/src/public-types/metric.public-types.d.ts +154 -0
  24. package/dist/internal-common/src/public-types/openapi.public-types.d.ts +9 -0
  25. package/dist/internal-common/src/public-types/query.public-types.d.ts +113 -0
  26. package/dist/internal-common/src/public-types/regions.public-types.d.ts +4 -0
  27. package/dist/internal-common/src/public-types/scheduler.public-types.d.ts +43 -0
  28. package/dist/{common/src/schema/schema.types.d.ts → internal-common/src/public-types/schema.public-types.d.ts} +54 -54
  29. package/dist/internal-common/src/public-types/secret.public-types.d.ts +51 -0
  30. package/dist/internal-common/src/public-types/serialized-query.public-types.d.ts +60 -0
  31. package/dist/internal-common/src/public-types/socket.public-types.d.ts +4 -0
  32. package/dist/{common/src/types.d.ts → internal-common/src/public-types/typescript.public-types.d.ts} +20 -14
  33. package/dist/internal-common/src/public-types/web.public-types.d.ts +93 -0
  34. package/dist/internal-common/src/public-types-backend/api-call.public-context.d.ts +30 -0
  35. package/dist/internal-common/src/public-types-backend/mutation.public-context.d.ts +148 -0
  36. package/dist/internal-common/src/public-types-backend/native-query.public-context.d.ts +72 -0
  37. package/dist/{common/src/query/query-context.d.ts → internal-common/src/public-types-backend/query.public-context.d.ts} +177 -137
  38. package/dist/{common/src/ai-chatbot.schemas.d.ts → internal-common/src/public-utils/context-utils.d.ts} +1 -1
  39. package/dist/internal-common/src/public-utils/id-utils.d.ts +44 -0
  40. package/dist/internal-common/src/types/ai-agent.types.d.ts +199 -0
  41. package/dist/{common/src/mutation.schemas.d.ts → internal-common/src/types/ai-assistant.types.d.ts} +1 -1
  42. package/dist/internal-common/src/types/ai-knowledge-base.types.d.ts +202 -0
  43. package/dist/internal-common/src/types/ai-matchmaking.types.d.ts +59 -0
  44. package/dist/{common/src → internal-common/src/types}/backend-function.types.d.ts +1 -1
  45. package/dist/internal-common/src/types/communication.types.d.ts +1 -0
  46. package/dist/internal-common/src/types/document.types.d.ts +1 -0
  47. package/dist/internal-common/src/types/file.types.d.ts +6 -0
  48. package/dist/internal-common/src/types/headers.types.d.ts +17 -0
  49. package/dist/internal-common/src/types/mutation.types.d.ts +1 -0
  50. package/dist/internal-common/src/types/notification.types.d.ts +5 -0
  51. package/dist/internal-common/src/types/observability.types.d.ts +78 -0
  52. package/dist/internal-common/src/types/query.types.d.ts +13 -0
  53. package/dist/internal-common/src/types/secret.types.d.ts +7 -0
  54. package/dist/internal-common/src/types/socket.types.d.ts +1 -0
  55. package/dist/internal-common/src/types/stage.d.ts +9 -0
  56. package/dist/{common/src → internal-common/src/types}/time-units.d.ts +1 -1
  57. package/dist/internal-common/src/types/url-shortener.types.d.ts +41 -0
  58. package/dist/internal-common/src/utils/array.d.ts +7 -0
  59. package/dist/internal-common/src/utils/e2e-test-utils.d.ts +2 -0
  60. package/dist/{common → internal-common}/src/utils/global.utils.d.ts +1 -1
  61. package/dist/internal-common/src/utils/http.d.ts +5 -0
  62. package/dist/{common → internal-common}/src/utils/lock.manager.d.ts +14 -14
  63. package/dist/internal-common/src/utils/metric-utils.d.ts +4 -0
  64. package/dist/internal-common/src/utils/metrics.types.d.ts +7 -0
  65. package/dist/internal-common/src/utils/object.d.ts +58 -0
  66. package/dist/internal-common/src/utils/serialization.d.ts +17 -0
  67. package/dist/internal-common/src/utils/squid.constants.d.ts +1 -0
  68. package/dist/internal-common/src/utils/trace-id-generator.d.ts +1 -0
  69. package/dist/internal-common/src/utils/validation.d.ts +19 -0
  70. package/dist/{common → internal-common}/src/websocket.impl.d.ts +26 -21
  71. package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -1239
  72. package/dist/typescript-client/src/admin-client.d.ts +23 -0
  73. package/dist/typescript-client/src/agent/ai-agent-client-reference.d.ts +181 -0
  74. package/dist/typescript-client/src/agent/ai-agent-client.d.ts +37 -0
  75. package/dist/typescript-client/src/agent/ai-agent-client.types.d.ts +69 -0
  76. package/dist/typescript-client/src/ai-assistant-client.d.ts +72 -73
  77. package/dist/typescript-client/src/ai-audio-client.d.ts +25 -0
  78. package/dist/typescript-client/src/ai-client.d.ts +129 -0
  79. package/dist/typescript-client/src/ai-files-client.d.ts +33 -0
  80. package/dist/typescript-client/src/ai-image-client.d.ts +25 -0
  81. package/dist/typescript-client/src/ai-knowledge-base/ai-knowledge-base-client-reference.d.ts +86 -0
  82. package/dist/typescript-client/src/ai-knowledge-base/ai-knowledge-base-client.d.ts +28 -0
  83. package/dist/typescript-client/src/ai-matchmaking-client.d.ts +99 -0
  84. package/dist/typescript-client/src/api-client.d.ts +69 -0
  85. package/dist/typescript-client/src/auth.manager.d.ts +11 -26
  86. package/dist/typescript-client/src/backend-function.manager.d.ts +1 -9
  87. package/dist/typescript-client/src/client-customization.utils.d.ts +1 -0
  88. package/dist/typescript-client/src/client-id.service.d.ts +1 -27
  89. package/dist/typescript-client/src/collection-reference.d.ts +105 -80
  90. package/dist/typescript-client/src/collection-reference.factory.d.ts +1 -13
  91. package/dist/typescript-client/src/connection-details.d.ts +24 -23
  92. package/dist/typescript-client/src/console-utils.d.ts +1 -0
  93. package/dist/typescript-client/src/data.manager.d.ts +1 -173
  94. package/dist/typescript-client/src/destruct.manager.d.ts +1 -12
  95. package/dist/typescript-client/src/distributed-lock.manager.d.ts +39 -16
  96. package/dist/typescript-client/src/document-identity.service.d.ts +1 -12
  97. package/dist/typescript-client/src/document-reference.d.ts +151 -140
  98. package/dist/typescript-client/src/document-reference.factory.d.ts +1 -13
  99. package/dist/typescript-client/src/document-store.d.ts +1 -14
  100. package/dist/typescript-client/src/execute-function-options.d.ts +73 -0
  101. package/dist/typescript-client/src/external-auth-client.d.ts +36 -0
  102. package/dist/typescript-client/src/extraction-client.d.ts +32 -0
  103. package/dist/typescript-client/src/file-args-transformer.d.ts +1 -0
  104. package/dist/typescript-client/src/file-utils.d.ts +1 -0
  105. package/dist/typescript-client/src/index.d.ts +63 -9
  106. package/dist/typescript-client/src/integration-client.d.ts +60 -0
  107. package/dist/typescript-client/src/job-client.d.ts +32 -0
  108. package/dist/typescript-client/src/mutation/mutation-sender.d.ts +1 -10
  109. package/dist/typescript-client/src/native-query-manager.d.ts +1 -7
  110. package/dist/typescript-client/src/notification-client.d.ts +20 -0
  111. package/dist/typescript-client/src/observability-client.d.ts +43 -0
  112. package/dist/typescript-client/src/public-types.d.ts +30 -0
  113. package/dist/typescript-client/src/public-utils.d.ts +1 -0
  114. package/dist/typescript-client/src/query/deserializer.d.ts +10 -3
  115. package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +316 -161
  116. package/dist/typescript-client/src/query/local-query-manager.d.ts +1 -9
  117. package/dist/{common → typescript-client}/src/query/pagination.d.ts +65 -62
  118. package/dist/typescript-client/src/query/query-builder.factory.d.ts +228 -77
  119. package/dist/typescript-client/src/query/query-sender.d.ts +1 -33
  120. package/dist/typescript-client/src/query/query-subscription.manager.d.ts +1 -130
  121. package/dist/typescript-client/src/query/query.types.d.ts +16 -49
  122. package/dist/typescript-client/src/query/snapshot-emitter.d.ts +41 -0
  123. package/dist/typescript-client/src/query-utils.d.ts +18 -0
  124. package/dist/typescript-client/src/queue.manager.d.ts +12 -0
  125. package/dist/typescript-client/src/rate-limiter.d.ts +1 -32
  126. package/dist/typescript-client/src/rpc.manager.d.ts +1 -30
  127. package/dist/typescript-client/src/scheduler-client.d.ts +31 -0
  128. package/dist/typescript-client/src/secret.client.d.ts +96 -22
  129. package/dist/typescript-client/src/socket.manager.d.ts +1 -43
  130. package/dist/typescript-client/src/squid-http-client.d.ts +11 -0
  131. package/dist/typescript-client/src/squid.d.ts +378 -269
  132. package/dist/typescript-client/src/state/state.service.spec.d.ts +1 -1
  133. package/dist/typescript-client/src/storage-client.d.ts +145 -0
  134. package/dist/typescript-client/src/types.d.ts +27 -2
  135. package/dist/typescript-client/src/version.d.ts +5 -0
  136. package/dist/typescript-client/src/web-client.d.ts +63 -0
  137. package/dist/typescript-client/src/webhook.manager.d.ts +10 -0
  138. package/package.json +34 -18
  139. package/dist/common/src/ai-assistant.types.d.ts +0 -25
  140. package/dist/common/src/ai-chatbot.context.d.ts +0 -12
  141. package/dist/common/src/ai-chatbot.types.d.ts +0 -27
  142. package/dist/common/src/api-call.context.d.ts +0 -13
  143. package/dist/common/src/api.types.d.ts +0 -4
  144. package/dist/common/src/application.schemas.d.ts +0 -66
  145. package/dist/common/src/application.types.d.ts +0 -143
  146. package/dist/common/src/backend-run.types.d.ts +0 -2
  147. package/dist/common/src/bundle-api.types.d.ts +0 -43
  148. package/dist/common/src/bundle-data.types.d.ts +0 -5
  149. package/dist/common/src/communication.types.d.ts +0 -8
  150. package/dist/common/src/context.types.d.ts +0 -40
  151. package/dist/common/src/distributed-lock.context.d.ts +0 -4
  152. package/dist/common/src/document.types.d.ts +0 -22
  153. package/dist/common/src/graphql.context.d.ts +0 -7
  154. package/dist/common/src/graphql.types.d.ts +0 -9
  155. package/dist/common/src/heartbeat.types.d.ts +0 -1
  156. package/dist/common/src/http-status.enum.d.ts +0 -50
  157. package/dist/common/src/index.d.ts +0 -57
  158. package/dist/common/src/integrations/ai_chatbot.types.d.ts +0 -31
  159. package/dist/common/src/integrations/api.types.d.ts +0 -80
  160. package/dist/common/src/integrations/auth.types.d.ts +0 -47
  161. package/dist/common/src/integrations/database.types.d.ts +0 -274
  162. package/dist/common/src/integrations/index.d.ts +0 -134
  163. package/dist/common/src/integrations/observability.types.d.ts +0 -23
  164. package/dist/common/src/logger.types.d.ts +0 -21
  165. package/dist/common/src/metrics.types.d.ts +0 -1
  166. package/dist/common/src/mutation.context.d.ts +0 -14
  167. package/dist/common/src/mutation.types.d.ts +0 -53
  168. package/dist/common/src/named-query.context.d.ts +0 -4
  169. package/dist/common/src/named-query.schemas.d.ts +0 -1
  170. package/dist/common/src/named-query.types.d.ts +0 -1
  171. package/dist/common/src/native-query.context.d.ts +0 -7
  172. package/dist/common/src/native-query.types.d.ts +0 -16
  173. package/dist/common/src/query/base-query-builder.d.ts +0 -147
  174. package/dist/common/src/query/index.d.ts +0 -4
  175. package/dist/common/src/query/serialized-query.types.d.ts +0 -24
  176. package/dist/common/src/query.types.d.ts +0 -64
  177. package/dist/common/src/regions.d.ts +0 -1
  178. package/dist/common/src/secret.schemas.d.ts +0 -1
  179. package/dist/common/src/secret.types.d.ts +0 -22
  180. package/dist/common/src/security.types.d.ts +0 -1
  181. package/dist/common/src/socket.schemas.d.ts +0 -1
  182. package/dist/common/src/socket.types.d.ts +0 -5
  183. package/dist/common/src/trigger.types.d.ts +0 -1
  184. package/dist/common/src/utils/array.d.ts +0 -1
  185. package/dist/common/src/utils/assert.d.ts +0 -1
  186. package/dist/common/src/utils/error.d.ts +0 -4
  187. package/dist/common/src/utils/http.d.ts +0 -2
  188. package/dist/common/src/utils/id.d.ts +0 -2
  189. package/dist/common/src/utils/object.d.ts +0 -5
  190. package/dist/common/src/utils/serialization.d.ts +0 -6
  191. package/dist/common/src/utils/transforms.d.ts +0 -18
  192. package/dist/common/src/utils/url.d.ts +0 -1
  193. package/dist/common/src/utils/validation.d.ts +0 -25
  194. package/dist/common/src/webhook-response.d.ts +0 -1
  195. package/dist/typescript-client/src/ai-chatbot-client.d.ts +0 -174
  196. package/dist/typescript-client/src/ai-chatbot-client.factory.d.ts +0 -8
  197. package/dist/typescript-client/src/ai.types.d.ts +0 -61
  198. package/dist/typescript-client/src/api.manager.d.ts +0 -11
  199. package/dist/typescript-client/src/graphql-client.d.ts +0 -14
  200. package/dist/typescript-client/src/graphql-client.factory.d.ts +0 -11
  201. package/dist/typescript-client/src/named-query.manager.d.ts +0 -11
  202. package/dist/typescript-client/src/state/action.applier.d.ts +0 -7
  203. package/dist/typescript-client/src/state/actions.d.ts +0 -29
  204. package/dist/typescript-client/src/state/path_trie.d.ts +0 -27
  205. package/dist/typescript-client/src/state/state.service.d.ts +0 -22
  206. package/dist/typescript-client/src/testing/setup-tests.d.ts +0 -1
@@ -1,137 +1,177 @@
1
- import { IntegrationId } from '../communication.types';
2
- import { CollectionName, DocumentData } from '../document.types';
3
- import { FieldSort, Operator, Query, SimpleCondition } from '../query.types';
4
- import { DeepRecord, FieldOf, PartialBy, Paths } from '../types';
5
- export declare class QueryContext<T extends DocumentData = any> {
6
- readonly query: Query<T>;
7
- private readonly parsedConditions;
8
- /**
9
- * The ID of the integration being queried.
10
- */
11
- get integrationId(): IntegrationId;
12
- /**
13
- * The name of the collection being queried.
14
- */
15
- get collectionName(): CollectionName;
16
- /**
17
- * The query limit if one exists, -1 otherwise.
18
- */
19
- get limit(): number;
20
- /**
21
- * Verifies that the query's sort order aligns with the provided field sorts. The fields specified in the `sorts`
22
- * parameter must appear in the exact order at the beginning of the query's sort sequence. The query can include
23
- * additional fields in its sort order, but only after the specified sorts.
24
- *
25
- * @param sorts An array of field sorts.
26
- * @returns Whether the query's sorts matches the provided field sorts.
27
- */
28
- sortedBy(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
29
- /**
30
- * Verifies that the query's sort order exactly matches the provided field sorts. The fields specified in the
31
- * `sorts` parameter must appear in the exact order in the query's sort sequence. No additional sorts may be present
32
- * in the query.
33
- *
34
- * @param sorts An array of field sorts.
35
- * @returns Whether the query's sorts exactly match the provided field sorts.
36
- */
37
- sortedByExact(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
38
- /**
39
- * Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
40
- * to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
41
- * additional conditions, as these only narrow the result set.
42
- *
43
- * @param fieldName The name of the field for the condition.
44
- * @param operator The operator of the condition.
45
- * @param value The value of the condition.
46
- * @returns Whether the query is a subquery of the parent condition.
47
- */
48
- isSubqueryOf<F extends Paths<T>, O extends AllOperators>(fieldName: F, operator: O, value: GenericValue<T, F, O> | null): boolean;
49
- /**
50
- * Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
51
- * to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
52
- * additional conditions, as these only narrow the result set.
53
- *
54
- * @param condition The condition to validate.
55
- * @returns Whether the query is a subquery of the parent condition.
56
- */
57
- isSubqueryOfCondition(condition: GeneralCondition<T>): boolean;
58
- /**
59
- * Verifies that the query is a subquery of the specified conditions. A subquery is defined as a query that evaluates
60
- * to a subset of the results that would be obtained by applying the parent conditions. The subquery may also include
61
- * additional conditions, as these only narrow the result set.
62
- *
63
- * @param conditions The conditions to validate.
64
- * @returns Whether the query includes subquery of the parent conditions.
65
- */
66
- isSubqueryOfConditions(conditions: GeneralConditions<T>): boolean;
67
- /**
68
- * Verifies that the query is a subquery of the specified query. A subquery is defined as a query that evaluates
69
- * to a subset of the results that obtained for the parent query, including sorts and limits.
70
- *
71
- * @param query The query to validate.
72
- * @returns Whether the query is a subquery of the parent query.
73
- */
74
- isSubqueryOfQuery(query: Query<T>): boolean;
75
- /**
76
- * Returns all conditions that apply to any of the specified field names. This method
77
- * provides a convenient way to retrieve all conditions that involve a specific set of fields.
78
- *
79
- * @param fieldNames The field names for which to retrieve conditions.
80
- * @returns An array of conditions that involve any of the specified field names.
81
- */
82
- getConditionsFor<K extends Paths<T>>(...fieldNames: Array<K>): ContextConditions<T, K>;
83
- /**
84
- * Returns all conditions that apply to the specified field name. This method provides
85
- * a convenient way to retrieve all conditions that involve a specific field.
86
- *
87
- * @param fieldName The field name for which to retrieve conditions.
88
- * @returns An array of conditions that involve the specified field name.
89
- */
90
- getConditionsForField<K extends Paths<T>>(fieldName: K): ContextConditions<T>;
91
- /**
92
- * Returns true if the given document can be a result of the query.
93
- * The method does not account for limit and sort order.
94
- */
95
- documentMatchesQuery(doc: DocumentData): boolean;
96
- /**
97
- * Compares a condition against a given operator and value to determine if the
98
- * provided condition is a subset of the operator and value. A condition is
99
- * considered a subset if all values that satisfy (return true for) the
100
- * condition also satisfy the operator and value.
101
- *
102
- * This is done using the underlying CompareTable, which provides a comparison
103
- * function for each operator pair, or undefined if the comparison would
104
- * always be false, regardless of the values.
105
- */
106
- private evaluateSubset;
107
- private evaluateIncludes;
108
- private parseConditions;
109
- }
110
- /** A list of context conditions */
111
- export type ContextConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<ContextCondition<Doc, F>>;
112
- /** A Context condition - a condition that replaces multiple '==' or '!=' conditions with 'in' and 'not in'. */
113
- type ContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = InContextCondition<Doc, F> | NotInContextCondition<Doc, F> | OtherContextCondition<Doc, F>;
114
- interface InContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'in'> {
115
- operator: 'in';
116
- value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
117
- }
118
- interface NotInContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'not in'> {
119
- operator: 'not in';
120
- value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
121
- }
122
- interface OtherContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, Exclude<ContextOperator, 'in' | 'not in'>> {
123
- operator: Exclude<ContextOperator, 'in' | 'not in'>;
124
- value: FieldOf<DeepRecord<Doc>, Paths<Doc>> | any;
125
- }
126
- /** A condition that includes the 'in' and 'not in' operators. */
127
- interface GeneralCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, AllOperators> {
128
- operator: AllOperators;
129
- value: any;
130
- }
131
- /** A list of general conditions. */
132
- type GeneralConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<GeneralCondition<Doc, F>>;
133
- type ContextOperator = Exclude<Operator, '==' | '!='> | 'in' | 'not in';
134
- type AllOperators = Operator | 'in' | 'not in';
135
- /** A generic value that can exist in a query. */
136
- type GenericValue<Doc = any, F extends Paths<Doc> = Paths<Doc>, O extends AllOperators = any> = O extends 'in' ? Array<DeepRecord<Doc>[F]> | null : O extends 'not in' ? Array<DeepRecord<Doc>[F]> | null : DeepRecord<Doc>[F] | null;
137
- export {};
1
+ import { AiQueryOptions } from '../public-types/ai-query.public-types';
2
+ import { IntegrationId } from '../public-types/communication.public-types';
3
+ import { CollectionName, DocumentData } from '../public-types/document.public-types';
4
+ import { FieldSort, Operator, Query, SimpleCondition } from '../public-types/query.public-types';
5
+ import { DeepRecord, FieldOf, PartialBy, Paths } from '../public-types/typescript.public-types';
6
+ /**
7
+ * The information provided to the secureAiQuery function about the AI query being executed.
8
+ * @category AI
9
+ */
10
+ export interface AiQueryContext {
11
+ /** The prompt provided for the AI query. */
12
+ prompt: string;
13
+ /** The options used for executing the AI query. */
14
+ options: AiQueryOptions;
15
+ }
16
+ /**
17
+ * Represents the Squid query context.
18
+ * Passed to methods that require query details, such as those annotated with the `@secureCollection` annotation.
19
+ * @category Database
20
+ */
21
+ export declare class QueryContext<T extends DocumentData = any> {
22
+ readonly query: Query<T>;
23
+ /**
24
+ * The ID of the integration being queried.
25
+ */
26
+ get integrationId(): IntegrationId;
27
+ /**
28
+ * The name of the collection being queried.
29
+ */
30
+ get collectionName(): CollectionName;
31
+ /**
32
+ * The query limit if one exists, -1 otherwise.
33
+ */
34
+ get limit(): number;
35
+ /**
36
+ * Verifies that the query's sort order aligns with the provided field sorts. The fields specified in the `sorts`
37
+ * parameter must appear in the exact order at the beginning of the query's sort sequence. The query can include
38
+ * additional fields in its sort order, but only after the specified sorts.
39
+ *
40
+ * @param sorts An array of field sorts.
41
+ * @returns Whether the query's sorts matches the provided field sorts.
42
+ */
43
+ sortedBy(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
44
+ /**
45
+ * Verifies that the query's sort order exactly matches the provided field sorts. The fields specified in the
46
+ * `sorts` parameter must appear in the exact order in the query's sort sequence. No additional sorts may be present
47
+ * in the query.
48
+ *
49
+ * @param sorts An array of field sorts.
50
+ * @returns Whether the query's sorts exactly match the provided field sorts.
51
+ */
52
+ sortedByExact(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
53
+ /**
54
+ * Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
55
+ * to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
56
+ * additional conditions, as these only narrow the result set.
57
+ *
58
+ * @param fieldName The name of the field for the condition.
59
+ * @param operator The operator of the condition.
60
+ * @param value The value of the condition.
61
+ * @returns Whether the query is a subquery of the parent condition.
62
+ */
63
+ isSubqueryOf<F extends Paths<T>, O extends AllOperators>(fieldName: F, operator: O, value: GenericValue<T, F, O> | null): boolean;
64
+ /**
65
+ * Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
66
+ * to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
67
+ * additional conditions, as these only narrow the result set.
68
+ *
69
+ * @param condition The condition to validate.
70
+ * @returns Whether the query is a subquery of the parent condition.
71
+ */
72
+ isSubqueryOfCondition(condition: GeneralCondition<T>): boolean;
73
+ /**
74
+ * Verifies that the query is a subquery of the specified conditions. A subquery is defined as a query that evaluates
75
+ * to a subset of the results that would be obtained by applying the parent conditions. The subquery may also include
76
+ * additional conditions, as these only narrow the result set.
77
+ *
78
+ * @param conditions The conditions to validate.
79
+ * @returns Whether the query includes subquery of the parent conditions.
80
+ */
81
+ isSubqueryOfConditions(conditions: GeneralConditions<T>): boolean;
82
+ /**
83
+ * Verifies that the query is a subquery of the specified query. A subquery is defined as a query that evaluates
84
+ * to a subset of the results that obtained for the parent query, including sorts and limits.
85
+ *
86
+ * @param query The query to validate.
87
+ * @returns Whether the query is a subquery of the parent query.
88
+ */
89
+ isSubqueryOfQuery(query: Query<T>): boolean;
90
+ /**
91
+ * Returns all conditions that apply to any of the specified field names. This method
92
+ * provides a convenient way to retrieve all conditions that involve a specific set of fields.
93
+ *
94
+ * @param fieldNames The field names for which to retrieve conditions.
95
+ * @returns An array of conditions that involve any of the specified field names.
96
+ */
97
+ getConditionsFor<K extends Paths<T>>(...fieldNames: Array<K>): ContextConditions<T, K>;
98
+ /**
99
+ * Returns all conditions that apply to the specified field name. This method provides
100
+ * a convenient way to retrieve all conditions that involve a specific field.
101
+ *
102
+ * @param fieldName The field name for which to retrieve conditions.
103
+ * @returns An array of conditions that involve the specified field name.
104
+ */
105
+ getConditionsForField<K extends Paths<T>>(fieldName: K): ContextConditions<T>;
106
+ /**
107
+ * Returns true if the given document can be a result of the query.
108
+ * The method does not account for limit and sort order.
109
+ */
110
+ documentMatchesQuery(doc: DocumentData): boolean;
111
+ }
112
+ /**
113
+ * A list of context conditions.
114
+ * @category Database
115
+ */
116
+ export type ContextConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<ContextCondition<Doc, F>>;
117
+ /**
118
+ * A Context condition - a condition that replaces multiple '==' or '!=' conditions with 'in' and 'not in'.
119
+ * @category Database
120
+ */
121
+ export type ContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = InContextCondition<Doc, F> | NotInContextCondition<Doc, F> | OtherContextCondition<Doc, F>;
122
+ /**
123
+ * A condition using the 'in' operator to match values within a set.
124
+ * @category Database
125
+ */
126
+ export interface InContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'in'> {
127
+ /** Specifies the 'in' operator to check if a value exists within an array. */
128
+ operator: 'in';
129
+ /** An array of values to match against the field. */
130
+ value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
131
+ }
132
+ /**
133
+ * A condition using the 'not in' operator to exclude values within a set.
134
+ * @category Database
135
+ */
136
+ export interface NotInContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'not in'> {
137
+ /** Specifies the 'not in' operator to check if a value does not exist within an array. */
138
+ operator: 'not in';
139
+ /** An array of values to exclude from the field. */
140
+ value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
141
+ }
142
+ /**
143
+ * A condition using operators other than 'in' or 'not in' for field comparisons.
144
+ * @category Database
145
+ */
146
+ export interface OtherContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, Exclude<ContextOperator, 'in' | 'not in'>> {
147
+ /** The operator to use for the comparison, excluding 'in' and 'not in'. */
148
+ operator: Exclude<ContextOperator, 'in' | 'not in'>;
149
+ /** The value to compare against the field. */
150
+ value: FieldOf<DeepRecord<Doc>, Paths<Doc>> | any;
151
+ }
152
+ /**
153
+ * A condition that includes all operators, including 'in' and 'not in', for general use.
154
+ * @category Database
155
+ */
156
+ export interface GeneralCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, AllOperators> {
157
+ /** The operator to apply to the condition, including all possible operators. */
158
+ operator: AllOperators;
159
+ /** The value to use in the condition comparison. */
160
+ value: any;
161
+ }
162
+ /**
163
+ * A list of general conditions.
164
+ * @category Database
165
+ */
166
+ export type GeneralConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<GeneralCondition<Doc, F>>;
167
+ /**
168
+ * @category Database
169
+ */
170
+ export type ContextOperator = Exclude<Operator, '==' | '!='> | 'in' | 'not in';
171
+ type AllOperators = Operator | 'in' | 'not in';
172
+ /**
173
+ * A generic value that can exist in a query.
174
+ * @category Database
175
+ */
176
+ export type GenericValue<Doc = any, F extends Paths<Doc> = Paths<Doc>, O extends AllOperators = any> = O extends 'in' ? Array<DeepRecord<Doc>[F]> | null : O extends 'not in' ? Array<DeepRecord<Doc>[F]> | null : DeepRecord<Doc>[F] | null;
177
+ export {};
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Generates a random RFC 4122 version 4 UUID.
3
+ * The UUID is generated using a cryptographic pseudorandom number generator.
4
+ */
5
+ export declare function generateUUID(): string;
6
+ /**
7
+ * Generates a UUID-style ID.
8
+ * @deprecated Use `generateUUID` instead.
9
+ */
10
+ export declare function generateId(): string;
11
+ /** Default length if ID produced by `generateShortId`. */
12
+ export declare const DEFAULT_SHORT_ID_LENGTH = 18;
13
+ /**
14
+ * Generates an ID of the given `length` using lowercase latin letters and digits.
15
+ * If the 'prefix' provided replaces the first generated characters with the prefix.
16
+ * If the 'prefixToAvoid' provided, ensures the generated ID does not start with this prefix.
17
+ * When both 'prefix' and 'prefixToAvoid' are provided, 'prefixToAvoid' must be longer than 'prefix'.
18
+ */
19
+ export declare function generateShortId(length?: number, prefix?: string, prefixToAvoid?: string): string;
20
+ /**
21
+ * Generates a set of unique IDs under the same behavior as `generateShortId`.
22
+ *
23
+ * @param length The length of the ID to be generated. Default is 18.
24
+ * @param prefix The prefix of the generated ID. Default is an empty string.
25
+ * @param count The number of IDs to be generated.
26
+ */
27
+ export declare function generateShortIds({ count, length, prefix }: GenerateShortIdsOptions): string[];
28
+ /**
29
+ * Options for generating multiple short IDs.
30
+ */
31
+ export interface GenerateShortIdsOptions {
32
+ /** The number of IDs to generate. */
33
+ count: number;
34
+ /**
35
+ * The length of each generated ID.
36
+ * @default DEFAULT_SHORT_ID_LENGTH.
37
+ */
38
+ length?: number;
39
+ /**
40
+ * A string that must be a predefined prefix for each ID. Replaces the first generated characters.
41
+ * @default - no prefix.
42
+ */
43
+ prefix?: string;
44
+ }
@@ -0,0 +1,199 @@
1
+ import { AgentContextRequest, AiAgent, AiAgentContext, AiAnnotation, AiAudioCreateSpeechOptions, AiChatMessage, AiChatOptions, AiGenerateImageOptions, AllAiAgentChatOptions, ApplicationAiSettings } from '../public-types/ai-agent.public-types';
2
+ import { AiChatModelName, AiEmbeddingsModelName, AiProviderType } from '../public-types/ai-common.public-types';
3
+ import { AiContextMetadata, AiContextMetadataFilter } from '../public-types/ai-knowledge-base.public-types';
4
+ import { AiAgentId, AiKnowledgeBaseId, AppId, ClientRequestId } from '../public-types/communication.public-types';
5
+ import { JobId } from '../public-types/job.public-types';
6
+ import { SecretKey } from '../public-types/secret.public-types';
7
+ /** Specification for an AI model, defining its operational parameters. */
8
+ export type AiModelSpec = {
9
+ /** Maximum tokens the model can generate in a single response. */
10
+ maxOutputTokens: number;
11
+ /** Total context window size: input (aka prompt) + output (aka completion) tokens combined. */
12
+ contextWindowTokens: number;
13
+ };
14
+ /** Map of AI model details by model name. */
15
+ export declare const AI_VENDOR_MODEL_SPECS: Record<AiChatModelName, AiModelSpec>;
16
+ /** Map of embedding AI model specs by model name. */
17
+ export declare const AI_VENDOR_EMBEDDING_MODEL_SPECS: Record<AiEmbeddingsModelName, AiModelSpec>;
18
+ export interface AiChatRequest {
19
+ agentId: AiAgentId;
20
+ clientRequestId: ClientRequestId;
21
+ prompt?: string;
22
+ options?: AllAiAgentChatOptions;
23
+ jobId: JobId;
24
+ }
25
+ export interface AiAskRequest {
26
+ agentId: AiAgentId;
27
+ prompt?: string;
28
+ options?: AllAiAgentChatOptions;
29
+ jobId: JobId;
30
+ }
31
+ export interface AiGenerateImageRequest {
32
+ prompt: string;
33
+ options: AiGenerateImageOptions;
34
+ }
35
+ export interface AiAskQuestionInternalRequest {
36
+ appId: AppId;
37
+ prompt: string;
38
+ options: AiChatOptions;
39
+ }
40
+ export interface AiAskQuestionInternalResponse {
41
+ answer: string;
42
+ }
43
+ export interface GetSharedAgentsInternalRequest {
44
+ organizationId: string;
45
+ }
46
+ export interface GetSharedAgentsInternalResponse {
47
+ sharedAgents: Array<{
48
+ agentId: AiAgentId;
49
+ appId: AppId;
50
+ }>;
51
+ }
52
+ export interface ClearSharedAgentsForOrgInternalRequest {
53
+ organizationId: string;
54
+ }
55
+ export interface AiContextSizeRequest {
56
+ appId: AppId;
57
+ agentId: AiAgentId;
58
+ }
59
+ export interface AiContextSizeResponse {
60
+ sizeBytes: number;
61
+ }
62
+ export interface AiAskResponse {
63
+ responseString: string;
64
+ annotations?: Record<string, AiAnnotation>;
65
+ }
66
+ export interface AiAskWithVoiceResponse {
67
+ responseString: string;
68
+ voiceResponse: AiAudioCreateSpeechResponse;
69
+ annotations?: Record<string, AiAnnotation>;
70
+ }
71
+ export interface AiTranscribeAndAskWithVoiceResponse {
72
+ transcribedPrompt: string;
73
+ responseString: string;
74
+ voiceResponse: AiAudioCreateSpeechResponse;
75
+ annotations?: Record<string, AiAnnotation>;
76
+ }
77
+ export interface AiTranscribeAndChatResponse {
78
+ transcribedPrompt: string;
79
+ }
80
+ export interface AiAudioCreateSpeechResponse {
81
+ mimeType: string;
82
+ extension: string;
83
+ base64File: string;
84
+ }
85
+ export interface AiAudioCreateSpeechRequest {
86
+ input: string;
87
+ options: AiAudioCreateSpeechOptions;
88
+ }
89
+ export interface GetAgentRequest {
90
+ agentId: AiAgentId;
91
+ }
92
+ export interface GetAgentResponse {
93
+ agent: AiAgent | undefined;
94
+ }
95
+ export interface GetAgentContextRequest {
96
+ agentId: AiAgentId;
97
+ contextId: string;
98
+ }
99
+ export interface ConnectAgentKnowledgeBaseRequest {
100
+ agentId: AiAgentId;
101
+ knowledgeBaseId: AiKnowledgeBaseId;
102
+ description: string;
103
+ }
104
+ export interface DisconnectAgentKnowledgeBaseRequest {
105
+ agentId: AiAgentId;
106
+ knowledgeBaseId: AiKnowledgeBaseId;
107
+ }
108
+ export interface DeleteAgentRequest {
109
+ agentId: AiAgentId;
110
+ }
111
+ export interface UnshareAgentRequest {
112
+ agentId: AiAgentId;
113
+ }
114
+ export interface SetAgentOptionInPathRequest {
115
+ agentId: AiAgentId;
116
+ path: string;
117
+ value: unknown;
118
+ }
119
+ export interface ListAgentContextsRequest {
120
+ agentId: AiAgentId;
121
+ }
122
+ export interface ListAgentContextsResponse {
123
+ contexts: Array<AiAgentContext>;
124
+ }
125
+ export interface DeleteAgentContextsRequest {
126
+ agentId: AiAgentId;
127
+ contextIds: Array<string>;
128
+ }
129
+ export interface UpsertAgentContextsRequest {
130
+ agentId: AiAgentId;
131
+ contextRequests: Array<AgentContextRequest>;
132
+ }
133
+ export interface UpsertAgentCustomGuardrailsRequest {
134
+ agentId: AiAgentId;
135
+ customGuardrail: string;
136
+ }
137
+ export interface DeleteAgentCustomGuardrailsRequest {
138
+ agentId: AiAgentId;
139
+ }
140
+ export interface ListAgentsResponse {
141
+ agents: Array<AiAgent>;
142
+ }
143
+ export interface GetApplicationAiSettingsResponse {
144
+ settings: ApplicationAiSettings;
145
+ }
146
+ export interface GetApplicationAiSettingsResponse {
147
+ settings: ApplicationAiSettings;
148
+ }
149
+ export interface SetApplicationAiSettingsRequest {
150
+ settings: ApplicationAiSettings;
151
+ }
152
+ export interface SetAiProviderApiKeySecretRequest {
153
+ providerType: AiProviderType;
154
+ secretKey: SecretKey | undefined;
155
+ }
156
+ export interface SetAiProviderApiKeySecretResponse {
157
+ settings: ApplicationAiSettings;
158
+ }
159
+ export interface RegenerateAgentApiKeyRequest {
160
+ agentId: AiAgentId;
161
+ }
162
+ export interface GetAgentApiKeyRequest {
163
+ agentId: AiAgentId;
164
+ }
165
+ export declare function validateAiContextMetadata(metadata: AiContextMetadata): void;
166
+ export declare function validateAiContextMetadataFilter(filter: AiContextMetadataFilter): void;
167
+ export declare const METADATA_SERVICE_FUNCTION_NAME = "default:metadata";
168
+ export interface UpdateApplicationAiSettingsWebhookPayload {
169
+ appId: AppId;
170
+ aiSettings: ApplicationAiSettings;
171
+ }
172
+ export interface GetChatHistoryRequest {
173
+ agentId: AiAgentId;
174
+ memoryId: string;
175
+ }
176
+ export interface GetChatHistoryResponse {
177
+ messages: Array<AiChatMessage>;
178
+ }
179
+ export interface ProvideAgentFeedbackRequest {
180
+ agentId: string;
181
+ feedback: string;
182
+ }
183
+ export interface UploadAiFileRequest {
184
+ /** AI provider to upload file to. */
185
+ provider: AiProviderType;
186
+ /** Optional expiration time in seconds. If provided, file will be registered for automatic cleanup. */
187
+ expirationInSeconds?: number;
188
+ }
189
+ export interface UploadAiFileResponse {
190
+ fileId: string;
191
+ }
192
+ export interface DeleteAiFileRequest {
193
+ fileId: string;
194
+ /** AI provider that owns the file. */
195
+ provider: AiProviderType;
196
+ }
197
+ export interface DeleteAiFileResponse {
198
+ deleted: boolean;
199
+ }