UNPKG

@grouparoo/core

Version:
122 lines (121 loc) 4.92 kB
import { GrouparooPlugin } from "../classes/plugin"; import { APMWrap } from "./apm"; import { Import } from "../models/Import"; import { GrouparooRecord } from "../models/GrouparooRecord"; import { Run } from "../models/Run"; import { Setting, settingTypes } from "../models/Setting"; export declare namespace plugin { /** * This is needed when running in dev mode (TS) but you are using a compiled plugin (JS). * The plugin will actually load the JS model while core will be loading the TS model. * Both need to be "added" to sequelize to know which connection to use. */ function mountModels(): void; /** * Register a Grouparoo Plugin */ function registerPlugin(plugin: GrouparooPlugin, validate?: boolean): void; /** * Register a setting for your Grouparoo plugin */ function registerSetting(pluginName: string, key: string, title: string, defaultValue: any, description: string, type: typeof settingTypes[number], variant?: string): Promise<Setting>; /** * Read a setting for this plugin */ function readSetting(pluginName: string, key: string): Promise<Setting>; /** * Update a setting for this plugin */ function updateSetting(pluginName: string, key: string, value: any): Promise<Setting>; /** * When your plugin has a record for a record, send it to this method. We will use the provided mapping against your raw data row to store the original data and mapped data to the record. * mapping: an object whose keys are remote columns and whose values are the property keys, ie: {remoteColumnId: 'userId'} * row: {email: 'abc@company.com', vip: true} */ function createImport(mapping: { [remoteKey: string]: string; }, run: Run, row: { [remoteKey: string]: any; }): Promise<Import>; /** * Like plugin.createImport, but for many imports at once! * * mapping: an object whose keys are remote columns and whose values are the property keys, ie: {remoteColumnId: 'userId'} * rows: {email: 'abc@company.com', vip: true}[] */ function createImports(mapping: { [remoteKey: string]: string; }, run: Run, rows: { [remoteKey: string]: any; }[]): Promise<Import[]>; /** * data helpers */ function expandDates(raw: Date): { raw: Date; iso: string; sql: string; date: string; time: string; }; /** * Takes a string with mustache variables and replaces them with the proper values for a schedule and run */ function replaceTemplateRunVariables(string: string, run?: Run): Promise<string>; /** * Takes a record and returns data with the values from the properties and current time. */ function getRecordData(record: GrouparooRecord): Promise<{ now: { raw: Date; iso: string; sql: string; date: string; time: string; }; createdAt: { raw: Date; iso: string; sql: string; date: string; time: string; }; updatedAt: { raw: Date; iso: string; sql: string; date: string; time: string; }; } & Record<string, string | number | boolean | { raw: Date; iso: string; sql: string; date: string; time: string; }>>; /** * Takes a string with mustache variables and replaces them with the proper values for a record */ function replaceTemplateRecordVariables(string: string, record: GrouparooRecord, strict?: boolean): Promise<string>; /** * Takes a string with mustache variable (keys) and replaces them with the record property ids * ie: `select * where id = {{{ userId }}}` => `select * where id = {{{ ppr_abc123 }}}` */ function replaceTemplateRecordPropertyKeysWithRecordPropertyId(string: string, modelId: string): Promise<string>; /** * Takes a string with mustache variable (ids) and replaces them with the record property keys * ie: `select * where id = {{{ ppr_abc123 }}}` => `select * where id = {{{ userId }}}` */ function replaceTemplateRecordPropertyIdsWithRecordPropertyKeys(string: string, modelId: string): Promise<string>; function setApmWrap(f: APMWrap): void; /** * Returns the access token for an OAuth-based plugin app that uses refresh tokens. * Manages cache and expiration of the token. * In order to use this, app OAuth access must first be setup by the Grouparoo team. * * @param providerName the name of the provider (e.g. hubspot) * @param refreshToken the refresh token stored by the app options * @returns the access token */ function getOAuthAppAccessToken(providerName: string, refreshToken: string): Promise<string>; }