@grouparoo/core
Version:
The Grouparoo Core
104 lines (103 loc) • 4.44 kB
TypeScript
import Sequelize from "sequelize";
import { GroupConfigurationObject } from "../classes/codeConfig";
import { GroupRuleOpType, RelativeMatchDirectionType, RelativeMatchUnitType } from "../modules/ruleOpsDictionary";
import { Destination } from "./Destination";
import { GroupMember } from "./GroupMember";
import { GrouparooRecord } from "./GrouparooRecord";
import { GroupRule } from "./GroupRule";
import { Property } from "./Property";
import { Run } from "./Run";
import { GrouparooModel } from "./GrouparooModel";
import { CommonModel } from "../classes/commonModel";
export declare const GROUP_RULE_LIMIT = 10;
export interface GroupRuleOperation {
op: GroupRuleOpType;
description?: string;
}
export interface GroupRuleWithKey {
key?: string;
type?: Property["type"];
topLevel?: boolean;
operation: GroupRuleOperation;
match?: string | number | boolean;
relativeMatchNumber?: number;
relativeMatchUnit?: RelativeMatchUnitType;
relativeMatchDirection?: RelativeMatchDirectionType;
}
declare const matchTypes: readonly ["any", "all"];
declare const STATES: readonly ["draft", "ready", "initializing", "updating", "deleted"];
export declare class Group extends CommonModel<Group> {
idPrefix(): string;
name: string;
matchType: typeof matchTypes[number];
state: typeof STATES[number];
locked: string;
calculatedAt: Date;
modelId: string;
groupMembers: GroupMember[];
groupRules: GroupRule[];
destinations: Destination[];
records: GrouparooRecord[];
model: GrouparooModel;
recordsCount(options?: {}): Promise<number>;
getRules(): Promise<GroupRuleWithKey[]>;
setRules(rules: GroupRuleWithKey[]): Promise<Run>;
apiData(): Promise<{
id: string;
name: string;
modelId: string;
modelName: string;
rules: GroupRuleWithKey[];
matchType: "all" | "any";
state: "ready" | "draft" | "deleted" | "initializing" | "updating";
locked: string;
recordsCount: number;
createdAt: number;
updatedAt: number;
nextCalculatedAt: number;
calculatedAt: number;
}>;
fromConvenientRules(rules: GroupRuleWithKey[]): GroupRuleWithKey[];
toConvenientRules(rules: GroupRuleWithKey[]): GroupRuleWithKey[];
nextCalculatedAt(): Promise<Date>;
run(destinationId?: string): Promise<Run>;
stopPreviousRuns(): Promise<void>;
runAddGroupMembers(run: Run, limit?: number, offset?: number, highWaterMark?: number, destinationId?: string): Promise<{
groupMembersCount: number;
nextHighWaterMark: number;
nextOffset: number;
}>;
runRemoveGroupMembers(run: Run, limit?: number, destinationId?: string): Promise<number>;
removePreviousRunGroupMembers(run: Run, limit?: number): Promise<number>;
updateRecordsMembership(records: GrouparooRecord[]): Promise<{
[recordId: string]: boolean;
}>;
countPotentialMembers(rules?: GroupRuleWithKey[], matchType?: typeof matchTypes[number]): Promise<number>;
/**
* Take the rules for the group and check how many group members there would have been both individually for each single rule, and then by building up the query step-by-step
*/
countComponentMembersFromRules(rules?: GroupRuleWithKey[]): Promise<{
componentCounts: number[];
funnelCounts: number[];
}>;
/**
* Build the where-clause for the query to determine Group membership
*/
_buildGroupMemberQueryParts(rules?: GroupRuleWithKey[], matchType?: typeof matchTypes[number], recordState?: string): Promise<{
where: Sequelize.WhereAttributeHash<any>;
include: Sequelize.Includeable[];
}>;
getConfigId(): string;
getConfigObject(): Promise<GroupConfigurationObject>;
static ensureModel(instance: Group): Promise<void>;
static updateState(instance: Group): Promise<void>;
static noUpdateIfLocked(instance: Group): Promise<void>;
static checkGroupMembers(instance: Group): Promise<void>;
static ensureNotInUse(instance: Group): Promise<void>;
static noDestroyIfLocked(instance: Group): Promise<void>;
static destroyDestinationGroupTracking(instance: Group): Promise<void>;
static destroyDestinationGroupMembership(instance: Group): Promise<void>;
static destroyGroupRules(instance: Group): Promise<number>;
static stopRuns(instance: Group): Promise<void>;
}
export {};