@oneuptime/common 10.0.69 → 10.0.70

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 (82) hide show
  1. package/Models/DatabaseModels/KubernetesCluster.ts +5 -0
  2. package/Server/Infrastructure/Postgres/SchemaMigrations/1776865086264-MigrationName.ts +11 -8
  3. package/Server/Infrastructure/Postgres/SchemaMigrations/1776881254913-DedupeKubernetesClustersAndAddUniqueIndex.ts +134 -0
  4. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
  5. package/Server/Services/DatabaseService.ts +10 -27
  6. package/Server/Services/KubernetesResourceService.ts +33 -10
  7. package/Server/Types/Database/QueryHelper.ts +127 -0
  8. package/Server/Types/Database/QueryUtil.ts +244 -0
  9. package/Types/BaseDatabase/EndsWith.ts +41 -0
  10. package/Types/BaseDatabase/IncludesAll.ts +45 -0
  11. package/Types/BaseDatabase/IncludesNone.ts +48 -0
  12. package/Types/BaseDatabase/NotContains.ts +41 -0
  13. package/Types/BaseDatabase/StartsWith.ts +41 -0
  14. package/Types/JSON.ts +20 -0
  15. package/Types/SerializableObjectDictionary.ts +10 -0
  16. package/UI/Components/Filters/BooleanFilter.tsx +1 -0
  17. package/UI/Components/Filters/DateFilter.tsx +212 -25
  18. package/UI/Components/Filters/DropdownFilter.tsx +1 -0
  19. package/UI/Components/Filters/EntityFilter.tsx +214 -41
  20. package/UI/Components/Filters/FilterViewer.tsx +228 -146
  21. package/UI/Components/Filters/FilterViewerItem.tsx +1 -11
  22. package/UI/Components/Filters/FiltersForm.tsx +148 -97
  23. package/UI/Components/Filters/NumberFilter.tsx +219 -34
  24. package/UI/Components/Filters/OperatorSelector.tsx +91 -0
  25. package/UI/Components/Filters/TextFilter.tsx +182 -71
  26. package/UI/Components/Filters/Types/FilterOperator.ts +73 -0
  27. package/UI/Components/ModelTable/BaseModelTable.tsx +8 -0
  28. package/build/dist/Models/DatabaseModels/KubernetesCluster.js +7 -1
  29. package/build/dist/Models/DatabaseModels/KubernetesCluster.js.map +1 -1
  30. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776865086264-MigrationName.js +1 -1
  31. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776865086264-MigrationName.js.map +1 -1
  32. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776881254913-DedupeKubernetesClustersAndAddUniqueIndex.js +123 -0
  33. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776881254913-DedupeKubernetesClustersAndAddUniqueIndex.js.map +1 -0
  34. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
  35. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  36. package/build/dist/Server/Services/DatabaseService.js +9 -6
  37. package/build/dist/Server/Services/DatabaseService.js.map +1 -1
  38. package/build/dist/Server/Services/KubernetesResourceService.js +4 -2
  39. package/build/dist/Server/Services/KubernetesResourceService.js.map +1 -1
  40. package/build/dist/Server/Types/Database/QueryHelper.js +110 -0
  41. package/build/dist/Server/Types/Database/QueryHelper.js.map +1 -1
  42. package/build/dist/Server/Types/Database/QueryUtil.js +180 -0
  43. package/build/dist/Server/Types/Database/QueryUtil.js.map +1 -1
  44. package/build/dist/Types/BaseDatabase/EndsWith.js +31 -0
  45. package/build/dist/Types/BaseDatabase/EndsWith.js.map +1 -0
  46. package/build/dist/Types/BaseDatabase/IncludesAll.js +34 -0
  47. package/build/dist/Types/BaseDatabase/IncludesAll.js.map +1 -0
  48. package/build/dist/Types/BaseDatabase/IncludesNone.js +34 -0
  49. package/build/dist/Types/BaseDatabase/IncludesNone.js.map +1 -0
  50. package/build/dist/Types/BaseDatabase/NotContains.js +31 -0
  51. package/build/dist/Types/BaseDatabase/NotContains.js.map +1 -0
  52. package/build/dist/Types/BaseDatabase/StartsWith.js +31 -0
  53. package/build/dist/Types/BaseDatabase/StartsWith.js.map +1 -0
  54. package/build/dist/Types/JSON.js +5 -0
  55. package/build/dist/Types/JSON.js.map +1 -1
  56. package/build/dist/Types/SerializableObjectDictionary.js +10 -0
  57. package/build/dist/Types/SerializableObjectDictionary.js.map +1 -1
  58. package/build/dist/UI/Components/Filters/BooleanFilter.js +1 -1
  59. package/build/dist/UI/Components/Filters/BooleanFilter.js.map +1 -1
  60. package/build/dist/UI/Components/Filters/DateFilter.js +158 -14
  61. package/build/dist/UI/Components/Filters/DateFilter.js.map +1 -1
  62. package/build/dist/UI/Components/Filters/DropdownFilter.js +1 -1
  63. package/build/dist/UI/Components/Filters/DropdownFilter.js.map +1 -1
  64. package/build/dist/UI/Components/Filters/EntityFilter.js +174 -30
  65. package/build/dist/UI/Components/Filters/EntityFilter.js.map +1 -1
  66. package/build/dist/UI/Components/Filters/FilterViewer.js +188 -97
  67. package/build/dist/UI/Components/Filters/FilterViewer.js.map +1 -1
  68. package/build/dist/UI/Components/Filters/FilterViewerItem.js +1 -6
  69. package/build/dist/UI/Components/Filters/FilterViewerItem.js.map +1 -1
  70. package/build/dist/UI/Components/Filters/FiltersForm.js +46 -38
  71. package/build/dist/UI/Components/Filters/FiltersForm.js.map +1 -1
  72. package/build/dist/UI/Components/Filters/NumberFilter.js +165 -23
  73. package/build/dist/UI/Components/Filters/NumberFilter.js.map +1 -1
  74. package/build/dist/UI/Components/Filters/OperatorSelector.js +41 -0
  75. package/build/dist/UI/Components/Filters/OperatorSelector.js.map +1 -0
  76. package/build/dist/UI/Components/Filters/TextFilter.js +130 -53
  77. package/build/dist/UI/Components/Filters/TextFilter.js.map +1 -1
  78. package/build/dist/UI/Components/Filters/Types/FilterOperator.js +63 -0
  79. package/build/dist/UI/Components/Filters/Types/FilterOperator.js.map +1 -0
  80. package/build/dist/UI/Components/ModelTable/BaseModelTable.js +7 -0
  81. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  82. package/package.json +1 -1
@@ -6,6 +6,11 @@ import GreaterThan from "../../../Types/BaseDatabase/GreaterThan";
6
6
  import GreaterThanOrEqual from "../../../Types/BaseDatabase/GreaterThanOrEqual";
7
7
  import InBetween from "../../../Types/BaseDatabase/InBetween";
8
8
  import Includes from "../../../Types/BaseDatabase/Includes";
9
+ import IncludesAll from "../../../Types/BaseDatabase/IncludesAll";
10
+ import IncludesNone from "../../../Types/BaseDatabase/IncludesNone";
11
+ import StartsWith from "../../../Types/BaseDatabase/StartsWith";
12
+ import EndsWith from "../../../Types/BaseDatabase/EndsWith";
13
+ import NotContains from "../../../Types/BaseDatabase/NotContains";
9
14
  import IsNull from "../../../Types/BaseDatabase/IsNull";
10
15
  import LessThan from "../../../Types/BaseDatabase/LessThan";
11
16
  import LessThanOrEqual from "../../../Types/BaseDatabase/LessThanOrEqual";
@@ -17,12 +22,16 @@ import TableColumnType from "../../../Types/Database/TableColumnType";
17
22
  import { JSONObject } from "../../../Types/JSON";
18
23
  import ObjectID from "../../../Types/ObjectID";
19
24
  import Typeof from "../../../Types/Typeof";
25
+ import { And, DataSource } from "typeorm";
20
26
  import { FindOperator } from "typeorm/find-options/FindOperator";
21
27
  import { CompareType } from "../../../Types/Database/CompareBase";
22
28
  import CaptureSpan from "../../Utils/Telemetry/CaptureSpan";
23
29
  import LessThanOrNull from "../../../Types/BaseDatabase/LessThanOrNull";
24
30
  import GreaterThanOrNull from "../../../Types/BaseDatabase/GreaterThanOrNull";
25
31
  import EqualTo from "../../../Types/BaseDatabase/EqualTo";
32
+ import PostgresAppInstance from "../../Infrastructure/PostgresDatabase";
33
+ import { RelationMetadata } from "typeorm/metadata/RelationMetadata";
34
+ import { EntityMetadata } from "typeorm/metadata/EntityMetadata";
26
35
 
27
36
  export default class QueryUtil {
28
37
  @CaptureSpan()
@@ -111,6 +120,30 @@ export default class QueryUtil {
111
120
  query[key] = QueryHelper.search(
112
121
  (query[key] as Search<string>).toString() as any,
113
122
  ) as any;
123
+ } else if (
124
+ query[key] &&
125
+ query[key] instanceof NotContains &&
126
+ tableColumnMetadata
127
+ ) {
128
+ query[key] = QueryHelper.notContains(
129
+ (query[key] as NotContains<string>).toString() as any,
130
+ ) as any;
131
+ } else if (
132
+ query[key] &&
133
+ query[key] instanceof StartsWith &&
134
+ tableColumnMetadata
135
+ ) {
136
+ query[key] = QueryHelper.startsWith(
137
+ (query[key] as StartsWith<string>).toString() as any,
138
+ ) as any;
139
+ } else if (
140
+ query[key] &&
141
+ query[key] instanceof EndsWith &&
142
+ tableColumnMetadata
143
+ ) {
144
+ query[key] = QueryHelper.endsWith(
145
+ (query[key] as EndsWith<string>).toString() as any,
146
+ ) as any;
114
147
  } else if (
115
148
  query[key] &&
116
149
  query[key] instanceof LessThan &&
@@ -142,6 +175,138 @@ export default class QueryUtil {
142
175
  query[key] = QueryHelper.greaterThan(
143
176
  (query[key] as GreaterThan<CompareType>).toString() as any,
144
177
  ) as any;
178
+ } else if (
179
+ query[key] &&
180
+ query[key] instanceof IncludesAll &&
181
+ tableColumnMetadata
182
+ ) {
183
+ if (tableColumnMetadata.type === TableColumnType.EntityArray) {
184
+ const includesAll: IncludesAll = query[key] as IncludesAll;
185
+ const values: Array<string | ObjectID> = (
186
+ includesAll.values as Array<string | ObjectID | number>
187
+ ).map((item: string | ObjectID | number) => {
188
+ if (
189
+ item !== null &&
190
+ typeof item === Typeof.Object &&
191
+ !(item instanceof ObjectID)
192
+ ) {
193
+ const itemRecord: JSONObject = item as unknown as JSONObject;
194
+ if (itemRecord["_id"]) {
195
+ return itemRecord["_id"] as string;
196
+ }
197
+ }
198
+ return item.toString();
199
+ });
200
+
201
+ const manyToManyMeta: {
202
+ joinTableName: string;
203
+ ownerColumnName: string;
204
+ relationColumnName: string;
205
+ } | null = QueryUtil.getManyToManyRelationMetadata(modelType, key);
206
+
207
+ if (manyToManyMeta && values.length > 0) {
208
+ const subqueryFilter: any = QueryHelper.allEntitiesInManyToMany({
209
+ values,
210
+ joinTableName: manyToManyMeta.joinTableName,
211
+ ownerColumnName: manyToManyMeta.ownerColumnName,
212
+ relationColumnName: manyToManyMeta.relationColumnName,
213
+ });
214
+
215
+ // Remove the relation-based filter so TypeORM does not create a
216
+ // JOIN that would yield OR semantics.
217
+ delete query[key];
218
+
219
+ const existingIdFilter: any = (query as any)._id;
220
+ if (existingIdFilter instanceof FindOperator) {
221
+ (query as any)._id = And(existingIdFilter, subqueryFilter);
222
+ } else if (
223
+ existingIdFilter &&
224
+ typeof existingIdFilter === Typeof.String
225
+ ) {
226
+ (query as any)._id = And(
227
+ QueryHelper.equalTo(existingIdFilter as string),
228
+ subqueryFilter,
229
+ );
230
+ } else {
231
+ (query as any)._id = subqueryFilter;
232
+ }
233
+ } else {
234
+ // Fall back to OR behavior when metadata cannot be resolved.
235
+ query[key] = values as any;
236
+ }
237
+ } else if (tableColumnMetadata.type === TableColumnType.Entity) {
238
+ // Entity (single) columns treat AND as a single match — same as OR.
239
+ query[key] = (query[key] as IncludesAll).values as any;
240
+ } else {
241
+ query[key] = QueryHelper.any(
242
+ (query[key] as IncludesAll).values,
243
+ ) as any;
244
+ }
245
+ } else if (
246
+ query[key] &&
247
+ query[key] instanceof IncludesNone &&
248
+ tableColumnMetadata
249
+ ) {
250
+ if (tableColumnMetadata.type === TableColumnType.EntityArray) {
251
+ const includesNone: IncludesNone = query[key] as IncludesNone;
252
+ const values: Array<string | ObjectID> = (
253
+ includesNone.values as Array<string | ObjectID | number>
254
+ ).map((item: string | ObjectID | number) => {
255
+ if (
256
+ item !== null &&
257
+ typeof item === Typeof.Object &&
258
+ !(item instanceof ObjectID)
259
+ ) {
260
+ const itemRecord: JSONObject = item as unknown as JSONObject;
261
+ if (itemRecord["_id"]) {
262
+ return itemRecord["_id"] as string;
263
+ }
264
+ }
265
+ return item.toString();
266
+ });
267
+
268
+ const manyToManyMeta: {
269
+ joinTableName: string;
270
+ ownerColumnName: string;
271
+ relationColumnName: string;
272
+ } | null = QueryUtil.getManyToManyRelationMetadata(modelType, key);
273
+
274
+ if (manyToManyMeta && values.length > 0) {
275
+ const subqueryFilter: any = QueryHelper.noneEntitiesInManyToMany({
276
+ values,
277
+ joinTableName: manyToManyMeta.joinTableName,
278
+ ownerColumnName: manyToManyMeta.ownerColumnName,
279
+ relationColumnName: manyToManyMeta.relationColumnName,
280
+ });
281
+
282
+ delete query[key];
283
+
284
+ const existingIdFilter: any = (query as any)._id;
285
+ if (existingIdFilter instanceof FindOperator) {
286
+ (query as any)._id = And(existingIdFilter, subqueryFilter);
287
+ } else if (
288
+ existingIdFilter &&
289
+ typeof existingIdFilter === Typeof.String
290
+ ) {
291
+ (query as any)._id = And(
292
+ QueryHelper.equalTo(existingIdFilter as string),
293
+ subqueryFilter,
294
+ );
295
+ } else {
296
+ (query as any)._id = subqueryFilter;
297
+ }
298
+ } else {
299
+ delete query[key];
300
+ }
301
+ } else if (tableColumnMetadata.type === TableColumnType.Entity) {
302
+ query[key] = QueryHelper.notIn(
303
+ (query[key] as IncludesNone).values as Array<string | ObjectID>,
304
+ ) as any;
305
+ } else {
306
+ query[key] = QueryHelper.notIn(
307
+ (query[key] as IncludesNone).values as Array<string | ObjectID>,
308
+ ) as any;
309
+ }
145
310
  } else if (
146
311
  query[key] &&
147
312
  query[key] instanceof Includes &&
@@ -237,4 +402,83 @@ export default class QueryUtil {
237
402
 
238
403
  return query;
239
404
  }
405
+
406
+ /**
407
+ * Resolves the join-table metadata for a many-to-many relation declared on
408
+ * the provided model. Returns null when the column is not a many-to-many
409
+ * relation, the database connection is not yet ready, or required metadata
410
+ * is missing.
411
+ */
412
+ public static getManyToManyRelationMetadata<TBaseModel extends BaseModel>(
413
+ modelType: { new (): TBaseModel },
414
+ propertyPath: string,
415
+ ): {
416
+ joinTableName: string;
417
+ ownerColumnName: string;
418
+ relationColumnName: string;
419
+ } | null {
420
+ if (!PostgresAppInstance.isConnected()) {
421
+ return null;
422
+ }
423
+
424
+ const dataSource: DataSource | null = PostgresAppInstance.getDataSource();
425
+
426
+ if (!dataSource) {
427
+ return null;
428
+ }
429
+
430
+ let entityMetadata: EntityMetadata | undefined;
431
+ try {
432
+ entityMetadata = dataSource.getMetadata(modelType);
433
+ } catch {
434
+ return null;
435
+ }
436
+
437
+ if (!entityMetadata) {
438
+ return null;
439
+ }
440
+
441
+ const relation: RelationMetadata | undefined =
442
+ entityMetadata.findRelationWithPropertyPath(propertyPath);
443
+
444
+ if (!relation || !relation.isManyToMany) {
445
+ return null;
446
+ }
447
+
448
+ // Only the owning side of a many-to-many has join/inverse columns. Follow
449
+ // the inverse relation when needed.
450
+ const owningRelation: RelationMetadata = relation.isOwning
451
+ ? relation
452
+ : (relation.inverseRelation ?? relation);
453
+
454
+ const joinTableName: string | undefined =
455
+ owningRelation.junctionEntityMetadata?.tableName;
456
+
457
+ if (!joinTableName) {
458
+ return null;
459
+ }
460
+
461
+ // When `modelType` is the owning side, its id lives on joinColumns. When
462
+ // it is the inverse side, its id lives on inverseJoinColumns.
463
+ const ownerColumns: Array<any> = relation.isOwning
464
+ ? owningRelation.joinColumns
465
+ : owningRelation.inverseJoinColumns;
466
+ const relationColumns: Array<any> = relation.isOwning
467
+ ? owningRelation.inverseJoinColumns
468
+ : owningRelation.joinColumns;
469
+
470
+ const ownerColumnName: string | undefined = ownerColumns[0]?.databaseName;
471
+ const relationColumnName: string | undefined =
472
+ relationColumns[0]?.databaseName;
473
+
474
+ if (!ownerColumnName || !relationColumnName) {
475
+ return null;
476
+ }
477
+
478
+ return {
479
+ joinTableName,
480
+ ownerColumnName,
481
+ relationColumnName,
482
+ };
483
+ }
240
484
  }
@@ -0,0 +1,41 @@
1
+ import BadDataException from "../Exception/BadDataException";
2
+ import { JSONObject, ObjectType } from "../JSON";
3
+ import QueryOperator from "./QueryOperator";
4
+
5
+ export default class EndsWith<T extends string> extends QueryOperator<T> {
6
+ private _value!: T;
7
+
8
+ public get value(): T {
9
+ return this._value;
10
+ }
11
+
12
+ public set value(v: T) {
13
+ this._value = v;
14
+ }
15
+
16
+ public constructor(value: T) {
17
+ super();
18
+ this.value = value;
19
+ }
20
+
21
+ public override toString(): T {
22
+ return this.value;
23
+ }
24
+
25
+ public override toJSON(): JSONObject {
26
+ return {
27
+ _type: ObjectType.EndsWith,
28
+ value: (this as EndsWith<T>).toString(),
29
+ };
30
+ }
31
+
32
+ public static override fromJSON<T extends string>(
33
+ json: JSONObject,
34
+ ): EndsWith<T> {
35
+ if (json["_type"] === ObjectType.EndsWith) {
36
+ return new EndsWith<T>((json["value"] as T) || ("" as T));
37
+ }
38
+
39
+ throw new BadDataException("Invalid JSON: " + JSON.stringify(json));
40
+ }
41
+ }
@@ -0,0 +1,45 @@
1
+ import BadDataException from "../Exception/BadDataException";
2
+ import { JSONObject, ObjectType } from "../JSON";
3
+ import JSONFunctions from "../JSONFunctions";
4
+ import ObjectID from "../ObjectID";
5
+ import QueryOperator from "./QueryOperator";
6
+
7
+ export type IncludesAllType = Array<string> | Array<ObjectID> | Array<number>;
8
+
9
+ export default class IncludesAll extends QueryOperator<IncludesAllType> {
10
+ private _values: IncludesAllType = [];
11
+
12
+ public get values(): IncludesAllType {
13
+ return this._values;
14
+ }
15
+
16
+ public set values(v: IncludesAllType) {
17
+ this._values = v;
18
+ }
19
+
20
+ public constructor(values: IncludesAllType) {
21
+ super();
22
+ this.values = values;
23
+ }
24
+
25
+ public override toJSON(): JSONObject {
26
+ return {
27
+ _type: ObjectType.IncludesAll,
28
+ value: (this as IncludesAll)._values,
29
+ };
30
+ }
31
+
32
+ public static override fromJSON(json: JSONObject): IncludesAll {
33
+ if (json["_type"] === ObjectType.IncludesAll) {
34
+ const valuesArray: Array<string> = [];
35
+
36
+ for (const value of (json["value"] as Array<string>) || []) {
37
+ valuesArray.push(JSONFunctions.deserializeValue(value) as string);
38
+ }
39
+
40
+ return new IncludesAll(valuesArray);
41
+ }
42
+
43
+ throw new BadDataException("Invalid JSON: " + JSON.stringify(json));
44
+ }
45
+ }
@@ -0,0 +1,48 @@
1
+ import BadDataException from "../Exception/BadDataException";
2
+ import { JSONObject, ObjectType } from "../JSON";
3
+ import JSONFunctions from "../JSONFunctions";
4
+ import ObjectID from "../ObjectID";
5
+ import QueryOperator from "./QueryOperator";
6
+
7
+ export type IncludesNoneType =
8
+ | Array<string>
9
+ | Array<ObjectID>
10
+ | Array<number>;
11
+
12
+ export default class IncludesNone extends QueryOperator<IncludesNoneType> {
13
+ private _values: IncludesNoneType = [];
14
+
15
+ public get values(): IncludesNoneType {
16
+ return this._values;
17
+ }
18
+
19
+ public set values(v: IncludesNoneType) {
20
+ this._values = v;
21
+ }
22
+
23
+ public constructor(values: IncludesNoneType) {
24
+ super();
25
+ this.values = values;
26
+ }
27
+
28
+ public override toJSON(): JSONObject {
29
+ return {
30
+ _type: ObjectType.IncludesNone,
31
+ value: (this as IncludesNone)._values,
32
+ };
33
+ }
34
+
35
+ public static override fromJSON(json: JSONObject): IncludesNone {
36
+ if (json["_type"] === ObjectType.IncludesNone) {
37
+ const valuesArray: Array<string> = [];
38
+
39
+ for (const value of (json["value"] as Array<string>) || []) {
40
+ valuesArray.push(JSONFunctions.deserializeValue(value) as string);
41
+ }
42
+
43
+ return new IncludesNone(valuesArray);
44
+ }
45
+
46
+ throw new BadDataException("Invalid JSON: " + JSON.stringify(json));
47
+ }
48
+ }
@@ -0,0 +1,41 @@
1
+ import BadDataException from "../Exception/BadDataException";
2
+ import { JSONObject, ObjectType } from "../JSON";
3
+ import QueryOperator from "./QueryOperator";
4
+
5
+ export default class NotContains<T extends string> extends QueryOperator<T> {
6
+ private _value!: T;
7
+
8
+ public get value(): T {
9
+ return this._value;
10
+ }
11
+
12
+ public set value(v: T) {
13
+ this._value = v;
14
+ }
15
+
16
+ public constructor(value: T) {
17
+ super();
18
+ this.value = value;
19
+ }
20
+
21
+ public override toString(): T {
22
+ return this.value;
23
+ }
24
+
25
+ public override toJSON(): JSONObject {
26
+ return {
27
+ _type: ObjectType.NotContains,
28
+ value: (this as NotContains<T>).toString(),
29
+ };
30
+ }
31
+
32
+ public static override fromJSON<T extends string>(
33
+ json: JSONObject,
34
+ ): NotContains<T> {
35
+ if (json["_type"] === ObjectType.NotContains) {
36
+ return new NotContains<T>((json["value"] as T) || ("" as T));
37
+ }
38
+
39
+ throw new BadDataException("Invalid JSON: " + JSON.stringify(json));
40
+ }
41
+ }
@@ -0,0 +1,41 @@
1
+ import BadDataException from "../Exception/BadDataException";
2
+ import { JSONObject, ObjectType } from "../JSON";
3
+ import QueryOperator from "./QueryOperator";
4
+
5
+ export default class StartsWith<T extends string> extends QueryOperator<T> {
6
+ private _value!: T;
7
+
8
+ public get value(): T {
9
+ return this._value;
10
+ }
11
+
12
+ public set value(v: T) {
13
+ this._value = v;
14
+ }
15
+
16
+ public constructor(value: T) {
17
+ super();
18
+ this.value = value;
19
+ }
20
+
21
+ public override toString(): T {
22
+ return this.value;
23
+ }
24
+
25
+ public override toJSON(): JSONObject {
26
+ return {
27
+ _type: ObjectType.StartsWith,
28
+ value: (this as StartsWith<T>).toString(),
29
+ };
30
+ }
31
+
32
+ public static override fromJSON<T extends string>(
33
+ json: JSONObject,
34
+ ): StartsWith<T> {
35
+ if (json["_type"] === ObjectType.StartsWith) {
36
+ return new StartsWith<T>((json["value"] as T) || ("" as T));
37
+ }
38
+
39
+ throw new BadDataException("Invalid JSON: " + JSON.stringify(json));
40
+ }
41
+ }
package/Types/JSON.ts CHANGED
@@ -7,6 +7,11 @@ import GreaterThan from "./BaseDatabase/GreaterThan";
7
7
  import GreaterThanOrEqual from "./BaseDatabase/GreaterThanOrEqual";
8
8
  import InBetween from "./BaseDatabase/InBetween";
9
9
  import Includes from "./BaseDatabase/Includes";
10
+ import IncludesAll from "./BaseDatabase/IncludesAll";
11
+ import IncludesNone from "./BaseDatabase/IncludesNone";
12
+ import StartsWith from "./BaseDatabase/StartsWith";
13
+ import EndsWith from "./BaseDatabase/EndsWith";
14
+ import NotContains from "./BaseDatabase/NotContains";
10
15
  import LessThan from "./BaseDatabase/LessThan";
11
16
  import LessThanOrEqual from "./BaseDatabase/LessThanOrEqual";
12
17
  import NotEqual from "./BaseDatabase/NotEqual";
@@ -71,6 +76,11 @@ export enum ObjectType {
71
76
  NotNull = "NotNull",
72
77
  IsNull = "IsNull",
73
78
  Includes = "Includes",
79
+ IncludesAll = "IncludesAll",
80
+ IncludesNone = "IncludesNone",
81
+ StartsWith = "StartsWith",
82
+ EndsWith = "EndsWith",
83
+ NotContains = "NotContains",
74
84
  DashboardComponent = "DashboardComponent",
75
85
  DashboardViewConfig = "DashboardViewConfig",
76
86
  }
@@ -157,6 +167,16 @@ export type JSONValue =
157
167
  | Array<StartAndEndTime>
158
168
  | Includes
159
169
  | Array<Includes>
170
+ | IncludesAll
171
+ | Array<IncludesAll>
172
+ | IncludesNone
173
+ | Array<IncludesNone>
174
+ | StartsWith<string>
175
+ | Array<StartsWith<string>>
176
+ | EndsWith<string>
177
+ | Array<EndsWith<string>>
178
+ | NotContains<string>
179
+ | Array<NotContains<string>>
160
180
  | DashboardViewConfig;
161
181
 
162
182
  export interface JSONObject {
@@ -7,6 +7,11 @@ import GreaterThan from "./BaseDatabase/GreaterThan";
7
7
  import GreaterThanOrEqual from "./BaseDatabase/GreaterThanOrEqual";
8
8
  import InBetween from "./BaseDatabase/InBetween";
9
9
  import Includes from "./BaseDatabase/Includes";
10
+ import IncludesAll from "./BaseDatabase/IncludesAll";
11
+ import IncludesNone from "./BaseDatabase/IncludesNone";
12
+ import StartsWith from "./BaseDatabase/StartsWith";
13
+ import EndsWith from "./BaseDatabase/EndsWith";
14
+ import NotContains from "./BaseDatabase/NotContains";
10
15
  import IsNull from "./BaseDatabase/IsNull";
11
16
  import LessThan from "./BaseDatabase/LessThan";
12
17
  import LessThanOrEqual from "./BaseDatabase/LessThanOrEqual";
@@ -65,6 +70,11 @@ const SerializableObjectDictionary: Dictionary<any> = {
65
70
  [ObjectType.HashedString]: HashedString,
66
71
  [ObjectType.InBetween]: InBetween,
67
72
  [ObjectType.Includes]: Includes,
73
+ [ObjectType.IncludesAll]: IncludesAll,
74
+ [ObjectType.IncludesNone]: IncludesNone,
75
+ [ObjectType.StartsWith]: StartsWith,
76
+ [ObjectType.EndsWith]: EndsWith,
77
+ [ObjectType.NotContains]: NotContains,
68
78
  [ObjectType.NotNull]: NotNull,
69
79
  [ObjectType.IsNull]: IsNull,
70
80
  [ObjectType.Recurring]: Recurring,
@@ -50,6 +50,7 @@ const BooleanFilter: BooleanFilterFunction = <T extends GenericObject>(
50
50
  }
51
51
  }}
52
52
  placeholder={`Filter by ${filter.title}`}
53
+ className="relative rounded-md w-full overflow-visible"
53
54
  />
54
55
  );
55
56
  }