From 5b2e2113bee576c064c052f6580c83c4c67ef184 Mon Sep 17 00:00:00 2001 From: Martin Zanoni Date: Thu, 27 Jun 2024 10:40:54 +0200 Subject: [PATCH] feat: Add HasValue and RelativeDateTimeCondition --- .../client/src/builders/conditionBuilder.ts | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/packages/client/src/builders/conditionBuilder.ts b/packages/client/src/builders/conditionBuilder.ts index ba28209..7aa30b9 100644 --- a/packages/client/src/builders/conditionBuilder.ts +++ b/packages/client/src/builders/conditionBuilder.ts @@ -1,6 +1,6 @@ -import { ContainsCondition, DistinctCondition, EqualsCondition, GreaterThanCondition, LessThanCondition, ValueConditionCollection, DataValueBase, DataObjectFilter, DataObjectFilterConditionBuilder } from '..'; +import { ContainsCondition, DistinctCondition, EqualsCondition, GreaterThanCondition, LessThanCondition, ValueConditionCollection, DataValueBase, DataObjectFilterConditionBuilder, HasValueCondition, RelativeDateTimeCondition } from '..'; -export type Conditions = ContainsCondition | DistinctCondition | EqualsCondition | GreaterThanCondition | LessThanCondition; +export type Conditions = ContainsCondition | DistinctCondition | EqualsCondition | GreaterThanCondition | LessThanCondition | HasValueCondition | RelativeDateTimeCondition; export class ConditionBuilder { conditions: Conditions[] = []; @@ -67,9 +67,9 @@ export class ConditionBuilder { const condition: ContainsCondition = { $type: 'Relewise.Client.Requests.Conditions.ContainsCondition, Relewise.Client', - objectFilter: { - conditions: conditionsBuilder.build(), - skip: skip, + objectFilter: { + conditions: conditionsBuilder.build(), + skip: skip, take: take, }, valueCollectionEvaluationMode: 'All', @@ -80,6 +80,29 @@ export class ConditionBuilder { return this; } + public addHasValueCondition(negated: boolean = false) { + const condition: HasValueCondition = { + $type: 'Relewise.Client.Requests.Conditions.HasValueCondition, Relewise.Client', + negated: negated, + }; + this.conditions.push(condition); + + return this; + } + + public addRelativeDateTimeCondition(comparison: 'Before' | 'After', unit: 'UnixMilliseconds' | 'UnixSeconds' | 'UnixMinutes', currentTimeOffset: number = 0, negated: boolean = false) { + const condition: RelativeDateTimeCondition = { + $type: 'Relewise.Client.Requests.Conditions.RelativeDateTimeCondition, Relewise.Client', + comparison: comparison, + currentTimeOffset: currentTimeOffset, + unit: unit, + negated: negated, + }; + this.conditions.push(condition); + + return this; + } + public build(): ValueConditionCollection | null { return this.conditions.length === 0 ? null