@squidcloud/local-backend 1.0.40 → 1.0.41

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 (172) hide show
  1. package/dist/common/src/ai-assistant.context.d.ts +13 -13
  2. package/dist/common/src/ai-assistant.context.js +19 -19
  3. package/dist/common/src/ai-assistant.schemas.d.ts +207 -207
  4. package/dist/common/src/ai-assistant.schemas.js +196 -196
  5. package/dist/common/src/ai-assistant.types.d.ts +80 -80
  6. package/dist/common/src/ai-assistant.types.js +11 -11
  7. package/dist/common/src/api-call.context.d.ts +13 -13
  8. package/dist/common/src/api-call.context.js +16 -16
  9. package/dist/common/src/api.types.d.ts +23 -23
  10. package/dist/common/src/api.types.js +2 -2
  11. package/dist/common/src/application.schemas.d.ts +1168 -1168
  12. package/dist/common/src/application.schemas.js +741 -741
  13. package/dist/common/src/application.types.d.ts +228 -228
  14. package/dist/common/src/application.types.js +89 -89
  15. package/dist/common/src/backend-function.schemas.d.ts +3 -3
  16. package/dist/common/src/backend-function.schemas.js +12 -12
  17. package/dist/common/src/backend-function.types.d.ts +6 -6
  18. package/dist/common/src/backend-function.types.js +2 -2
  19. package/dist/common/src/backend-run.types.d.ts +54 -54
  20. package/dist/common/src/backend-run.types.js +73 -73
  21. package/dist/common/src/bundle-api.types.d.ts +71 -71
  22. package/dist/common/src/bundle-api.types.js +2 -2
  23. package/dist/common/src/bundle-data.types.d.ts +59 -59
  24. package/dist/common/src/bundle-data.types.js +2 -2
  25. package/dist/common/src/communication.types.d.ts +18 -18
  26. package/dist/common/src/communication.types.js +40 -40
  27. package/dist/common/src/context.types.d.ts +24 -24
  28. package/dist/common/src/context.types.js +2 -2
  29. package/dist/common/src/distributed-lock.context.d.ts +5 -5
  30. package/dist/common/src/distributed-lock.context.js +10 -10
  31. package/dist/common/src/document.types.d.ts +32 -32
  32. package/dist/common/src/document.types.js +50 -50
  33. package/dist/common/src/graphql.context.d.ts +14 -14
  34. package/dist/common/src/graphql.context.js +12 -12
  35. package/dist/common/src/graphql.types.d.ts +11 -11
  36. package/dist/common/src/graphql.types.js +34 -34
  37. package/dist/common/src/heartbeat.types.d.ts +4 -4
  38. package/dist/common/src/heartbeat.types.js +16 -16
  39. package/dist/common/src/http-status.enum.d.ts +50 -50
  40. package/dist/common/src/http-status.enum.js +54 -54
  41. package/dist/common/src/index.d.ts +54 -54
  42. package/dist/common/src/index.js +70 -70
  43. package/dist/common/src/integrations/ai_assistant.types.d.ts +30 -30
  44. package/dist/common/src/integrations/ai_assistant.types.js +2 -2
  45. package/dist/common/src/integrations/api.types.d.ts +80 -80
  46. package/dist/common/src/integrations/api.types.js +2 -2
  47. package/dist/common/src/integrations/auth.types.d.ts +39 -39
  48. package/dist/common/src/integrations/auth.types.js +2 -2
  49. package/dist/common/src/integrations/database.types.d.ts +236 -236
  50. package/dist/common/src/integrations/database.types.js +2 -2
  51. package/dist/common/src/integrations/index.d.ts +101 -101
  52. package/dist/common/src/integrations/index.js +105 -105
  53. package/dist/common/src/integrations/observability.types.d.ts +23 -23
  54. package/dist/common/src/integrations/observability.types.js +23 -23
  55. package/dist/common/src/logger.types.d.ts +21 -21
  56. package/dist/common/src/logger.types.js +11 -11
  57. package/dist/common/src/metrics.types.d.ts +73 -73
  58. package/dist/common/src/metrics.types.js +11 -11
  59. package/dist/common/src/mutation.context.d.ts +13 -13
  60. package/dist/common/src/mutation.context.js +26 -26
  61. package/dist/common/src/mutation.schemas.d.ts +5 -5
  62. package/dist/common/src/mutation.schemas.js +114 -114
  63. package/dist/common/src/mutation.types.d.ts +63 -63
  64. package/dist/common/src/mutation.types.js +142 -142
  65. package/dist/common/src/named-query.context.d.ts +4 -4
  66. package/dist/common/src/named-query.context.js +9 -9
  67. package/dist/common/src/named-query.schemas.d.ts +3 -3
  68. package/dist/common/src/named-query.schemas.js +13 -13
  69. package/dist/common/src/named-query.types.d.ts +8 -8
  70. package/dist/common/src/named-query.types.js +2 -2
  71. package/dist/common/src/query/{simple-query-builder.d.ts → base-query-builder.d.ts} +25 -29
  72. package/dist/common/src/query/base-query-builder.js +37 -0
  73. package/dist/common/src/query/base-query-builder.js.map +1 -0
  74. package/dist/common/src/query/index.d.ts +2 -2
  75. package/dist/common/src/query/index.js +18 -18
  76. package/dist/common/src/query/index.js.map +1 -1
  77. package/dist/common/src/query/query-context.d.ts +24 -24
  78. package/dist/common/src/query/query-context.js +158 -158
  79. package/dist/common/src/query.schemas.d.ts +6 -6
  80. package/dist/common/src/query.schemas.js +96 -96
  81. package/dist/common/src/query.types.d.ts +92 -92
  82. package/dist/common/src/query.types.js +134 -134
  83. package/dist/common/src/regions.d.ts +21 -21
  84. package/dist/common/src/regions.js +46 -46
  85. package/dist/common/src/schema/schema.types.d.ts +30 -30
  86. package/dist/common/src/schema/schema.types.js +172 -172
  87. package/dist/common/src/secret.schemas.d.ts +6 -6
  88. package/dist/common/src/secret.schemas.js +32 -32
  89. package/dist/common/src/secret.types.d.ts +49 -49
  90. package/dist/common/src/secret.types.js +5 -5
  91. package/dist/common/src/security.types.d.ts +3 -3
  92. package/dist/common/src/security.types.js +2 -2
  93. package/dist/common/src/socket.schemas.d.ts +3 -3
  94. package/dist/common/src/socket.schemas.js +58 -58
  95. package/dist/common/src/socket.types.d.ts +108 -108
  96. package/dist/common/src/socket.types.js +2 -2
  97. package/dist/common/src/time-units.d.ts +5 -5
  98. package/dist/common/src/time-units.js +8 -8
  99. package/dist/common/src/trigger.types.d.ts +15 -15
  100. package/dist/common/src/trigger.types.js +2 -2
  101. package/dist/common/src/types.d.ts +15 -15
  102. package/dist/common/src/types.js +2 -2
  103. package/dist/common/src/utils/array.d.ts +8 -8
  104. package/dist/common/src/utils/array.js +51 -51
  105. package/dist/common/src/utils/assert.d.ts +8 -8
  106. package/dist/common/src/utils/assert.js +49 -49
  107. package/dist/common/src/utils/error.d.ts +4 -4
  108. package/dist/common/src/utils/error.js +10 -10
  109. package/dist/common/src/utils/http.d.ts +2 -2
  110. package/dist/common/src/utils/http.js +38 -38
  111. package/dist/common/src/utils/id.d.ts +2 -2
  112. package/dist/common/src/utils/id.js +21 -21
  113. package/dist/common/src/utils/lock.manager.d.ts +9 -9
  114. package/dist/common/src/utils/lock.manager.js +39 -39
  115. package/dist/common/src/utils/nullish.d.ts +1 -1
  116. package/dist/common/src/utils/nullish.js +7 -7
  117. package/dist/common/src/utils/object.d.ts +6 -6
  118. package/dist/common/src/utils/object.js +89 -89
  119. package/dist/common/src/utils/serialization.d.ts +6 -6
  120. package/dist/common/src/utils/serialization.js +77 -77
  121. package/dist/common/src/utils/transforms.d.ts +18 -18
  122. package/dist/common/src/utils/transforms.js +92 -92
  123. package/dist/common/src/utils/url.d.ts +1 -1
  124. package/dist/common/src/utils/url.js +15 -15
  125. package/dist/common/src/utils/validation.d.ts +17 -17
  126. package/dist/common/src/utils/validation.js +209 -209
  127. package/dist/common/src/webhook-response.d.ts +7 -7
  128. package/dist/common/src/webhook-response.js +7 -7
  129. package/dist/internal-common/src/async-queue.d.ts +4 -4
  130. package/dist/internal-common/src/async-queue.js +17 -17
  131. package/dist/internal-common/src/code-executor.types.d.ts +13 -13
  132. package/dist/internal-common/src/code-executor.types.js +2 -2
  133. package/dist/internal-common/src/environment/environment.types.d.ts +74 -74
  134. package/dist/internal-common/src/environment/environment.types.js +2 -2
  135. package/dist/internal-common/src/environment/index.d.ts +6 -6
  136. package/dist/internal-common/src/environment/index.js +25 -25
  137. package/dist/internal-common/src/environment/local.environment.d.ts +2 -2
  138. package/dist/internal-common/src/environment/local.environment.js +62 -62
  139. package/dist/internal-common/src/index.d.ts +11 -11
  140. package/dist/internal-common/src/index.js +29 -29
  141. package/dist/internal-common/src/kafka/kafka.manager.d.ts +22 -22
  142. package/dist/internal-common/src/kafka/kafka.manager.js +128 -128
  143. package/dist/internal-common/src/kafka/kafka.types.d.ts +17 -17
  144. package/dist/internal-common/src/kafka/kafka.types.js +2 -2
  145. package/dist/internal-common/src/kafka-observability-publisher.d.ts +11 -11
  146. package/dist/internal-common/src/kafka-observability-publisher.js +20 -20
  147. package/dist/internal-common/src/local-dev.types.d.ts +31 -31
  148. package/dist/internal-common/src/local-dev.types.js +2 -2
  149. package/dist/internal-common/src/observability-publisher.d.ts +9 -9
  150. package/dist/internal-common/src/observability-publisher.js +58 -58
  151. package/dist/internal-common/src/observability.types.d.ts +17 -17
  152. package/dist/internal-common/src/observability.types.js +2 -2
  153. package/dist/internal-common/src/shutdown.manager.d.ts +20 -20
  154. package/dist/internal-common/src/shutdown.manager.js +76 -76
  155. package/dist/internal-common/src/utils.d.ts +5 -5
  156. package/dist/internal-common/src/utils.js +29 -29
  157. package/dist/local-backend/src/index.d.ts +4 -4
  158. package/dist/local-backend/src/index.js +20 -20
  159. package/dist/local-backend/src/local-backend-socket.service.d.ts +18 -18
  160. package/dist/local-backend/src/local-backend-socket.service.js +108 -108
  161. package/dist/local-backend/src/local-backend.app.d.ts +2 -2
  162. package/dist/local-backend/src/local-backend.app.js +19 -19
  163. package/dist/local-backend/src/local-backend.controller.d.ts +8 -8
  164. package/dist/local-backend/src/local-backend.controller.js +49 -49
  165. package/dist/local-backend/src/local-backend.module.d.ts +8 -8
  166. package/dist/local-backend/src/local-backend.module.js +53 -53
  167. package/dist/local-backend/src/local-backend.service.d.ts +15 -15
  168. package/dist/local-backend/src/local-backend.service.js +165 -165
  169. package/dist/tsconfig.build.tsbuildinfo +1 -1
  170. package/package.json +1 -1
  171. package/dist/common/src/query/simple-query-builder.js +0 -115
  172. package/dist/common/src/query/simple-query-builder.js.map +0 -1
@@ -1,92 +1,92 @@
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
- export 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
- clientRequestId: ClientRequestId;
56
- query: Query;
57
- subscribe: boolean;
58
- }
59
- export interface QueryUnsubscribeRequest {
60
- clientRequestId: ClientRequestId;
61
- }
62
- export interface QueryRegisterRequest {
63
- clientRequestId: ClientRequestId;
64
- query: Query;
65
- parentClientRequestId: ClientRequestId;
66
- }
67
- interface QueryMetadata {
68
- condCount: number;
69
- }
70
- export type QueryMapping<T extends string> = {
71
- unconditional: Array<T>;
72
- conditional: Record<FieldName, Record<Operator, Record<PrimitiveFieldType & string, Array<T>>>>;
73
- queriesMetadata: Record<T, QueryMetadata>;
74
- };
75
- export declare abstract class QueryMappingManager<T> {
76
- abstract addQuery(appId: AppId, query: Query, key: T): Promise<void>;
77
- abstract removeQuery(appId: AppId, key: T): Promise<Query | undefined>;
78
- abstract findQueriesForDocument(appId: AppId, doc: SquidDocument, collectionName: CollectionName, integrationId: IntegrationId): Promise<Array<T> | undefined>;
79
- abstract removeLocalDevAppData(appId: AppId): Promise<void>;
80
- }
81
- export declare abstract class SimpleQueryMappingManager<T extends string> extends QueryMappingManager<T> {
82
- abstract getMapping(appId: AppId, collectionName: CollectionName, integrationId: IntegrationId): Promise<QueryMapping<T> | undefined> | (QueryMapping<T> | undefined);
83
- findQueriesForDocument(appId: AppId, doc: SquidDocument, collectionName: CollectionName, integrationId: IntegrationId): Promise<Array<T>>;
84
- }
85
- export declare function findQueriesForDocumentSync<T extends string>(mapping: QueryMapping<T>, doc: SquidDocument): Array<T>;
86
- export declare function compareOperator(conditionValue: PrimitiveFieldType, valueInDocument: PrimitiveFieldType, operator: Operator): boolean;
87
- export declare function getQuerySubscriptionId(clientId: string, clientRequestId: string): QuerySubscriptionId;
88
- export declare function parseQuerySubscriptionId(querySubscriptionId: QuerySubscriptionId): {
89
- clientId: string;
90
- clientRequestId: string;
91
- };
92
- 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
+ export 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
+ clientRequestId: ClientRequestId;
56
+ query: Query;
57
+ subscribe: boolean;
58
+ }
59
+ export interface QueryUnsubscribeRequest {
60
+ clientRequestId: ClientRequestId;
61
+ }
62
+ export interface QueryRegisterRequest {
63
+ clientRequestId: ClientRequestId;
64
+ query: Query;
65
+ parentClientRequestId: ClientRequestId;
66
+ }
67
+ interface QueryMetadata {
68
+ condCount: number;
69
+ }
70
+ export type QueryMapping<T extends string> = {
71
+ unconditional: Array<T>;
72
+ conditional: Record<FieldName, Record<Operator, Record<PrimitiveFieldType & string, Array<T>>>>;
73
+ queriesMetadata: Record<T, QueryMetadata>;
74
+ };
75
+ export declare abstract class QueryMappingManager<T> {
76
+ abstract addQuery(appId: AppId, query: Query, key: T): Promise<void>;
77
+ abstract removeQuery(appId: AppId, key: T): Promise<Query | undefined>;
78
+ abstract findQueriesForDocument(appId: AppId, doc: SquidDocument, collectionName: CollectionName, integrationId: IntegrationId): Promise<Array<T> | undefined>;
79
+ abstract removeLocalDevAppData(appId: AppId): Promise<void>;
80
+ }
81
+ export declare abstract class SimpleQueryMappingManager<T extends string> extends QueryMappingManager<T> {
82
+ abstract getMapping(appId: AppId, collectionName: CollectionName, integrationId: IntegrationId): Promise<QueryMapping<T> | undefined> | (QueryMapping<T> | undefined);
83
+ findQueriesForDocument(appId: AppId, doc: SquidDocument, collectionName: CollectionName, integrationId: IntegrationId): Promise<Array<T>>;
84
+ }
85
+ export declare function findQueriesForDocumentSync<T extends string>(mapping: QueryMapping<T>, doc: SquidDocument): Array<T>;
86
+ export declare function compareOperator(conditionValue: PrimitiveFieldType, valueInDocument: PrimitiveFieldType, operator: Operator): boolean;
87
+ export declare function getQuerySubscriptionId(clientId: string, clientRequestId: string): QuerySubscriptionId;
88
+ export declare function parseQuerySubscriptionId(querySubscriptionId: QuerySubscriptionId): {
89
+ clientId: string;
90
+ clientRequestId: string;
91
+ };
92
+ export {};
@@ -1,135 +1,135 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseQuerySubscriptionId = exports.getQuerySubscriptionId = exports.compareOperator = exports.findQueriesForDocumentSync = exports.SimpleQueryMappingManager = exports.QueryMappingManager = void 0;
4
- const nullish_1 = require("./utils/nullish");
5
- const object_1 = require("./utils/object");
6
- const serialization_1 = require("./utils/serialization");
7
- class QueryMappingManager {
8
- }
9
- exports.QueryMappingManager = QueryMappingManager;
10
- class SimpleQueryMappingManager extends QueryMappingManager {
11
- async findQueriesForDocument(appId, doc, collectionName, integrationId) {
12
- const mapping = await this.getMapping(appId, collectionName, integrationId);
13
- if (!mapping)
14
- return [];
15
- return findQueriesForDocumentSync(mapping, doc);
16
- }
17
- }
18
- exports.SimpleQueryMappingManager = SimpleQueryMappingManager;
19
- function findQueriesForDocumentSync(mapping, doc) {
20
- var _a;
21
- const result = [...(mapping.unconditional || [])];
22
- const ignoredMappedId = new Set();
23
- const mappedIdFoundMap = new Map();
24
- for (const [encodedFieldName, fieldMapping] of Object.entries(mapping.conditional || {})) {
25
- const fieldName = (0, serialization_1.decodeValueForMapping)(encodedFieldName);
26
- for (const [operator, operatorMapping] of Object.entries(fieldMapping)) {
27
- const matchedMappedId = [];
28
- const valueInDocument = (_a = (0, object_1.getInPath)(doc, fieldName)) !== null && _a !== void 0 ? _a : null;
29
- const encodedValueInDocument = (0, serialization_1.encodeValueForMapping)(valueInDocument);
30
- switch (operator) {
31
- case '==': {
32
- matchedMappedId.push(...(operatorMapping[encodedValueInDocument] || []));
33
- break;
34
- }
35
- case '!=': {
36
- const matchedSubscriptionIds = operatorMapping[encodedValueInDocument] || [];
37
- matchedSubscriptionIds.forEach((qsi) => ignoredMappedId.add(qsi));
38
- const restOfValues = Object.entries(operatorMapping).filter(([value]) => value !== encodedValueInDocument);
39
- for (const [ignored, mappedId] of restOfValues) {
40
- matchedMappedId.push(...mappedId);
41
- }
42
- break;
43
- }
44
- case '<':
45
- case '<=':
46
- case '>':
47
- case '>=':
48
- case 'like':
49
- case 'not like':
50
- case 'like_cs':
51
- case 'not like_cs': {
52
- if ((0, nullish_1.isNotNullish)(valueInDocument)) {
53
- matchedMappedId.push(...Object.entries(operatorMapping)
54
- .filter(([conditionValue]) => compareOperator((0, serialization_1.decodeValueForMapping)(conditionValue), valueInDocument, operator))
55
- .reduce((current, [ignored, matchedMappedId]) => {
56
- current.push(...matchedMappedId);
57
- return current;
58
- }, []));
59
- }
60
- break;
61
- }
62
- default:
63
- throw new Error('Unsupported operator: ' + operator);
64
- }
65
- for (const mappedId of matchedMappedId) {
66
- mappedIdFoundMap.set(mappedId, (mappedIdFoundMap.get(mappedId) || 0) + 1);
67
- }
68
- }
69
- }
70
- for (const [mappedId, matchCount] of mappedIdFoundMap.entries()) {
71
- if (ignoredMappedId.has(mappedId))
72
- continue;
73
- if (matchCount >= mapping.queriesMetadata[mappedId].condCount) {
74
- result.push(mappedId);
75
- }
76
- }
77
- return result;
78
- }
79
- exports.findQueriesForDocumentSync = findQueriesForDocumentSync;
80
- function compareOperator(conditionValue, valueInDocument, operator) {
81
- if (conditionValue === null || valueInDocument === null)
82
- return false;
83
- switch (operator) {
84
- case '<':
85
- return valueInDocument < conditionValue;
86
- case '<=':
87
- return valueInDocument <= conditionValue;
88
- case '>':
89
- return valueInDocument > conditionValue;
90
- case '>=':
91
- return valueInDocument >= conditionValue;
92
- case 'like':
93
- return (typeof valueInDocument === 'string' &&
94
- typeof conditionValue === 'string' &&
95
- isStringMatch(valueInDocument, conditionValue, false));
96
- case 'not like':
97
- return !(typeof valueInDocument === 'string' &&
98
- typeof conditionValue === 'string' &&
99
- isStringMatch(valueInDocument, conditionValue, false));
100
- case 'like_cs':
101
- return (typeof valueInDocument === 'string' &&
102
- typeof conditionValue === 'string' &&
103
- isStringMatch(valueInDocument, conditionValue, true));
104
- case 'not like_cs':
105
- return !(typeof valueInDocument === 'string' &&
106
- typeof conditionValue === 'string' &&
107
- isStringMatch(valueInDocument, conditionValue, true));
108
- default:
109
- throw new Error(`Unsupported operator comparison: ${operator}`);
110
- }
111
- }
112
- exports.compareOperator = compareOperator;
113
- function isStringMatch(str, pattern, caseSensitive) {
114
- if (!caseSensitive) {
115
- str = str.toLowerCase();
116
- pattern = pattern.toLowerCase();
117
- }
118
- const escapedPattern = pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
119
- const regexPattern = escapedPattern.replace(/%/g, '.*');
120
- const regex = new RegExp(`^${regexPattern}$`);
121
- return regex.test(str);
122
- }
123
- function getQuerySubscriptionId(clientId, clientRequestId) {
124
- return `${clientId}_${clientRequestId}`;
125
- }
126
- exports.getQuerySubscriptionId = getQuerySubscriptionId;
127
- function parseQuerySubscriptionId(querySubscriptionId) {
128
- const splitString = querySubscriptionId.split('_');
129
- return {
130
- clientId: splitString[0],
131
- clientRequestId: splitString[1],
132
- };
133
- }
134
- exports.parseQuerySubscriptionId = parseQuerySubscriptionId;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseQuerySubscriptionId = exports.getQuerySubscriptionId = exports.compareOperator = exports.findQueriesForDocumentSync = exports.SimpleQueryMappingManager = exports.QueryMappingManager = void 0;
4
+ const nullish_1 = require("./utils/nullish");
5
+ const object_1 = require("./utils/object");
6
+ const serialization_1 = require("./utils/serialization");
7
+ class QueryMappingManager {
8
+ }
9
+ exports.QueryMappingManager = QueryMappingManager;
10
+ class SimpleQueryMappingManager extends QueryMappingManager {
11
+ async findQueriesForDocument(appId, doc, collectionName, integrationId) {
12
+ const mapping = await this.getMapping(appId, collectionName, integrationId);
13
+ if (!mapping)
14
+ return [];
15
+ return findQueriesForDocumentSync(mapping, doc);
16
+ }
17
+ }
18
+ exports.SimpleQueryMappingManager = SimpleQueryMappingManager;
19
+ function findQueriesForDocumentSync(mapping, doc) {
20
+ var _a;
21
+ const result = [...(mapping.unconditional || [])];
22
+ const ignoredMappedId = new Set();
23
+ const mappedIdFoundMap = new Map();
24
+ for (const [encodedFieldName, fieldMapping] of Object.entries(mapping.conditional || {})) {
25
+ const fieldName = (0, serialization_1.decodeValueForMapping)(encodedFieldName);
26
+ for (const [operator, operatorMapping] of Object.entries(fieldMapping)) {
27
+ const matchedMappedId = [];
28
+ const valueInDocument = (_a = (0, object_1.getInPath)(doc, fieldName)) !== null && _a !== void 0 ? _a : null;
29
+ const encodedValueInDocument = (0, serialization_1.encodeValueForMapping)(valueInDocument);
30
+ switch (operator) {
31
+ case '==': {
32
+ matchedMappedId.push(...(operatorMapping[encodedValueInDocument] || []));
33
+ break;
34
+ }
35
+ case '!=': {
36
+ const matchedSubscriptionIds = operatorMapping[encodedValueInDocument] || [];
37
+ matchedSubscriptionIds.forEach((qsi) => ignoredMappedId.add(qsi));
38
+ const restOfValues = Object.entries(operatorMapping).filter(([value]) => value !== encodedValueInDocument);
39
+ for (const [ignored, mappedId] of restOfValues) {
40
+ matchedMappedId.push(...mappedId);
41
+ }
42
+ break;
43
+ }
44
+ case '<':
45
+ case '<=':
46
+ case '>':
47
+ case '>=':
48
+ case 'like':
49
+ case 'not like':
50
+ case 'like_cs':
51
+ case 'not like_cs': {
52
+ if ((0, nullish_1.isNotNullish)(valueInDocument)) {
53
+ matchedMappedId.push(...Object.entries(operatorMapping)
54
+ .filter(([conditionValue]) => compareOperator((0, serialization_1.decodeValueForMapping)(conditionValue), valueInDocument, operator))
55
+ .reduce((current, [ignored, matchedMappedId]) => {
56
+ current.push(...matchedMappedId);
57
+ return current;
58
+ }, []));
59
+ }
60
+ break;
61
+ }
62
+ default:
63
+ throw new Error('Unsupported operator: ' + operator);
64
+ }
65
+ for (const mappedId of matchedMappedId) {
66
+ mappedIdFoundMap.set(mappedId, (mappedIdFoundMap.get(mappedId) || 0) + 1);
67
+ }
68
+ }
69
+ }
70
+ for (const [mappedId, matchCount] of mappedIdFoundMap.entries()) {
71
+ if (ignoredMappedId.has(mappedId))
72
+ continue;
73
+ if (matchCount >= mapping.queriesMetadata[mappedId].condCount) {
74
+ result.push(mappedId);
75
+ }
76
+ }
77
+ return result;
78
+ }
79
+ exports.findQueriesForDocumentSync = findQueriesForDocumentSync;
80
+ function compareOperator(conditionValue, valueInDocument, operator) {
81
+ if (conditionValue === null || valueInDocument === null)
82
+ return false;
83
+ switch (operator) {
84
+ case '<':
85
+ return valueInDocument < conditionValue;
86
+ case '<=':
87
+ return valueInDocument <= conditionValue;
88
+ case '>':
89
+ return valueInDocument > conditionValue;
90
+ case '>=':
91
+ return valueInDocument >= conditionValue;
92
+ case 'like':
93
+ return (typeof valueInDocument === 'string' &&
94
+ typeof conditionValue === 'string' &&
95
+ isStringMatch(valueInDocument, conditionValue, false));
96
+ case 'not like':
97
+ return !(typeof valueInDocument === 'string' &&
98
+ typeof conditionValue === 'string' &&
99
+ isStringMatch(valueInDocument, conditionValue, false));
100
+ case 'like_cs':
101
+ return (typeof valueInDocument === 'string' &&
102
+ typeof conditionValue === 'string' &&
103
+ isStringMatch(valueInDocument, conditionValue, true));
104
+ case 'not like_cs':
105
+ return !(typeof valueInDocument === 'string' &&
106
+ typeof conditionValue === 'string' &&
107
+ isStringMatch(valueInDocument, conditionValue, true));
108
+ default:
109
+ throw new Error(`Unsupported operator comparison: ${operator}`);
110
+ }
111
+ }
112
+ exports.compareOperator = compareOperator;
113
+ function isStringMatch(str, pattern, caseSensitive) {
114
+ if (!caseSensitive) {
115
+ str = str.toLowerCase();
116
+ pattern = pattern.toLowerCase();
117
+ }
118
+ const escapedPattern = pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
119
+ const regexPattern = escapedPattern.replace(/%/g, '.*');
120
+ const regex = new RegExp(`^${regexPattern}$`);
121
+ return regex.test(str);
122
+ }
123
+ function getQuerySubscriptionId(clientId, clientRequestId) {
124
+ return `${clientId}_${clientRequestId}`;
125
+ }
126
+ exports.getQuerySubscriptionId = getQuerySubscriptionId;
127
+ function parseQuerySubscriptionId(querySubscriptionId) {
128
+ const splitString = querySubscriptionId.split('_');
129
+ return {
130
+ clientId: splitString[0],
131
+ clientRequestId: splitString[1],
132
+ };
133
+ }
134
+ exports.parseQuerySubscriptionId = parseQuerySubscriptionId;
135
135
  //# sourceMappingURL=query.types.js.map
@@ -1,21 +1,21 @@
1
- export type SquidCloudId = 'aws' | 'gcp' | 'azure';
2
- export declare const SupportedSquidRegions: readonly ["us-east-1.aws"];
3
- export type SupportedSquidRegion = (typeof SupportedSquidRegions)[number];
4
- export interface SquidCloudRegion {
5
- id: string;
6
- name: string;
7
- }
8
- export interface SquidSupportedCloud {
9
- id: SquidCloudId;
10
- name: string;
11
- icon: string;
12
- regions: Array<SquidCloudRegion>;
13
- tooltip?: string;
14
- }
15
- export declare const squidSupportedRegionMap: Record<SupportedSquidRegion, SquidCloudRegion>;
16
- export declare function getSquidSupportedCloudMap(): Record<SquidCloudId, SquidSupportedCloud>;
17
- export declare function convertToSquidRegion(cloudId: SquidCloudId, region: string): SupportedSquidRegion;
18
- export declare function convertFromSquidRegion(regionAndCloud: SupportedSquidRegion): {
19
- cloudId: SquidCloudId;
20
- region: string;
21
- };
1
+ export type SquidCloudId = 'aws' | 'gcp' | 'azure';
2
+ export declare const SupportedSquidRegions: readonly ["us-east-1.aws"];
3
+ export type SupportedSquidRegion = (typeof SupportedSquidRegions)[number];
4
+ export interface SquidCloudRegion {
5
+ id: string;
6
+ name: string;
7
+ }
8
+ export interface SquidSupportedCloud {
9
+ id: SquidCloudId;
10
+ name: string;
11
+ icon: string;
12
+ regions: Array<SquidCloudRegion>;
13
+ tooltip?: string;
14
+ }
15
+ export declare const squidSupportedRegionMap: Record<SupportedSquidRegion, SquidCloudRegion>;
16
+ export declare function getSquidSupportedCloudMap(): Record<SquidCloudId, SquidSupportedCloud>;
17
+ export declare function convertToSquidRegion(cloudId: SquidCloudId, region: string): SupportedSquidRegion;
18
+ export declare function convertFromSquidRegion(regionAndCloud: SupportedSquidRegion): {
19
+ cloudId: SquidCloudId;
20
+ region: string;
21
+ };
@@ -1,47 +1,47 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertFromSquidRegion = exports.convertToSquidRegion = exports.getSquidSupportedCloudMap = exports.squidSupportedRegionMap = exports.SupportedSquidRegions = void 0;
4
- const nullish_1 = require("./utils/nullish");
5
- exports.SupportedSquidRegions = ['us-east-1.aws'];
6
- exports.squidSupportedRegionMap = {
7
- 'us-east-1.aws': { id: 'us-east-1', name: 'US East (N. Virginia)' },
8
- ['us-east-1.aws-dev']: { id: 'us-east-1', name: 'US East (N. Virginia - Dev)' },
9
- ['local']: { id: 'local', name: 'Local' },
10
- };
11
- function getSquidSupportedCloudMap() {
12
- return {
13
- aws: {
14
- id: 'aws',
15
- name: 'Amazon Web Services',
16
- icon: 'aws_icon',
17
- regions: [exports.squidSupportedRegionMap['us-east-1.aws']].filter(nullish_1.isNotNullish),
18
- },
19
- gcp: {
20
- id: 'gcp',
21
- name: 'Google Cloud Platform',
22
- icon: 'gcp_icon',
23
- tooltip: 'Google Cloud (GCP) support is coming soon!',
24
- regions: [],
25
- },
26
- azure: {
27
- id: 'azure',
28
- name: 'Microsoft Azure',
29
- icon: 'azure_icon',
30
- tooltip: 'Microsoft Azure support is coming soon!',
31
- regions: [],
32
- },
33
- };
34
- }
35
- exports.getSquidSupportedCloudMap = getSquidSupportedCloudMap;
36
- function convertToSquidRegion(cloudId, region) {
37
- if (region === 'local')
38
- return 'local';
39
- return `${region}.${cloudId}`;
40
- }
41
- exports.convertToSquidRegion = convertToSquidRegion;
42
- function convertFromSquidRegion(regionAndCloud) {
43
- const splitRegion = regionAndCloud.split('.');
44
- return { cloudId: splitRegion[1], region: splitRegion[0] };
45
- }
46
- exports.convertFromSquidRegion = convertFromSquidRegion;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertFromSquidRegion = exports.convertToSquidRegion = exports.getSquidSupportedCloudMap = exports.squidSupportedRegionMap = exports.SupportedSquidRegions = void 0;
4
+ const nullish_1 = require("./utils/nullish");
5
+ exports.SupportedSquidRegions = ['us-east-1.aws'];
6
+ exports.squidSupportedRegionMap = {
7
+ 'us-east-1.aws': { id: 'us-east-1', name: 'US East (N. Virginia)' },
8
+ ['us-east-1.aws-dev']: { id: 'us-east-1', name: 'US East (N. Virginia - Dev)' },
9
+ ['local']: { id: 'local', name: 'Local' },
10
+ };
11
+ function getSquidSupportedCloudMap() {
12
+ return {
13
+ aws: {
14
+ id: 'aws',
15
+ name: 'Amazon Web Services',
16
+ icon: 'aws_icon',
17
+ regions: [exports.squidSupportedRegionMap['us-east-1.aws']].filter(nullish_1.isNotNullish),
18
+ },
19
+ gcp: {
20
+ id: 'gcp',
21
+ name: 'Google Cloud Platform',
22
+ icon: 'gcp_icon',
23
+ tooltip: 'Google Cloud (GCP) support is coming soon!',
24
+ regions: [],
25
+ },
26
+ azure: {
27
+ id: 'azure',
28
+ name: 'Microsoft Azure',
29
+ icon: 'azure_icon',
30
+ tooltip: 'Microsoft Azure support is coming soon!',
31
+ regions: [],
32
+ },
33
+ };
34
+ }
35
+ exports.getSquidSupportedCloudMap = getSquidSupportedCloudMap;
36
+ function convertToSquidRegion(cloudId, region) {
37
+ if (region === 'local')
38
+ return 'local';
39
+ return `${region}.${cloudId}`;
40
+ }
41
+ exports.convertToSquidRegion = convertToSquidRegion;
42
+ function convertFromSquidRegion(regionAndCloud) {
43
+ const splitRegion = regionAndCloud.split('.');
44
+ return { cloudId: splitRegion[1], region: splitRegion[0] };
45
+ }
46
+ exports.convertFromSquidRegion = convertFromSquidRegion;
47
47
  //# sourceMappingURL=regions.js.map