@squidcloud/local-backend 1.0.39 → 1.0.40

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 (170) 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 -31
  32. package/dist/common/src/document.types.js +50 -49
  33. package/dist/common/src/document.types.js.map +1 -1
  34. package/dist/common/src/graphql.context.d.ts +14 -14
  35. package/dist/common/src/graphql.context.js +12 -12
  36. package/dist/common/src/graphql.types.d.ts +11 -11
  37. package/dist/common/src/graphql.types.js +34 -34
  38. package/dist/common/src/heartbeat.types.d.ts +4 -4
  39. package/dist/common/src/heartbeat.types.js +16 -16
  40. package/dist/common/src/http-status.enum.d.ts +50 -50
  41. package/dist/common/src/http-status.enum.js +54 -54
  42. package/dist/common/src/index.d.ts +54 -54
  43. package/dist/common/src/index.js +70 -70
  44. package/dist/common/src/integrations/ai_assistant.types.d.ts +30 -30
  45. package/dist/common/src/integrations/ai_assistant.types.js +2 -2
  46. package/dist/common/src/integrations/api.types.d.ts +80 -80
  47. package/dist/common/src/integrations/api.types.js +2 -2
  48. package/dist/common/src/integrations/auth.types.d.ts +39 -39
  49. package/dist/common/src/integrations/auth.types.js +2 -2
  50. package/dist/common/src/integrations/database.types.d.ts +236 -236
  51. package/dist/common/src/integrations/database.types.js +2 -2
  52. package/dist/common/src/integrations/index.d.ts +101 -101
  53. package/dist/common/src/integrations/index.js +105 -105
  54. package/dist/common/src/integrations/observability.types.d.ts +23 -23
  55. package/dist/common/src/integrations/observability.types.js +23 -23
  56. package/dist/common/src/logger.types.d.ts +21 -21
  57. package/dist/common/src/logger.types.js +11 -11
  58. package/dist/common/src/metrics.types.d.ts +73 -73
  59. package/dist/common/src/metrics.types.js +11 -11
  60. package/dist/common/src/mutation.context.d.ts +13 -13
  61. package/dist/common/src/mutation.context.js +26 -26
  62. package/dist/common/src/mutation.schemas.d.ts +5 -5
  63. package/dist/common/src/mutation.schemas.js +114 -114
  64. package/dist/common/src/mutation.types.d.ts +63 -63
  65. package/dist/common/src/mutation.types.js +142 -142
  66. package/dist/common/src/named-query.context.d.ts +4 -4
  67. package/dist/common/src/named-query.context.js +9 -9
  68. package/dist/common/src/named-query.schemas.d.ts +3 -3
  69. package/dist/common/src/named-query.schemas.js +13 -13
  70. package/dist/common/src/named-query.types.d.ts +8 -8
  71. package/dist/common/src/named-query.types.js +2 -2
  72. package/dist/common/src/query/index.d.ts +2 -2
  73. package/dist/common/src/query/index.js +18 -18
  74. package/dist/common/src/query/query-context.d.ts +24 -29
  75. package/dist/common/src/query/query-context.js +158 -185
  76. package/dist/common/src/query/query-context.js.map +1 -1
  77. package/dist/common/src/query/simple-query-builder.d.ts +29 -29
  78. package/dist/common/src/query/simple-query-builder.js +114 -114
  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
@@ -1,115 +1,115 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SimpleQueryBuilder = exports.BaseQueryBuilderInterface = void 0;
4
- const _ = require("lodash");
5
- const assert_1 = require("../utils/assert");
6
- const validation_1 = require("../utils/validation");
7
- class BaseQueryBuilderInterface {
8
- eq(fieldName, value) {
9
- return this.where(fieldName, '==', value);
10
- }
11
- neq(fieldName, value) {
12
- return this.where(fieldName, '!=', value);
13
- }
14
- in(fieldName, value) {
15
- return this.where(fieldName, 'in', value);
16
- }
17
- nin(fieldName, value) {
18
- return this.where(fieldName, 'not in', value);
19
- }
20
- gt(fieldName, value) {
21
- return this.where(fieldName, '>', value);
22
- }
23
- gte(fieldName, value) {
24
- return this.where(fieldName, '>=', value);
25
- }
26
- lt(fieldName, value) {
27
- return this.where(fieldName, '<', value);
28
- }
29
- lte(fieldName, value) {
30
- return this.where(fieldName, '<=', value);
31
- }
32
- like(fieldName, pattern, caseSensitive) {
33
- return this.where(fieldName, caseSensitive ? 'like_cs' : 'like', pattern);
34
- }
35
- notLike(fieldName, pattern, caseSensitive) {
36
- return this.where(fieldName, caseSensitive ? 'not like_cs' : 'not like', pattern);
37
- }
38
- }
39
- exports.BaseQueryBuilderInterface = BaseQueryBuilderInterface;
40
- class SimpleQueryBuilder extends BaseQueryBuilderInterface {
41
- constructor(collectionName, integrationId) {
42
- super();
43
- this.collectionName = collectionName;
44
- this.integrationId = integrationId;
45
- this.query = {
46
- integrationId,
47
- collectionName,
48
- conditions: [],
49
- limit: -1,
50
- sortOrder: [],
51
- };
52
- }
53
- where(fieldName, operator, value) {
54
- if (operator === 'in' || operator === 'not in') {
55
- const values = value instanceof Array ? [...value] : [value];
56
- for (const value of values) {
57
- this.query.conditions.push({
58
- fieldName,
59
- operator: operator === 'in' ? '==' : '!=',
60
- value: value,
61
- });
62
- }
63
- return this;
64
- }
65
- this.query.conditions.push({
66
- fieldName,
67
- operator,
68
- value: value,
69
- });
70
- return this;
71
- }
72
- limit(limit) {
73
- (0, validation_1.validateQueryLimit)(limit);
74
- (0, assert_1.assertTruthy)(this.query.limit === -1, 'The limit was already set.');
75
- this.query.limit = limit;
76
- return this;
77
- }
78
- sortBy(fieldName, asc = true) {
79
- const fieldSort = { asc, fieldName };
80
- (0, validation_1.validateFieldSort)(fieldSort);
81
- (0, assert_1.assertTruthy)(!this.query.sortOrder.some((so) => so.fieldName === fieldName), `${fieldName} already in the sort list.`);
82
- this.query.sortOrder.push(fieldSort);
83
- return this;
84
- }
85
- build() {
86
- const mergedConditions = this.mergeConditions();
87
- return Object.assign(Object.assign({}, this.query), { conditions: mergedConditions });
88
- }
89
- mergeConditions() {
90
- const result = [];
91
- const groupByFieldName = _.groupBy(this.query.conditions || [], (condition) => condition.fieldName);
92
- for (const fieldNameGroup of Object.values(groupByFieldName)) {
93
- const groupByOperator = _.groupBy(fieldNameGroup, (operator) => operator.operator);
94
- for (const [operator, operatorGroup] of Object.entries(groupByOperator)) {
95
- if (operator === '==' || operator === '!=') {
96
- result.push(...operatorGroup);
97
- continue;
98
- }
99
- const sorted = _.sortBy(operatorGroup, (o) => o.value);
100
- if (operator === '>' || operator === '>=') {
101
- result.push(sorted[sorted.length - 1]);
102
- }
103
- else if (operator === '<' || operator === '<=') {
104
- result.push(sorted[0]);
105
- }
106
- else {
107
- result.push(sorted[0]);
108
- }
109
- }
110
- }
111
- return result;
112
- }
113
- }
114
- exports.SimpleQueryBuilder = SimpleQueryBuilder;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SimpleQueryBuilder = exports.BaseQueryBuilderInterface = void 0;
4
+ const _ = require("lodash");
5
+ const assert_1 = require("../utils/assert");
6
+ const validation_1 = require("../utils/validation");
7
+ class BaseQueryBuilderInterface {
8
+ eq(fieldName, value) {
9
+ return this.where(fieldName, '==', value);
10
+ }
11
+ neq(fieldName, value) {
12
+ return this.where(fieldName, '!=', value);
13
+ }
14
+ in(fieldName, value) {
15
+ return this.where(fieldName, 'in', value);
16
+ }
17
+ nin(fieldName, value) {
18
+ return this.where(fieldName, 'not in', value);
19
+ }
20
+ gt(fieldName, value) {
21
+ return this.where(fieldName, '>', value);
22
+ }
23
+ gte(fieldName, value) {
24
+ return this.where(fieldName, '>=', value);
25
+ }
26
+ lt(fieldName, value) {
27
+ return this.where(fieldName, '<', value);
28
+ }
29
+ lte(fieldName, value) {
30
+ return this.where(fieldName, '<=', value);
31
+ }
32
+ like(fieldName, pattern, caseSensitive) {
33
+ return this.where(fieldName, caseSensitive ? 'like_cs' : 'like', pattern);
34
+ }
35
+ notLike(fieldName, pattern, caseSensitive) {
36
+ return this.where(fieldName, caseSensitive ? 'not like_cs' : 'not like', pattern);
37
+ }
38
+ }
39
+ exports.BaseQueryBuilderInterface = BaseQueryBuilderInterface;
40
+ class SimpleQueryBuilder extends BaseQueryBuilderInterface {
41
+ constructor(collectionName, integrationId) {
42
+ super();
43
+ this.collectionName = collectionName;
44
+ this.integrationId = integrationId;
45
+ this.query = {
46
+ integrationId,
47
+ collectionName,
48
+ conditions: [],
49
+ limit: -1,
50
+ sortOrder: [],
51
+ };
52
+ }
53
+ where(fieldName, operator, value) {
54
+ if (operator === 'in' || operator === 'not in') {
55
+ const values = value instanceof Array ? [...value] : [value];
56
+ for (const value of values) {
57
+ this.query.conditions.push({
58
+ fieldName,
59
+ operator: operator === 'in' ? '==' : '!=',
60
+ value: value,
61
+ });
62
+ }
63
+ return this;
64
+ }
65
+ this.query.conditions.push({
66
+ fieldName,
67
+ operator,
68
+ value: value,
69
+ });
70
+ return this;
71
+ }
72
+ limit(limit) {
73
+ (0, validation_1.validateQueryLimit)(limit);
74
+ (0, assert_1.assertTruthy)(this.query.limit === -1, 'The limit was already set.');
75
+ this.query.limit = limit;
76
+ return this;
77
+ }
78
+ sortBy(fieldName, asc = true) {
79
+ const fieldSort = { asc, fieldName };
80
+ (0, validation_1.validateFieldSort)(fieldSort);
81
+ (0, assert_1.assertTruthy)(!this.query.sortOrder.some((so) => so.fieldName === fieldName), `${fieldName} already in the sort list.`);
82
+ this.query.sortOrder.push(fieldSort);
83
+ return this;
84
+ }
85
+ build() {
86
+ const mergedConditions = this.mergeConditions();
87
+ return Object.assign(Object.assign({}, this.query), { conditions: mergedConditions });
88
+ }
89
+ mergeConditions() {
90
+ const result = [];
91
+ const groupByFieldName = _.groupBy(this.query.conditions || [], (condition) => condition.fieldName);
92
+ for (const fieldNameGroup of Object.values(groupByFieldName)) {
93
+ const groupByOperator = _.groupBy(fieldNameGroup, (operator) => operator.operator);
94
+ for (const [operator, operatorGroup] of Object.entries(groupByOperator)) {
95
+ if (operator === '==' || operator === '!=') {
96
+ result.push(...operatorGroup);
97
+ continue;
98
+ }
99
+ const sorted = _.sortBy(operatorGroup, (o) => o.value);
100
+ if (operator === '>' || operator === '>=') {
101
+ result.push(sorted[sorted.length - 1]);
102
+ }
103
+ else if (operator === '<' || operator === '<=') {
104
+ result.push(sorted[0]);
105
+ }
106
+ else {
107
+ result.push(sorted[0]);
108
+ }
109
+ }
110
+ }
111
+ return result;
112
+ }
113
+ }
114
+ exports.SimpleQueryBuilder = SimpleQueryBuilder;
115
115
  //# sourceMappingURL=simple-query-builder.js.map
@@ -1,6 +1,6 @@
1
- import { JSONSchemaType } from 'ajv';
2
- import { Query, QueryRegisterRequest, 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>;
6
- export declare const QueryRegisterRequestSchema: JSONSchemaType<QueryRegisterRequest>;
1
+ import { JSONSchemaType } from 'ajv';
2
+ import { Query, QueryRegisterRequest, 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>;
6
+ export declare const QueryRegisterRequestSchema: JSONSchemaType<QueryRegisterRequest>;
@@ -1,97 +1,97 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueryRegisterRequestSchema = exports.QueryUnsubscribeRequestSchema = exports.QueryRequestSchema = exports.QuerySchema = void 0;
4
- exports.QuerySchema = {
5
- $id: 'querySchema',
6
- type: 'object',
7
- required: ['collectionName', 'integrationId'],
8
- properties: {
9
- collectionName: { type: 'string', nullable: false },
10
- integrationId: { type: 'string', nullable: false },
11
- conditions: {
12
- type: 'array',
13
- nullable: false,
14
- items: {
15
- type: 'object',
16
- nullable: false,
17
- required: ['fieldName', 'operator', 'value'],
18
- properties: {
19
- fieldName: { type: 'string', nullable: false },
20
- operator: {
21
- type: 'string',
22
- nullable: false,
23
- enum: ['==', '>=', '<=', '>', '<', '!=', 'like', 'not like', 'like_cs', 'not like_cs'],
24
- },
25
- value: {
26
- $ref: 'querySchema#/definitions/conditionValueSchema',
27
- },
28
- },
29
- },
30
- },
31
- sortOrder: {
32
- type: 'array',
33
- nullable: false,
34
- items: {
35
- type: 'object',
36
- required: ['fieldName', 'asc'],
37
- properties: {
38
- fieldName: { type: 'string' },
39
- asc: { type: 'boolean' },
40
- },
41
- },
42
- },
43
- limit: { type: 'number', nullable: false },
44
- },
45
- definitions: {
46
- conditionValueSchema: {
47
- oneOf: [
48
- { type: 'null', nullable: true },
49
- { type: 'string', nullable: false },
50
- { type: 'number', nullable: false },
51
- { type: 'boolean', nullable: false },
52
- {
53
- type: 'array',
54
- nullable: false,
55
- items: {
56
- $ref: 'querySchema#/definitions/conditionValueSchema',
57
- },
58
- },
59
- {
60
- type: 'object',
61
- nullable: false,
62
- patternProperties: {
63
- '[0-9a-zA-Z\\$_\\-\\.]{1,64}': {
64
- $ref: 'querySchema#/definitions/conditionValueSchema',
65
- },
66
- },
67
- },
68
- ],
69
- },
70
- },
71
- };
72
- exports.QueryRequestSchema = {
73
- type: 'object',
74
- required: ['clientRequestId', 'query', 'subscribe'],
75
- properties: {
76
- clientRequestId: { type: 'string', nullable: false },
77
- query: exports.QuerySchema,
78
- subscribe: { type: 'boolean', nullable: false },
79
- },
80
- };
81
- exports.QueryUnsubscribeRequestSchema = {
82
- type: 'object',
83
- required: ['clientRequestId'],
84
- properties: {
85
- clientRequestId: { type: 'string', nullable: false },
86
- },
87
- };
88
- exports.QueryRegisterRequestSchema = {
89
- type: 'object',
90
- required: ['clientRequestId', 'query', 'parentClientRequestId'],
91
- properties: {
92
- clientRequestId: { type: 'string', nullable: false },
93
- query: exports.QuerySchema,
94
- parentClientRequestId: { type: 'string', nullable: false },
95
- },
96
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QueryRegisterRequestSchema = exports.QueryUnsubscribeRequestSchema = exports.QueryRequestSchema = exports.QuerySchema = void 0;
4
+ exports.QuerySchema = {
5
+ $id: 'querySchema',
6
+ type: 'object',
7
+ required: ['collectionName', 'integrationId'],
8
+ properties: {
9
+ collectionName: { type: 'string', nullable: false },
10
+ integrationId: { type: 'string', nullable: false },
11
+ conditions: {
12
+ type: 'array',
13
+ nullable: false,
14
+ items: {
15
+ type: 'object',
16
+ nullable: false,
17
+ required: ['fieldName', 'operator', 'value'],
18
+ properties: {
19
+ fieldName: { type: 'string', nullable: false },
20
+ operator: {
21
+ type: 'string',
22
+ nullable: false,
23
+ enum: ['==', '>=', '<=', '>', '<', '!=', 'like', 'not like', 'like_cs', 'not like_cs'],
24
+ },
25
+ value: {
26
+ $ref: 'querySchema#/definitions/conditionValueSchema',
27
+ },
28
+ },
29
+ },
30
+ },
31
+ sortOrder: {
32
+ type: 'array',
33
+ nullable: false,
34
+ items: {
35
+ type: 'object',
36
+ required: ['fieldName', 'asc'],
37
+ properties: {
38
+ fieldName: { type: 'string' },
39
+ asc: { type: 'boolean' },
40
+ },
41
+ },
42
+ },
43
+ limit: { type: 'number', nullable: false },
44
+ },
45
+ definitions: {
46
+ conditionValueSchema: {
47
+ oneOf: [
48
+ { type: 'null', nullable: true },
49
+ { type: 'string', nullable: false },
50
+ { type: 'number', nullable: false },
51
+ { type: 'boolean', nullable: false },
52
+ {
53
+ type: 'array',
54
+ nullable: false,
55
+ items: {
56
+ $ref: 'querySchema#/definitions/conditionValueSchema',
57
+ },
58
+ },
59
+ {
60
+ type: 'object',
61
+ nullable: false,
62
+ patternProperties: {
63
+ '[0-9a-zA-Z\\$_\\-\\.]{1,64}': {
64
+ $ref: 'querySchema#/definitions/conditionValueSchema',
65
+ },
66
+ },
67
+ },
68
+ ],
69
+ },
70
+ },
71
+ };
72
+ exports.QueryRequestSchema = {
73
+ type: 'object',
74
+ required: ['clientRequestId', 'query', 'subscribe'],
75
+ properties: {
76
+ clientRequestId: { type: 'string', nullable: false },
77
+ query: exports.QuerySchema,
78
+ subscribe: { type: 'boolean', nullable: false },
79
+ },
80
+ };
81
+ exports.QueryUnsubscribeRequestSchema = {
82
+ type: 'object',
83
+ required: ['clientRequestId'],
84
+ properties: {
85
+ clientRequestId: { type: 'string', nullable: false },
86
+ },
87
+ };
88
+ exports.QueryRegisterRequestSchema = {
89
+ type: 'object',
90
+ required: ['clientRequestId', 'query', 'parentClientRequestId'],
91
+ properties: {
92
+ clientRequestId: { type: 'string', nullable: false },
93
+ query: exports.QuerySchema,
94
+ parentClientRequestId: { type: 'string', nullable: false },
95
+ },
96
+ };
97
97
  //# sourceMappingURL=query.schemas.js.map
@@ -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 {};