// Package: com.lightningkite.lightningdb // Generated by Khrysalis - this file will be overwritten. import { ReifiedType, TProperty1, reflectiveGet, safeCompare, safeEq, setUpDataClass, tryCastClass } from '@lightningkite/khrysalis-runtime' import { every, some } from 'iter-tools-es' //! Declares com.lightningkite.lightningdb.Condition export class Condition { protected constructor() { } public hashCode(): number { throw undefined; } public equals(other: (any | null)): boolean { throw undefined; } public invoke(on: T): boolean { throw undefined; } public and(other: Condition): Condition.And { return new Condition.And([this, other]); } public or(other: Condition): Condition.Or { return new Condition.Or([this, other]); } public not(): Condition.Not { return new Condition.Not(this); } } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.Never export class Never extends Condition { public constructor() { super(); } public invoke(on: T): boolean { return false; } public hashCode(): number { return 0; } public equals(other: (any | null)): boolean { return (tryCastClass>(other, Condition.Never)) !== null; } } } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.Always export class Always extends Condition { public constructor() { super(); } public invoke(on: T): boolean { return true; } public hashCode(): number { return 1; } public equals(other: (any | null)): boolean { return (tryCastClass>(other, Condition.Always)) !== null; } } } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.And export class And extends Condition { public constructor(public readonly conditions: Array>) { super(); } public static properties = ["conditions"] public static propertyTypes(T: ReifiedType) { return {conditions: [Array, [Condition, T]]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: T): boolean { return this.conditions.every((it: Condition): boolean => (it.invoke(on))); } } setUpDataClass(And) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.Or export class Or extends Condition { public constructor(public readonly conditions: Array>) { super(); } public static properties = ["conditions"] public static propertyTypes(T: ReifiedType) { return {conditions: [Array, [Condition, T]]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: T): boolean { return this.conditions.some((it: Condition): boolean => (it.invoke(on))); } } setUpDataClass(Or) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.Not export class Not extends Condition { public constructor(public readonly condition: Condition) { super(); } public static properties = ["condition"] public static propertyTypes(T: ReifiedType) { return {condition: [Condition, T]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: T): boolean { return (!this.condition.invoke(on)); } } setUpDataClass(Not) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.Equal export class Equal extends Condition { public constructor(public readonly value: T) { super(); } public static properties = ["value"] public static propertyTypes(T: ReifiedType) { return {value: T} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: T): boolean { return safeEq(on, this.value); } } setUpDataClass(Equal) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.NotEqual export class NotEqual extends Condition { public constructor(public readonly value: T) { super(); } public static properties = ["value"] public static propertyTypes(T: ReifiedType) { return {value: T} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: T): boolean { return !safeEq(on, this.value); } } setUpDataClass(NotEqual) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.Inside export class Inside extends Condition { public constructor(public readonly values: Array) { super(); } public static properties = ["values"] public static propertyTypes(T: ReifiedType) { return {values: [Array, T]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: T): boolean { return this.values.some((x) => safeEq(on, x)); } } setUpDataClass(Inside) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.NotInside export class NotInside extends Condition { public constructor(public readonly values: Array) { super(); } public static properties = ["values"] public static propertyTypes(T: ReifiedType) { return {values: [Array, T]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: T): boolean { return (!this.values.some((x) => safeEq(on, x))); } } setUpDataClass(NotInside) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.GreaterThan export class GreaterThan extends Condition { public constructor(public readonly value: T) { super(); } public static properties = ["value"] public static propertyTypes(T: ReifiedType) { return {value: T} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: T): boolean { return safeCompare(on, this.value) > 0; } } setUpDataClass(GreaterThan) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.LessThan export class LessThan extends Condition { public constructor(public readonly value: T) { super(); } public static properties = ["value"] public static propertyTypes(T: ReifiedType) { return {value: T} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: T): boolean { return safeCompare(on, this.value) < 0; } } setUpDataClass(LessThan) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.GreaterThanOrEqual export class GreaterThanOrEqual extends Condition { public constructor(public readonly value: T) { super(); } public static properties = ["value"] public static propertyTypes(T: ReifiedType) { return {value: T} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: T): boolean { return safeCompare(on, this.value) >= 0; } } setUpDataClass(GreaterThanOrEqual) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.LessThanOrEqual export class LessThanOrEqual extends Condition { public constructor(public readonly value: T) { super(); } public static properties = ["value"] public static propertyTypes(T: ReifiedType) { return {value: T} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: T): boolean { return safeCompare(on, this.value) <= 0; } } setUpDataClass(LessThanOrEqual) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.StringContains export class StringContains extends Condition { public constructor(public readonly value: string, public readonly ignoreCase: boolean = false) { super(); } public static properties = ["value", "ignoreCase"] public static propertyTypes() { return {value: [String], ignoreCase: [Boolean]} } copy: (values: Partial) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: string): boolean { return (on.toLowerCase().indexOf(this.value.toLowerCase()) != -1); } } setUpDataClass(StringContains) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.FullTextSearch export class FullTextSearch extends Condition { public constructor(public readonly value: string, public readonly ignoreCase: boolean = false) { super(); } public static properties = ["value", "ignoreCase"] public static propertyTypes(T: ReifiedType) { return {value: [String], ignoreCase: [Boolean]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: T): boolean { throw "Not Implemented locally"; } } setUpDataClass(FullTextSearch) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.RegexMatches export class RegexMatches extends Condition { public constructor(public readonly pattern: string, public readonly ignoreCase: boolean = false) { super(); this.regex = new RegExp(this.pattern); } public static properties = ["pattern", "ignoreCase"] public static propertyTypes() { return {pattern: [String], ignoreCase: [Boolean]} } copy: (values: Partial) => this; equals: (other: any) => boolean; hashCode: () => number; public readonly regex: RegExp; public invoke(on: string): boolean { return this.regex.test(on); } } setUpDataClass(RegexMatches) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.IntBitsClear export class IntBitsClear extends Condition { public constructor(public readonly mask: number) { super(); } public static properties = ["mask"] public static propertyTypes() { return {mask: [Number]} } copy: (values: Partial) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: number): boolean { return (on & this.mask) === 0; } } setUpDataClass(IntBitsClear) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.IntBitsSet export class IntBitsSet extends Condition { public constructor(public readonly mask: number) { super(); } public static properties = ["mask"] public static propertyTypes() { return {mask: [Number]} } copy: (values: Partial) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: number): boolean { return (on & this.mask) === this.mask; } } setUpDataClass(IntBitsSet) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.IntBitsAnyClear export class IntBitsAnyClear extends Condition { public constructor(public readonly mask: number) { super(); } public static properties = ["mask"] public static propertyTypes() { return {mask: [Number]} } copy: (values: Partial) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: number): boolean { return (on & this.mask) < this.mask; } } setUpDataClass(IntBitsAnyClear) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.IntBitsAnySet export class IntBitsAnySet extends Condition { public constructor(public readonly mask: number) { super(); } public static properties = ["mask"] public static propertyTypes() { return {mask: [Number]} } copy: (values: Partial) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: number): boolean { return (on & this.mask) > 0; } } setUpDataClass(IntBitsAnySet) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.ListAllElements export class ListAllElements extends Condition> { public constructor(public readonly condition: Condition) { super(); } public static properties = ["condition"] public static propertyTypes(E: ReifiedType) { return {condition: [Condition, E]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: Array): boolean { return on.every((it: E): boolean => (this.condition.invoke(it))); } } setUpDataClass(ListAllElements) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.ListAnyElements export class ListAnyElements extends Condition> { public constructor(public readonly condition: Condition) { super(); } public static properties = ["condition"] public static propertyTypes(E: ReifiedType) { return {condition: [Condition, E]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: Array): boolean { return on.some((it: E): boolean => (this.condition.invoke(it))); } } setUpDataClass(ListAnyElements) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.ListSizesEquals export class ListSizesEquals extends Condition> { public constructor(public readonly count: number) { super(); } public static properties = ["count"] public static propertyTypes(E: ReifiedType) { return {count: [Number]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: Array): boolean { return on.length === this.count; } } setUpDataClass(ListSizesEquals) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.SetAllElements export class SetAllElements extends Condition> { public constructor(public readonly condition: Condition) { super(); } public static properties = ["condition"] public static propertyTypes(E: ReifiedType) { return {condition: [Condition, E]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: Set): boolean { return every((it: E): boolean => (this.condition.invoke(it)), on); } } setUpDataClass(SetAllElements) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.SetAnyElements export class SetAnyElements extends Condition> { public constructor(public readonly condition: Condition) { super(); } public static properties = ["condition"] public static propertyTypes(E: ReifiedType) { return {condition: [Condition, E]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: Set): boolean { return some((it: E): boolean => (this.condition.invoke(it)), on); } } setUpDataClass(SetAnyElements) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.SetSizesEquals export class SetSizesEquals extends Condition> { public constructor(public readonly count: number) { super(); } public static properties = ["count"] public static propertyTypes(E: ReifiedType) { return {count: [Number]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: Set): boolean { return on.size === this.count; } } setUpDataClass(SetSizesEquals) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.Exists export class Exists extends Condition> { public constructor(public readonly key: string) { super(); } public static properties = ["key"] public static propertyTypes(V: ReifiedType) { return {key: [String]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: Map): boolean { return on.has(this.key); } } setUpDataClass(Exists) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.OnKey export class OnKey extends Condition> { public constructor(public readonly key: string, public readonly condition: Condition) { super(); } public static properties = ["key", "condition"] public static propertyTypes(V: ReifiedType) { return {key: [String], condition: [Condition, V]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: Map): boolean { return on.has(this.key) && this.condition.invoke((on.get(this.key) ?? null) as V); } } setUpDataClass(OnKey) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.OnField export class OnField extends Condition { public constructor(public readonly key: TProperty1, public readonly condition: Condition) { super(); } public static properties = ["key", "condition"] public static propertyTypes(K: ReifiedType, V: ReifiedType) { return {key: [String, K, V], condition: [Condition, V]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: K): boolean { return this.condition.invoke(reflectiveGet(on, this.key)); } } setUpDataClass(OnField) } export namespace Condition { //! Declares com.lightningkite.lightningdb.Condition.IfNotNull export class IfNotNull extends Condition<(T | null)> { public constructor(public readonly condition: Condition) { super(); } public static properties = ["condition"] public static propertyTypes(T: ReifiedType) { return {condition: [Condition, T]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public invoke(on: (T | null)): boolean { return on !== null && this.condition.invoke(on!); } } setUpDataClass(IfNotNull) }