@squidcloud/client 1.0.61 → 1.0.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/common/src/ai-assistant.context.d.ts +11 -0
  2. package/dist/common/src/ai-assistant.schemas.d.ts +210 -210
  3. package/dist/common/src/ai-assistant.types.d.ts +81 -76
  4. package/dist/common/src/api-call.context.d.ts +12 -12
  5. package/dist/common/src/api.types.d.ts +24 -24
  6. package/dist/common/src/application.schemas.d.ts +1060 -1060
  7. package/dist/common/src/application.types.d.ts +224 -224
  8. package/dist/common/src/auth.types.d.ts +4 -4
  9. package/dist/common/src/backend-function.schemas.d.ts +3 -3
  10. package/dist/common/src/backend-function.types.d.ts +7 -7
  11. package/dist/common/src/backend-run.types.d.ts +53 -53
  12. package/dist/common/src/bundle-api.types.d.ts +68 -66
  13. package/dist/common/src/bundle-data.types.d.ts +59 -52
  14. package/dist/common/src/communication.types.d.ts +4 -4
  15. package/dist/common/src/context.types.d.ts +32 -32
  16. package/dist/common/src/distributed-lock.context.d.ts +5 -5
  17. package/dist/common/src/document.types.d.ts +37 -37
  18. package/dist/common/src/graphql.context.d.ts +6 -6
  19. package/dist/common/src/graphql.types.d.ts +11 -11
  20. package/dist/common/src/http-status.enum.d.ts +50 -50
  21. package/dist/common/src/index.d.ts +54 -54
  22. package/dist/common/src/integrations/ai_assistant.types.d.ts +30 -30
  23. package/dist/common/src/integrations/api.types.d.ts +80 -80
  24. package/dist/common/src/integrations/auth.types.d.ts +22 -22
  25. package/dist/common/src/integrations/database.types.d.ts +236 -236
  26. package/dist/common/src/integrations/index.d.ts +97 -97
  27. package/dist/common/src/integrations/observability.types.d.ts +22 -22
  28. package/dist/common/src/logger.types.d.ts +21 -21
  29. package/dist/common/src/metrics.types.d.ts +58 -58
  30. package/dist/common/src/mutation.context.d.ts +10 -10
  31. package/dist/common/src/mutation.schemas.d.ts +5 -5
  32. package/dist/common/src/mutation.types.d.ts +72 -72
  33. package/dist/common/src/named-query.context.d.ts +4 -4
  34. package/dist/common/src/named-query.schemas.d.ts +3 -3
  35. package/dist/common/src/named-query.types.d.ts +9 -9
  36. package/dist/common/src/query/index.d.ts +2 -2
  37. package/dist/common/src/query/query-context.d.ts +37 -37
  38. package/dist/common/src/query/simple-query-builder.d.ts +137 -137
  39. package/dist/common/src/query.schemas.d.ts +5 -5
  40. package/dist/common/src/query.types.d.ts +118 -118
  41. package/dist/common/src/regions.d.ts +22 -22
  42. package/dist/common/src/schema/schema.types.d.ts +54 -54
  43. package/dist/common/src/secret.schemas.d.ts +6 -6
  44. package/dist/common/src/secret.types.d.ts +49 -37
  45. package/dist/common/src/security.types.d.ts +3 -3
  46. package/dist/common/src/socket.schemas.d.ts +3 -3
  47. package/dist/common/src/socket.types.d.ts +108 -108
  48. package/dist/common/src/time-units.d.ts +5 -5
  49. package/dist/common/src/trigger.types.d.ts +15 -15
  50. package/dist/common/src/types.d.ts +15 -15
  51. package/dist/common/src/utils/array.d.ts +8 -8
  52. package/dist/common/src/utils/assert.d.ts +8 -8
  53. package/dist/common/src/utils/error.d.ts +4 -4
  54. package/dist/common/src/utils/http.d.ts +2 -2
  55. package/dist/common/src/utils/id.d.ts +2 -2
  56. package/dist/common/src/utils/lock.manager.d.ts +14 -14
  57. package/dist/common/src/utils/nullish.d.ts +1 -1
  58. package/dist/common/src/utils/object.d.ts +6 -6
  59. package/dist/common/src/utils/serialization.d.ts +6 -6
  60. package/dist/common/src/utils/transforms.d.ts +18 -18
  61. package/dist/common/src/utils/url.d.ts +1 -1
  62. package/dist/common/src/utils/validation.d.ts +30 -30
  63. package/dist/common/src/webhook-response.d.ts +7 -7
  64. package/dist/index.js +1 -1
  65. package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -1239
  66. package/dist/typescript-client/src/ai-assistant-client.d.ts +66 -66
  67. package/dist/typescript-client/src/ai-client.factory.d.ts +13 -13
  68. package/dist/typescript-client/src/api.manager.d.ts +15 -15
  69. package/dist/typescript-client/src/auth.manager.d.ts +23 -23
  70. package/dist/typescript-client/src/backend-function.manager.d.ts +13 -13
  71. package/dist/typescript-client/src/client-id.service.d.ts +24 -24
  72. package/dist/typescript-client/src/collection-reference.d.ts +81 -65
  73. package/dist/typescript-client/src/collection-reference.factory.d.ts +16 -16
  74. package/dist/typescript-client/src/data.manager.d.ts +172 -172
  75. package/dist/typescript-client/src/destruct.manager.d.ts +12 -12
  76. package/dist/typescript-client/src/distributed-lock.manager.d.ts +19 -19
  77. package/dist/typescript-client/src/document-identity.service.d.ts +12 -12
  78. package/dist/typescript-client/src/document-reference.d.ts +134 -134
  79. package/dist/typescript-client/src/document-reference.factory.d.ts +9 -9
  80. package/dist/typescript-client/src/document-store.d.ts +11 -11
  81. package/dist/typescript-client/src/graphql-client.d.ts +12 -12
  82. package/dist/typescript-client/src/graphql-client.factory.d.ts +9 -9
  83. package/dist/typescript-client/src/index.d.ts +8 -8
  84. package/dist/typescript-client/src/mutation/mutation-sender.d.ts +12 -12
  85. package/dist/typescript-client/src/named-query.manager.d.ts +14 -14
  86. package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +72 -72
  87. package/dist/typescript-client/src/query/query-builder.factory.d.ts +83 -83
  88. package/dist/typescript-client/src/query/query-subscription.manager.d.ts +64 -64
  89. package/dist/typescript-client/src/query/query.types.d.ts +14 -14
  90. package/dist/typescript-client/src/rpc.manager.d.ts +28 -28
  91. package/dist/typescript-client/src/socket.manager.d.ts +32 -32
  92. package/dist/typescript-client/src/squid.d.ts +188 -188
  93. package/dist/typescript-client/src/state/action.applier.d.ts +7 -7
  94. package/dist/typescript-client/src/state/actions.d.ts +29 -29
  95. package/dist/typescript-client/src/state/path_trie.d.ts +27 -27
  96. package/dist/typescript-client/src/state/state.service.d.ts +22 -22
  97. package/dist/typescript-client/src/state/state.service.spec.d.ts +1 -1
  98. package/dist/typescript-client/src/testing/setup-tests.d.ts +1 -1
  99. package/dist/typescript-client/src/types.d.ts +2 -2
  100. package/package.json +1 -1
@@ -1,37 +1,37 @@
1
- import { IntegrationId } from '../communication.types';
2
- import { CollectionName, FieldName } from '../document.types';
3
- import { AllOperators, ContextCondition, 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
- get integrationId(): IntegrationId;
9
- get collectionName(): CollectionName;
10
- get limit(): number;
11
- sortedBy(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
12
- sortedByExact(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
13
- includes<F extends FieldName<T>, O extends AllOperators>(fieldName: F, operator: O, value: GenericValue<T, F, O>): boolean;
14
- includesCondition(condition: ContextCondition<T>): boolean;
15
- includesConditions(conditions: GeneralConditions<T>): boolean;
16
- matchesConditions(conditions: GeneralConditions<T>): boolean;
17
- matchesQuery(query: Query<T>): boolean;
18
- isSubsetOf<F extends FieldName<T>, O extends AllOperators>(fieldName: F, operator: O, value: GenericValue<T, F, O> | null): boolean;
19
- isSubsetOfCondition(condition: GeneralCondition<T>): boolean;
20
- isSubsetOfConditions(conditions: GeneralConditions<T>): boolean;
21
- isSubsetOfQuery(query: Query<T>): boolean;
22
- getConditionsFor<K extends FieldName<T>>(...fieldNames: K[]): ContextConditions<T, K>;
23
- getConditionsForField<K extends Paths<T>>(fieldName: K): ContextConditions<T>;
24
- /**
25
- * Compares a condition against a given operator and value to determine if the
26
- * provided condition is a subset of the operator and value. A condition is
27
- * considered a subset if all values that satisfy (return true for) the
28
- * condition also satisfy the operator and value.
29
- *
30
- * This is done using the underlying CompareTable, which provides a comparison
31
- * function for each operator pair, or undefined if the comparison would
32
- * always be false, regardless of the values.
33
- */
34
- private evaluateSubset;
35
- private evaluateIncludes;
36
- private parseConditions;
37
- }
1
+ import { IntegrationId } from '../communication.types';
2
+ import { CollectionName, FieldName } from '../document.types';
3
+ import { AllOperators, ContextCondition, 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
+ get integrationId(): IntegrationId;
9
+ get collectionName(): CollectionName;
10
+ get limit(): number;
11
+ sortedBy(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
12
+ sortedByExact(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
13
+ includes<F extends FieldName<T>, O extends AllOperators>(fieldName: F, operator: O, value: GenericValue<T, F, O>): boolean;
14
+ includesCondition(condition: ContextCondition<T>): boolean;
15
+ includesConditions(conditions: GeneralConditions<T>): boolean;
16
+ matchesConditions(conditions: GeneralConditions<T>): boolean;
17
+ matchesQuery(query: Query<T>): boolean;
18
+ isSubsetOf<F extends FieldName<T>, O extends AllOperators>(fieldName: F, operator: O, value: GenericValue<T, F, O> | null): boolean;
19
+ isSubsetOfCondition(condition: GeneralCondition<T>): boolean;
20
+ isSubsetOfConditions(conditions: GeneralConditions<T>): boolean;
21
+ isSubsetOfQuery(query: Query<T>): boolean;
22
+ getConditionsFor<K extends FieldName<T>>(...fieldNames: K[]): ContextConditions<T, K>;
23
+ getConditionsForField<K extends Paths<T>>(fieldName: K): ContextConditions<T>;
24
+ /**
25
+ * Compares a condition against a given operator and value to determine if the
26
+ * provided condition is a subset of the operator and value. A condition is
27
+ * considered a subset if all values that satisfy (return true for) the
28
+ * condition also satisfy the operator and value.
29
+ *
30
+ * This is done using the underlying CompareTable, which provides a comparison
31
+ * function for each operator pair, or undefined if the comparison would
32
+ * always be false, regardless of the values.
33
+ */
34
+ private evaluateSubset;
35
+ private evaluateIncludes;
36
+ private parseConditions;
37
+ }
@@ -1,137 +1,137 @@
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 interface 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
- 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
- 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
- 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> implements 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
- eq(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
114
- /** @inheritDoc */
115
- neq(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
116
- /** @inheritDoc */
117
- in(fieldName: (keyof MyDocType & FieldName) | string, value: Array<PrimitiveFieldType>): this;
118
- /** @inheritDoc */
119
- nin(fieldName: (keyof MyDocType & FieldName) | string, value: Array<PrimitiveFieldType>): this;
120
- /** @inheritDoc */
121
- gt(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
122
- /** @inheritDoc */
123
- gte(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
124
- /** @inheritDoc */
125
- lt(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
126
- /** @inheritDoc */
127
- lte(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
128
- /** @inheritDoc */
129
- like(fieldName: (keyof MyDocType & FieldName) | string, pattern: string, caseSensitive?: boolean): this;
130
- /** @inheritDoc */
131
- notLike(fieldName: (keyof MyDocType & FieldName) | string, pattern: string, caseSensitive?: boolean): this;
132
- /** @inheritDoc */
133
- limit(limit: number): this;
134
- /** @inheritDoc */
135
- sortBy(fieldName: keyof MyDocType & FieldName, asc?: boolean): this;
136
- private mergeConditions;
137
- }
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 interface 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
+ 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
+ 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
+ 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> implements 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
+ eq(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
114
+ /** @inheritDoc */
115
+ neq(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
116
+ /** @inheritDoc */
117
+ in(fieldName: (keyof MyDocType & FieldName) | string, value: Array<PrimitiveFieldType>): this;
118
+ /** @inheritDoc */
119
+ nin(fieldName: (keyof MyDocType & FieldName) | string, value: Array<PrimitiveFieldType>): this;
120
+ /** @inheritDoc */
121
+ gt(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
122
+ /** @inheritDoc */
123
+ gte(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
124
+ /** @inheritDoc */
125
+ lt(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
126
+ /** @inheritDoc */
127
+ lte(fieldName: (keyof MyDocType & FieldName) | string, value: PrimitiveFieldType): this;
128
+ /** @inheritDoc */
129
+ like(fieldName: (keyof MyDocType & FieldName) | string, pattern: string, caseSensitive?: boolean): this;
130
+ /** @inheritDoc */
131
+ notLike(fieldName: (keyof MyDocType & FieldName) | string, pattern: string, caseSensitive?: boolean): this;
132
+ /** @inheritDoc */
133
+ limit(limit: number): this;
134
+ /** @inheritDoc */
135
+ sortBy(fieldName: keyof MyDocType & FieldName, asc?: boolean): this;
136
+ private mergeConditions;
137
+ }
@@ -1,5 +1,5 @@
1
- import { JSONSchemaType } from 'ajv';
2
- import { Query, QueryRequest, QueryUnsubscribeRequest } from './query.types';
3
- export declare const QuerySchema: JSONSchemaType<Query>;
4
- export declare const QueryRequestSchema: JSONSchemaType<QueryRequest>;
5
- export declare const QueryUnsubscribeRequestSchema: JSONSchemaType<QueryUnsubscribeRequest>;
1
+ import { JSONSchemaType } from 'ajv';
2
+ import { Query, QueryRequest, QueryUnsubscribeRequest } from './query.types';
3
+ export declare const QuerySchema: JSONSchemaType<Query>;
4
+ export declare const QueryRequestSchema: JSONSchemaType<QueryRequest>;
5
+ export declare const QueryUnsubscribeRequestSchema: JSONSchemaType<QueryUnsubscribeRequest>;
@@ -1,118 +1,118 @@
1
- import { TriggerId } from './application.types';
2
- import { AppId, ClientId, ClientRequestId, IntegrationId } from './communication.types';
3
- import { CollectionName, FieldName, PrimitiveFieldType, SquidDocument } from './document.types';
4
- export type Conditions<Doc = any, F extends FieldName<Doc> = any> = Array<Condition<Doc, F>>;
5
- export interface Condition<Doc = any, F extends FieldName<Doc> = any> {
6
- fieldName: F;
7
- operator: Operator;
8
- value: Doc[F] | null;
9
- }
10
- export type Operator = '==' | '>=' | '<=' | '>' | '<' | '!=' | 'like' | 'not like' | 'like_cs' | 'not like_cs';
11
- export type ContextConditions<Doc = any, F extends FieldName<Doc> = any> = Array<ContextCondition<Doc, F>>;
12
- 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;
13
- export type ContextCondition<Doc = any, F extends FieldName<Doc> = any> = InContextCondition<Doc, F> | NotInContextCondition<Doc, F> | OtherContextCondition<Doc, F>;
14
- interface InContextCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator' | 'value'> {
15
- operator: 'in';
16
- value: Array<Doc[F]>;
17
- }
18
- interface NotInContextCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator' | 'value'> {
19
- operator: 'not in';
20
- value: Array<Doc[F]>;
21
- }
22
- interface OtherContextCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator'> {
23
- operator: Exclude<ContextOperator, 'in' | 'not in'>;
24
- }
25
- export interface GeneralCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator' | 'value'> {
26
- operator: AllOperators;
27
- value: any;
28
- }
29
- export type GeneralConditions<Doc = any, F extends FieldName<Doc> = any> = Array<GeneralCondition<Doc, F>>;
30
- export type ContextOperator = Exclude<Operator, '==' | '!='> | 'in' | 'not in';
31
- export type AllOperators = Operator | 'in' | 'not in';
32
- export interface FieldSort<Doc> {
33
- fieldName: FieldName<Doc>;
34
- asc: boolean;
35
- }
36
- interface RegularQueryKey {
37
- queryType: 'query';
38
- clientId: string;
39
- clientRequestId: string;
40
- }
41
- interface TriggerKey {
42
- queryType: 'trigger';
43
- triggerId: TriggerId;
44
- }
45
- export type QueryKey = RegularQueryKey | TriggerKey;
46
- export interface Query<Doc = any> {
47
- collectionName: CollectionName;
48
- integrationId: string;
49
- conditions: Conditions<Doc>;
50
- sortOrder: Array<FieldSort<Doc>>;
51
- limit: number;
52
- }
53
- export type QuerySubscriptionId = `${ClientId}_${ClientRequestId}`;
54
- export interface QueryRequest {
55
- clientId: ClientId;
56
- clientRequestId: ClientRequestId;
57
- query: Query;
58
- subscribe: boolean;
59
- }
60
- export interface QueryUnsubscribeRequest {
61
- clientId: ClientId;
62
- clientRequestId: ClientRequestId;
63
- }
64
- interface QueryMetadata {
65
- condCount: number;
66
- }
67
- /**
68
- * Example query mapping:
69
- * {
70
- * unconditional: ['cid_123'],
71
- * conditional: {
72
- * age: {
73
- * '==': {
74
- * 10: ['cid2_321'],
75
- * 11: ['cid2_321'],
76
- * 12: ['cid2_321'],
77
- * },
78
- * '>': {
79
- * 20: ['cid_456']
80
- * }
81
- * }
82
- * },
83
- * queriesMetadata: {
84
- * 'cid_123': {
85
- * condCount: 0
86
- * },
87
- * 'cid2_321': {
88
- * condCount: 1
89
- * },
90
- * 'cid2_456': {
91
- * condCount: 1
92
- * }
93
- * }
94
- * }
95
- */
96
- export type QueryMapping<T extends string> = {
97
- unconditional: Array<T>;
98
- conditional: Record<FieldName, Record<Operator, Record<PrimitiveFieldType & string, Array<T>>>>;
99
- queriesMetadata: Record<T, QueryMetadata>;
100
- };
101
- export declare abstract class QueryMappingManager<T> {
102
- abstract addQuery(appId: AppId, query: Query, key: T): Promise<void>;
103
- abstract removeQuery(appId: AppId, key: T): Promise<Query | undefined>;
104
- abstract findQueriesForDocument(appId: AppId, doc: SquidDocument, collectionName: CollectionName, integrationId: IntegrationId): Promise<Array<T> | undefined>;
105
- }
106
- export declare abstract class SimpleQueryMappingManager<T extends string> extends QueryMappingManager<T> {
107
- abstract getMapping(appId: AppId, collectionName: CollectionName, integrationId: IntegrationId): Promise<QueryMapping<T> | undefined> | (QueryMapping<T> | undefined);
108
- findQueriesForDocument(appId: AppId, doc: SquidDocument, collectionName: CollectionName, integrationId: IntegrationId): Promise<Array<T>>;
109
- }
110
- export declare function findQueriesForDocumentSync<T extends string>(mapping: QueryMapping<T>, doc: SquidDocument): Array<T>;
111
- export declare function compareOperator(conditionValue: PrimitiveFieldType, valueInDocument: PrimitiveFieldType, operator: Operator): boolean;
112
- /** Returns a unique identifier for the query which includes both the client id and the client request id. */
113
- export declare function getQuerySubscriptionId(clientId: string, clientRequestId: string): QuerySubscriptionId;
114
- export declare function parseQuerySubscriptionId(querySubscriptionId: QuerySubscriptionId): {
115
- clientId: string;
116
- clientRequestId: string;
117
- };
118
- export {};
1
+ import { TriggerId } from './application.types';
2
+ import { AppId, ClientId, ClientRequestId, IntegrationId } from './communication.types';
3
+ import { CollectionName, FieldName, PrimitiveFieldType, SquidDocument } from './document.types';
4
+ export type Conditions<Doc = any, F extends FieldName<Doc> = any> = Array<Condition<Doc, F>>;
5
+ export interface Condition<Doc = any, F extends FieldName<Doc> = any> {
6
+ fieldName: F;
7
+ operator: Operator;
8
+ value: Doc[F] | null;
9
+ }
10
+ export type Operator = '==' | '>=' | '<=' | '>' | '<' | '!=' | 'like' | 'not like' | 'like_cs' | 'not like_cs';
11
+ export type ContextConditions<Doc = any, F extends FieldName<Doc> = any> = Array<ContextCondition<Doc, F>>;
12
+ 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;
13
+ export type ContextCondition<Doc = any, F extends FieldName<Doc> = any> = InContextCondition<Doc, F> | NotInContextCondition<Doc, F> | OtherContextCondition<Doc, F>;
14
+ interface InContextCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator' | 'value'> {
15
+ operator: 'in';
16
+ value: Array<Doc[F]>;
17
+ }
18
+ interface NotInContextCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator' | 'value'> {
19
+ operator: 'not in';
20
+ value: Array<Doc[F]>;
21
+ }
22
+ interface OtherContextCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator'> {
23
+ operator: Exclude<ContextOperator, 'in' | 'not in'>;
24
+ }
25
+ export interface GeneralCondition<Doc = any, F extends FieldName<Doc> = any> extends Omit<Condition<Doc, F>, 'operator' | 'value'> {
26
+ operator: AllOperators;
27
+ value: any;
28
+ }
29
+ export type GeneralConditions<Doc = any, F extends FieldName<Doc> = any> = Array<GeneralCondition<Doc, F>>;
30
+ export type ContextOperator = Exclude<Operator, '==' | '!='> | 'in' | 'not in';
31
+ export type AllOperators = Operator | 'in' | 'not in';
32
+ export interface FieldSort<Doc> {
33
+ fieldName: FieldName<Doc>;
34
+ asc: boolean;
35
+ }
36
+ interface RegularQueryKey {
37
+ queryType: 'query';
38
+ clientId: string;
39
+ clientRequestId: string;
40
+ }
41
+ interface TriggerKey {
42
+ queryType: 'trigger';
43
+ triggerId: TriggerId;
44
+ }
45
+ export type QueryKey = RegularQueryKey | TriggerKey;
46
+ export interface Query<Doc = any> {
47
+ collectionName: CollectionName;
48
+ integrationId: string;
49
+ conditions: Conditions<Doc>;
50
+ sortOrder: Array<FieldSort<Doc>>;
51
+ limit: number;
52
+ }
53
+ export type QuerySubscriptionId = `${ClientId}_${ClientRequestId}`;
54
+ export interface QueryRequest {
55
+ clientId: ClientId;
56
+ clientRequestId: ClientRequestId;
57
+ query: Query;
58
+ subscribe: boolean;
59
+ }
60
+ export interface QueryUnsubscribeRequest {
61
+ clientId: ClientId;
62
+ clientRequestId: ClientRequestId;
63
+ }
64
+ interface QueryMetadata {
65
+ condCount: number;
66
+ }
67
+ /**
68
+ * Example query mapping:
69
+ * {
70
+ * unconditional: ['cid_123'],
71
+ * conditional: {
72
+ * age: {
73
+ * '==': {
74
+ * 10: ['cid2_321'],
75
+ * 11: ['cid2_321'],
76
+ * 12: ['cid2_321'],
77
+ * },
78
+ * '>': {
79
+ * 20: ['cid_456']
80
+ * }
81
+ * }
82
+ * },
83
+ * queriesMetadata: {
84
+ * 'cid_123': {
85
+ * condCount: 0
86
+ * },
87
+ * 'cid2_321': {
88
+ * condCount: 1
89
+ * },
90
+ * 'cid2_456': {
91
+ * condCount: 1
92
+ * }
93
+ * }
94
+ * }
95
+ */
96
+ export type QueryMapping<T extends string> = {
97
+ unconditional: Array<T>;
98
+ conditional: Record<FieldName, Record<Operator, Record<PrimitiveFieldType & string, Array<T>>>>;
99
+ queriesMetadata: Record<T, QueryMetadata>;
100
+ };
101
+ export declare abstract class QueryMappingManager<T> {
102
+ abstract addQuery(appId: AppId, query: Query, key: T): Promise<void>;
103
+ abstract removeQuery(appId: AppId, key: T): Promise<Query | undefined>;
104
+ abstract findQueriesForDocument(appId: AppId, doc: SquidDocument, collectionName: CollectionName, integrationId: IntegrationId): Promise<Array<T> | undefined>;
105
+ }
106
+ export declare abstract class SimpleQueryMappingManager<T extends string> extends QueryMappingManager<T> {
107
+ abstract getMapping(appId: AppId, collectionName: CollectionName, integrationId: IntegrationId): Promise<QueryMapping<T> | undefined> | (QueryMapping<T> | undefined);
108
+ findQueriesForDocument(appId: AppId, doc: SquidDocument, collectionName: CollectionName, integrationId: IntegrationId): Promise<Array<T>>;
109
+ }
110
+ export declare function findQueriesForDocumentSync<T extends string>(mapping: QueryMapping<T>, doc: SquidDocument): Array<T>;
111
+ export declare function compareOperator(conditionValue: PrimitiveFieldType, valueInDocument: PrimitiveFieldType, operator: Operator): boolean;
112
+ /** Returns a unique identifier for the query which includes both the client id and the client request id. */
113
+ export declare function getQuerySubscriptionId(clientId: string, clientRequestId: string): QuerySubscriptionId;
114
+ export declare function parseQuerySubscriptionId(querySubscriptionId: QuerySubscriptionId): {
115
+ clientId: string;
116
+ clientRequestId: string;
117
+ };
118
+ export {};