@squidcloud/client 1.0.80 → 1.0.82

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 (102) hide show
  1. package/dist/cjs/index.js +5 -5
  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 +2 -2
  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 +1 -1
  8. package/dist/common/src/application.types.d.ts +184 -184
  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 +54 -54
  23. package/dist/common/src/integrations/ai_assistant.types.d.ts +30 -30
  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 +236 -236
  27. package/dist/common/src/integrations/index.d.ts +101 -101
  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/{simple-query-builder.d.ts → base-query-builder.d.ts} +122 -117
  38. package/dist/common/src/query/index.d.ts +2 -2
  39. package/dist/common/src/query/query-context.d.ts +109 -109
  40. package/dist/common/src/query.schemas.d.ts +3 -3
  41. package/dist/common/src/query.types.d.ts +57 -57
  42. package/dist/common/src/regions.d.ts +1 -1
  43. package/dist/common/src/schema/schema.types.d.ts +54 -54
  44. package/dist/common/src/secret.schemas.d.ts +1 -1
  45. package/dist/common/src/secret.types.d.ts +8 -8
  46. package/dist/common/src/security.types.d.ts +1 -1
  47. package/dist/common/src/socket.schemas.d.ts +1 -1
  48. package/dist/common/src/socket.types.d.ts +1 -1
  49. package/dist/common/src/time-units.d.ts +1 -1
  50. package/dist/common/src/trigger.types.d.ts +1 -1
  51. package/dist/common/src/types.d.ts +8 -8
  52. package/dist/common/src/utils/array.d.ts +1 -1
  53. package/dist/common/src/utils/assert.d.ts +1 -1
  54. package/dist/common/src/utils/error.d.ts +4 -4
  55. package/dist/common/src/utils/http.d.ts +2 -2
  56. package/dist/common/src/utils/id.d.ts +2 -2
  57. package/dist/common/src/utils/lock.manager.d.ts +14 -14
  58. package/dist/common/src/utils/nullish.d.ts +1 -1
  59. package/dist/common/src/utils/object.d.ts +6 -6
  60. package/dist/common/src/utils/serialization.d.ts +6 -6
  61. package/dist/common/src/utils/transforms.d.ts +18 -18
  62. package/dist/common/src/utils/url.d.ts +1 -1
  63. package/dist/common/src/utils/validation.d.ts +30 -30
  64. package/dist/common/src/webhook-response.d.ts +1 -1
  65. package/dist/esm/index.js +5 -5
  66. package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -1239
  67. package/dist/typescript-client/src/ai-assistant-client.d.ts +167 -167
  68. package/dist/typescript-client/src/ai-client.factory.d.ts +11 -11
  69. package/dist/typescript-client/src/api.manager.d.ts +15 -15
  70. package/dist/typescript-client/src/auth.manager.d.ts +23 -23
  71. package/dist/typescript-client/src/backend-function.manager.d.ts +13 -13
  72. package/dist/typescript-client/src/client-id.service.d.ts +25 -25
  73. package/dist/typescript-client/src/collection-reference.d.ts +82 -80
  74. package/dist/typescript-client/src/collection-reference.factory.d.ts +13 -13
  75. package/dist/typescript-client/src/connection-details.d.ts +23 -23
  76. package/dist/typescript-client/src/data.manager.d.ts +172 -172
  77. package/dist/typescript-client/src/destruct.manager.d.ts +12 -12
  78. package/dist/typescript-client/src/distributed-lock.manager.d.ts +19 -19
  79. package/dist/typescript-client/src/document-identity.service.d.ts +12 -12
  80. package/dist/typescript-client/src/document-reference.d.ts +134 -134
  81. package/dist/typescript-client/src/document-reference.factory.d.ts +12 -12
  82. package/dist/typescript-client/src/document-store.d.ts +11 -11
  83. package/dist/typescript-client/src/graphql-client.d.ts +12 -12
  84. package/dist/typescript-client/src/graphql-client.factory.d.ts +9 -9
  85. package/dist/typescript-client/src/index.d.ts +8 -8
  86. package/dist/typescript-client/src/mutation/mutation-sender.d.ts +10 -10
  87. package/dist/typescript-client/src/named-query.manager.d.ts +12 -12
  88. package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +110 -72
  89. package/dist/typescript-client/src/query/query-builder.factory.d.ts +64 -89
  90. package/dist/typescript-client/src/query/query-subscription.manager.d.ts +135 -135
  91. package/dist/typescript-client/src/query/query.types.d.ts +14 -14
  92. package/dist/typescript-client/src/rpc.manager.d.ts +28 -28
  93. package/dist/typescript-client/src/socket.manager.d.ts +32 -32
  94. package/dist/typescript-client/src/squid.d.ts +217 -218
  95. package/dist/typescript-client/src/state/action.applier.d.ts +7 -7
  96. package/dist/typescript-client/src/state/actions.d.ts +29 -29
  97. package/dist/typescript-client/src/state/path_trie.d.ts +27 -27
  98. package/dist/typescript-client/src/state/state.service.d.ts +22 -22
  99. package/dist/typescript-client/src/state/state.service.spec.d.ts +1 -1
  100. package/dist/typescript-client/src/testing/setup-tests.d.ts +1 -1
  101. package/dist/typescript-client/src/types.d.ts +2 -2
  102. package/package.json +1 -1
@@ -1,117 +1,122 @@
1
- import { IntegrationId } from '../communication.types';
2
- import { CollectionName, DocumentData, FieldName, PrimitiveFieldType } from '../document.types';
3
- import { Operator, Query } from '../query.types';
4
- /** Base interface for a query builder. */
5
- export declare abstract class BaseQueryBuilderInterface<MyDocType extends DocumentData> {
6
- /**
7
- * Adds a condition to the query.
8
- * @param fieldName The name of the field to query.
9
- * @param operator The operator to use.
10
- * @param value The value to compare against.
11
- * @returns The query builder.
12
- */
13
- abstract where(fieldName: (keyof MyDocType & FieldName) | string, operator: Operator | 'in' | 'not in', value: PrimitiveFieldType | Array<PrimitiveFieldType>): this;
14
- /**
15
- * A shortcut for where(fieldName, '==', value)
16
- *
17
- * @param fieldName The name of the field to query.
18
- * @param value The value to compare against.
19
- * @returns The query builder.
20
- */
21
- eq(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
22
- /**
23
- * A shortcut for where(fieldName, '!=', value)
24
- * @param fieldName The name of the field to query.
25
- * @param value The value to compare against.
26
- * @returns The query builder.
27
- */
28
- neq(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
29
- /**
30
- * A shortcut for where(fieldName, 'in', value)
31
- * @param fieldName The name of the field to query.
32
- * @param value An array of values to compare against.
33
- * @returns The query builder.
34
- */
35
- in(fieldName: (keyof MyDocType & FieldName) | string, value: Array<PrimitiveFieldType>): this;
36
- /**
37
- * A shortcut for where(fieldName, 'not in', value)
38
- * @param fieldName The name of the field to query.
39
- * @param value An array of values to compare against.
40
- * @returns The query builder.
41
- */
42
- nin(fieldName: (keyof MyDocType & FieldName) | string, value: Array<PrimitiveFieldType>): this;
43
- /**
44
- * A shortcut for where(fieldName, '>', value)
45
- * @param fieldName The name of the field to query.
46
- * @param value The value to compare against.
47
- * @returns The query builder.
48
- */
49
- gt(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
50
- /**
51
- * A shortcut for where(fieldName, '>=', value)
52
- * @param fieldName The name of the field to query.
53
- * @param value The value to compare against.
54
- * @returns The query builder.
55
- */
56
- gte(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
57
- /**
58
- * A shortcut for where(fieldName, '<', value)
59
- * @param fieldName The name of the field to query.
60
- * @param value The value to compare against.
61
- * @returns The query builder.
62
- */
63
- lt(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
64
- /**
65
- * A shortcut for where(fieldName, '<=', value)
66
- * @param fieldName The name of the field to query.
67
- * @param value The value to compare against.
68
- * @returns The query builder.
69
- */
70
- lte(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
71
- /**
72
- * A shortcut for where(fieldName, 'like', pattern).
73
- *
74
- * @param fieldName The name of the field to query.
75
- * @param pattern The pattern to compare against. '%' is the only allowed wildcard
76
- * @param caseSensitive Whether to use case-sensitive comparison. Defaults to true.
77
- * @returns The query builder.
78
- */
79
- like(fieldName: (keyof MyDocType & FieldName) | string, pattern: string, caseSensitive?: boolean): this;
80
- /**
81
- * A shortcut for where(fieldName, 'not like', pattern).
82
- *
83
- * @param fieldName The name of the field to query.
84
- * @param pattern The pattern to compare against. '%' is the only allowed wildcard
85
- * @param caseSensitive Whether to use case-sensitive comparison. Defaults to true.
86
- * @returns The query builder.
87
- */
88
- notLike(fieldName: (keyof MyDocType & FieldName) | string, pattern: string, caseSensitive?: boolean): this;
89
- /**
90
- * Sets a limit to the number of results returned by the query. The maximum limit is 20,000 and the default is 1,000
91
- * if none is provided.
92
- * @param limit The limit to set.
93
- * @returns The query builder.
94
- */
95
- abstract limit(limit: number): this;
96
- /**
97
- * Adds a sort order to the query. You can add multiple sort orders to the query. The order in which you add them
98
- * determines the order in which they are applied.
99
- * @param fieldName The name of the field to sort by.
100
- * @param asc Whether to sort in ascending order. Defaults to true.
101
- * @returns The query builder.
102
- */
103
- abstract sortBy(fieldName: keyof MyDocType & FieldName, asc?: boolean): this;
104
- }
105
- /** A query builder that can be used to build a query that returns a list of documents. */
106
- export declare class SimpleQueryBuilder<MyDocType extends DocumentData> extends BaseQueryBuilderInterface<MyDocType> {
107
- protected readonly collectionName: CollectionName;
108
- protected readonly integrationId: IntegrationId;
109
- protected readonly query: Query<MyDocType>;
110
- /** @inheritDoc */
111
- where(fieldName: (keyof MyDocType & FieldName) | string, operator: Operator | 'in' | 'not in', value: PrimitiveFieldType | Array<PrimitiveFieldType>): this;
112
- /** @inheritDoc */
113
- limit(limit: number): this;
114
- /** @inheritDoc */
115
- sortBy(fieldName: keyof MyDocType & FieldName, asc?: boolean): this;
116
- private mergeConditions;
117
- }
1
+ import { DocumentData, FieldName, PrimitiveFieldType } from '../document.types';
2
+ import { Operator } from '../query.types';
3
+ import { Observable } from 'rxjs';
4
+ export interface SnapshotEmitter<ReturnType> {
5
+ /**
6
+ * Returns a promise that resolves to the query results.
7
+ *
8
+ * @returns A promise that resolves to the query results.
9
+ */
10
+ snapshot(): Promise<Array<ReturnType>>;
11
+ /**
12
+ * Returns an observable that emits the query results and updates whenever the query results change unless
13
+ * `subscribe=false` is provided.
14
+ *
15
+ * Important: Make sure to unsubscribe from the observable when you are done with it.
16
+ *
17
+ * @param subscribe Whether to subscribe to changes to the query results. Defaults to `true`.
18
+ * @returns An observable for the query results.
19
+ */
20
+ snapshots(subscribe?: boolean): Observable<Array<ReturnType>>;
21
+ }
22
+ /** Query builder base class. */
23
+ export declare abstract class BaseQueryBuilder<MyDocType extends DocumentData> {
24
+ /**
25
+ * Adds a condition to the query.
26
+ * @param fieldName The name of the field to query.
27
+ * @param operator The operator to use.
28
+ * @param value The value to compare against.
29
+ * @returns The query builder.
30
+ */
31
+ abstract where(fieldName: (keyof MyDocType & FieldName) | string, operator: Operator | 'in' | 'not in', value: PrimitiveFieldType | Array<PrimitiveFieldType>): this;
32
+ /**
33
+ * A shortcut for where(fieldName, '==', value)
34
+ *
35
+ * @param fieldName The name of the field to query.
36
+ * @param value The value to compare against.
37
+ * @returns The query builder.
38
+ */
39
+ eq(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
40
+ /**
41
+ * A shortcut for where(fieldName, '!=', value)
42
+ * @param fieldName The name of the field to query.
43
+ * @param value The value to compare against.
44
+ * @returns The query builder.
45
+ */
46
+ neq(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
47
+ /**
48
+ * A shortcut for where(fieldName, 'in', value)
49
+ * @param fieldName The name of the field to query.
50
+ * @param value An array of values to compare against.
51
+ * @returns The query builder.
52
+ */
53
+ in(fieldName: (keyof MyDocType & FieldName) | string, value: Array<PrimitiveFieldType>): this;
54
+ /**
55
+ * A shortcut for where(fieldName, 'not in', value)
56
+ * @param fieldName The name of the field to query.
57
+ * @param value An array of values to compare against.
58
+ * @returns The query builder.
59
+ */
60
+ nin(fieldName: (keyof MyDocType & FieldName) | string, value: Array<PrimitiveFieldType>): this;
61
+ /**
62
+ * A shortcut for where(fieldName, '>', value)
63
+ * @param fieldName The name of the field to query.
64
+ * @param value The value to compare against.
65
+ * @returns The query builder.
66
+ */
67
+ gt(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
68
+ /**
69
+ * A shortcut for where(fieldName, '>=', value)
70
+ * @param fieldName The name of the field to query.
71
+ * @param value The value to compare against.
72
+ * @returns The query builder.
73
+ */
74
+ gte(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
75
+ /**
76
+ * A shortcut for where(fieldName, '<', value)
77
+ * @param fieldName The name of the field to query.
78
+ * @param value The value to compare against.
79
+ * @returns The query builder.
80
+ */
81
+ lt(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
82
+ /**
83
+ * A shortcut for where(fieldName, '<=', value)
84
+ * @param fieldName The name of the field to query.
85
+ * @param value The value to compare against.
86
+ * @returns The query builder.
87
+ */
88
+ lte(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
89
+ /**
90
+ * A shortcut for where(fieldName, 'like', pattern).
91
+ *
92
+ * @param fieldName The name of the field to query.
93
+ * @param pattern The pattern to compare against. '%' is the only allowed wildcard
94
+ * @param caseSensitive Whether to use case-sensitive comparison. Defaults to true.
95
+ * @returns The query builder.
96
+ */
97
+ like(fieldName: (keyof MyDocType & FieldName) | string, pattern: string, caseSensitive?: boolean): this;
98
+ /**
99
+ * A shortcut for where(fieldName, 'not like', pattern).
100
+ *
101
+ * @param fieldName The name of the field to query.
102
+ * @param pattern The pattern to compare against. '%' is the only allowed wildcard
103
+ * @param caseSensitive Whether to use case-sensitive comparison. Defaults to true.
104
+ * @returns The query builder.
105
+ */
106
+ notLike(fieldName: (keyof MyDocType & FieldName) | string, pattern: string, caseSensitive?: boolean): this;
107
+ /**
108
+ * Sets a limit to the number of results returned by the query. The maximum limit is 20,000 and the default is 1,000
109
+ * if none is provided.
110
+ * @param limit The limit to set.
111
+ * @returns The query builder.
112
+ */
113
+ abstract limit(limit: number): this;
114
+ /**
115
+ * Adds a sort order to the query. You can add multiple sort orders to the query. The order in which you add them
116
+ * determines the order in which they are applied.
117
+ * @param fieldName The name of the field to sort by.
118
+ * @param asc Whether to sort in ascending order. Defaults to true.
119
+ * @returns The query builder.
120
+ */
121
+ abstract sortBy(fieldName: keyof MyDocType & FieldName, asc?: boolean): this;
122
+ }
@@ -1,2 +1,2 @@
1
- export * from './query-context';
2
- export * from './simple-query-builder';
1
+ export * from './query-context';
2
+ export * from './base-query-builder';
@@ -1,109 +1,109 @@
1
- import { IntegrationId } from '../communication.types';
2
- import { CollectionName, DocumentData, FieldName } from '../document.types';
3
- import { AllOperators, ContextConditions, FieldSort, GeneralCondition, GeneralConditions, GenericValue, Query } from '../query.types';
4
- import { PartialBy, Paths } from '../types';
5
- export declare class QueryContext<T = 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 FieldName<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 FieldName<T>>(...fieldNames: 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
- }
1
+ import { IntegrationId } from '../communication.types';
2
+ import { CollectionName, DocumentData, FieldName } from '../document.types';
3
+ import { AllOperators, ContextConditions, FieldSort, GeneralCondition, GeneralConditions, GenericValue, Query } from '../query.types';
4
+ import { PartialBy, Paths } from '../types';
5
+ export declare class QueryContext<T = 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 FieldName<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 FieldName<T>>(...fieldNames: 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
+ }
@@ -1,3 +1,3 @@
1
- import { JSONSchemaType } from 'ajv';
2
- import { QueryRegisterRequest } from './query.types';
3
- export declare const QueryRegisterRequestSchema: JSONSchemaType<QueryRegisterRequest>;
1
+ import { JSONSchemaType } from 'ajv';
2
+ import { QueryRegisterRequest } from './query.types';
3
+ export declare const QueryRegisterRequestSchema: JSONSchemaType<QueryRegisterRequest>;
@@ -1,57 +1,57 @@
1
- import { ClientRequestId } from './communication.types';
2
- import { CollectionName, FieldName } from './document.types';
3
- /** A list of query conditions. */
4
- export type Conditions<Doc = any, F extends FieldName<Doc> = any> = Array<Condition<Doc, F>>;
5
- /** A single query condition. */
6
- export interface Condition<Doc = any, F extends FieldName<Doc> = any> {
7
- fieldName: F;
8
- operator: Operator;
9
- value: Doc[F] | null;
10
- }
11
- /** An operator in a query condition. */
12
- export type Operator = '==' | '>=' | '<=' | '>' | '<' | '!=' | 'like' | 'not like' | 'like_cs' | 'not like_cs';
13
- /** A list of context conditions */
14
- export type ContextConditions<Doc = any, F extends FieldName<Doc> = any> = Array<ContextCondition<Doc, F>>;
15
- /** A generic value that can exist in a query. */
16
- export type GenericValue<Doc = any, F extends FieldName<Doc> = any, O extends AllOperators = any> = O extends 'in' ? Array<Doc[F]> | null : O extends 'not in' ? Array<Doc[F]> | null : Doc[F] | null;
17
- /** A Context condition - a condition that replaces multiple '==' or '!=' conditions with 'in' and 'not in'. */
18
- export type ContextCondition<Doc = any, F extends FieldName<Doc> = any> = InContextCondition<Doc, F> | NotInContextCondition<Doc, F> | OtherContextCondition<Doc, F>;
19
- interface InContextCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator' | 'value'> {
20
- operator: 'in';
21
- value: Array<Doc[F]>;
22
- }
23
- interface NotInContextCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator' | 'value'> {
24
- operator: 'not in';
25
- value: Array<Doc[F]>;
26
- }
27
- export interface OtherContextCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator'> {
28
- operator: Exclude<ContextOperator, 'in' | 'not in'>;
29
- }
30
- /** A condition that includes the 'in' and 'not in' operators. */
31
- export interface GeneralCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator' | 'value'> {
32
- operator: AllOperators;
33
- value: any;
34
- }
35
- /** A list of general conditions. */
36
- export type GeneralConditions<Doc = any, F extends FieldName<Doc> = any> = Array<GeneralCondition<Doc, F>>;
37
- export type ContextOperator = Exclude<Operator, '==' | '!='> | 'in' | 'not in';
38
- export type AllOperators = Operator | 'in' | 'not in';
39
- /** A definition of a sort by a filed. */
40
- export interface FieldSort<Doc> {
41
- fieldName: FieldName<Doc>;
42
- asc: boolean;
43
- }
44
- /** A query object. */
45
- export interface Query<Doc = any> {
46
- collectionName: CollectionName;
47
- integrationId: string;
48
- conditions: Conditions<Doc>;
49
- sortOrder: Array<FieldSort<Doc>>;
50
- limit: number;
51
- }
52
- export interface QueryRegisterRequest {
53
- clientRequestId: ClientRequestId;
54
- query: Query;
55
- parentClientRequestId: ClientRequestId;
56
- }
57
- export {};
1
+ import { ClientRequestId } from './communication.types';
2
+ import { CollectionName, FieldName } from './document.types';
3
+ /** A list of query conditions. */
4
+ export type Conditions<Doc = any, F extends FieldName<Doc> = any> = Array<Condition<Doc, F>>;
5
+ /** A single query condition. */
6
+ export interface Condition<Doc = any, F extends FieldName<Doc> = any> {
7
+ fieldName: F;
8
+ operator: Operator;
9
+ value: Doc[F] | null;
10
+ }
11
+ /** An operator in a query condition. */
12
+ export type Operator = '==' | '>=' | '<=' | '>' | '<' | '!=' | 'like' | 'not like' | 'like_cs' | 'not like_cs';
13
+ /** A list of context conditions */
14
+ export type ContextConditions<Doc = any, F extends FieldName<Doc> = any> = Array<ContextCondition<Doc, F>>;
15
+ /** A generic value that can exist in a query. */
16
+ export type GenericValue<Doc = any, F extends FieldName<Doc> = any, O extends AllOperators = any> = O extends 'in' ? Array<Doc[F]> | null : O extends 'not in' ? Array<Doc[F]> | null : Doc[F] | null;
17
+ /** A Context condition - a condition that replaces multiple '==' or '!=' conditions with 'in' and 'not in'. */
18
+ export type ContextCondition<Doc = any, F extends FieldName<Doc> = any> = InContextCondition<Doc, F> | NotInContextCondition<Doc, F> | OtherContextCondition<Doc, F>;
19
+ interface InContextCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator' | 'value'> {
20
+ operator: 'in';
21
+ value: Array<Doc[F]>;
22
+ }
23
+ interface NotInContextCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator' | 'value'> {
24
+ operator: 'not in';
25
+ value: Array<Doc[F]>;
26
+ }
27
+ export interface OtherContextCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator'> {
28
+ operator: Exclude<ContextOperator, 'in' | 'not in'>;
29
+ }
30
+ /** A condition that includes the 'in' and 'not in' operators. */
31
+ export interface GeneralCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator' | 'value'> {
32
+ operator: AllOperators;
33
+ value: any;
34
+ }
35
+ /** A list of general conditions. */
36
+ export type GeneralConditions<Doc = any, F extends FieldName<Doc> = any> = Array<GeneralCondition<Doc, F>>;
37
+ export type ContextOperator = Exclude<Operator, '==' | '!='> | 'in' | 'not in';
38
+ export type AllOperators = Operator | 'in' | 'not in';
39
+ /** A definition of a sort by a filed. */
40
+ export interface FieldSort<Doc> {
41
+ fieldName: FieldName<Doc>;
42
+ asc: boolean;
43
+ }
44
+ /** A query object. */
45
+ export interface Query<Doc = any> {
46
+ collectionName: CollectionName;
47
+ integrationId: string;
48
+ conditions: Conditions<Doc>;
49
+ sortOrder: Array<FieldSort<Doc>>;
50
+ limit: number;
51
+ }
52
+ export interface QueryRegisterRequest {
53
+ clientRequestId: ClientRequestId;
54
+ query: Query;
55
+ parentClientRequestId: ClientRequestId;
56
+ }
57
+ export {};
@@ -1 +1 @@
1
- export type SupportedSquidRegion = (typeof SupportedSquidRegions)[number];
1
+ export type SupportedSquidRegion = (typeof SupportedSquidRegions)[number];