@grouparoo/core
Version:
The Grouparoo Core
191 lines (190 loc) • 6.43 kB
TypeScript
import { GroupRuleOpType, RelativeMatchUnitType, RelativeMatchDirectionType } from "../modules/ruleOpsDictionary";
import { DestinationCollection, DestinationSyncMode } from "../models/Destination";
import { PropertyFiltersWithKey } from "../models/Property";
import { GroupRuleWithKey } from "../models/Group";
import { CommonModel } from "./commonModel";
export interface IdsByClass {
model?: string[];
app?: string[];
source?: string[];
property?: string[];
group?: string[];
schedule?: string[];
destination?: string[];
apikey?: string[];
team?: string[];
teammember?: string[];
record?: string[];
}
interface ConfigurationObject {
id?: string;
class?: string;
}
export interface ApiKeyConfigurationObject extends ConfigurationObject {
name: string;
type?: string;
apiKey?: string;
permissions?: {
topic: string;
read: boolean;
write: boolean;
}[];
options?: {
permissionAllRead: boolean;
permissionAllWrite: boolean;
};
}
export interface ModelConfigurationObject extends ConfigurationObject {
name: string;
type: string;
}
export interface AppConfigurationObject extends ConfigurationObject {
name: string;
type: string;
refresh?: {
query: string;
recurringFrequency: number;
};
options?: {
[key: string]: any;
};
}
export interface DestinationConfigurationObject extends ConfigurationObject {
name: string;
type: string;
appId: string;
modelId: string;
syncMode: DestinationSyncMode;
collection: DestinationCollection;
groupId?: string;
options?: {
[key: string]: any;
};
mapping?: {
[key: string]: any;
};
destinationGroupMemberships?: {
[key: string]: string;
};
}
export interface GroupRuleConfigurationObject {
key?: string;
propertyId?: string;
type?: GroupRuleWithKey["type"];
op: GroupRuleOpType;
match?: string | number | boolean;
relativeMatchNumber?: number;
relativeMatchUnit?: RelativeMatchUnitType;
relativeMatchDirection?: RelativeMatchDirectionType;
}
export interface GroupConfigurationObject extends ConfigurationObject {
name: string;
modelId: string;
rules?: GroupRuleConfigurationObject[];
}
export interface RecordConfigurationObject extends ConfigurationObject {
modelId: string;
properties?: {
[key: string]: (string | boolean | number | Date)[];
};
}
export interface PropertyConfigurationObject extends ConfigurationObject {
key: string;
type: string;
sourceId: string;
unique?: boolean;
isArray?: boolean;
options?: {
[key: string]: any;
};
filters?: PropertyFiltersWithKey[];
}
export interface ScheduleConfigurationObject extends ConfigurationObject {
name: string;
sourceId: string;
recurring?: boolean;
incremental?: boolean;
recurringFrequency?: number;
confirmRecords?: boolean;
options?: {
[key: string]: any;
};
filters?: PropertyFiltersWithKey[];
refreshEnabled?: boolean;
}
export interface SettingConfigurationObject extends ConfigurationObject {
pluginName: string;
key: string;
value: string | boolean | number;
}
export interface SourceConfigurationObject extends ConfigurationObject {
appId: string;
name: string;
modelId: string;
type: string;
options?: {
[key: string]: any;
};
mapping?: {
[key: string]: any;
};
}
export interface TeamConfigurationObject extends ConfigurationObject {
name: string;
permissions?: {
topic: string;
read: boolean;
write: boolean;
}[];
options?: {
permissionAllRead: boolean;
permissionAllWrite: boolean;
};
}
export interface TeamMemberConfigurationObject extends ConfigurationObject {
teamId: string;
email: string;
options?: {
firstName?: string;
lastName?: string;
password?: string;
};
}
export declare type AnyConfigurationObject = ModelConfigurationObject | ApiKeyConfigurationObject | AppConfigurationObject | DestinationConfigurationObject | GroupConfigurationObject | RecordConfigurationObject | PropertyConfigurationObject | ScheduleConfigurationObject | SettingConfigurationObject | SourceConfigurationObject | TeamConfigurationObject | TeamMemberConfigurationObject;
interface ConfigObjectWithReferenceIDs {
configObject: AnyConfigurationObject;
providedIds: string[];
prerequisiteIds: string[];
}
export declare function getCodeConfigLockKey(): string;
export declare function getParentByName(model: any, parentId: string): Promise<any>;
export declare function validateConfigObjectKeys(model: any, configObject: AnyConfigurationObject, additionalAllowedKeys?: string[]): void;
/**
* Log a Sequelize Model
*/
export declare function logModel<T>(instance: CommonModel<T> & {
key?: string;
email?: string;
name?: string;
}, mode: "created" | "updated" | "deleted" | "validated", name?: string): void;
export declare function extractNonNullParts<T, Key extends keyof T>(configObject: T, key: Key): T[Key];
export declare function getAutoBootstrappedProperty(sourceConfigObject: SourceConfigurationObject, otherConfigObjects: AnyConfigurationObject[]): PropertyConfigurationObject;
export declare function sortConfigurationObjects(configObjects: AnyConfigurationObject[]): Promise<AnyConfigurationObject[]>;
/**
* Check a set of config objects for duplicate IDs within the same type.
*
* @param configObjects ConfigurationObject[]
*/
export declare function validateConfigObjects(configObjects: AnyConfigurationObject[]): {
configObjects: AnyConfigurationObject[];
errors: string[];
};
export declare function getConfigObjectsWithIds(configObjects: AnyConfigurationObject[]): Promise<ConfigObjectWithReferenceIDs[]>;
export declare function getDirectParentId(configObject: ConfigurationObject): Promise<string>;
export declare function getParentIds(configObject: AnyConfigurationObject, otherConfigObjects?: AnyConfigurationObject[]): Promise<{
prerequisiteIds: string[];
providedIds: string[];
}>;
export declare function sortConfigObjectsWithIds(configObjectsWithIds: ConfigObjectWithReferenceIDs[]): ConfigObjectWithReferenceIDs[];
export declare function cleanClass(configObject: ConfigurationObject): string;
export {};