export function setMockConnection(mock: any): void; /** * Executes an operation. * @function * @private * @param {Operation} operations - Operations * @returns {State} */ export function execute(...operations: Operation): State; /** * Create one or more new sObject records. Relationships in the record should be nested and not use dot-notation syntax * @public * @example Single record creation * create("Account", { Name: "My Account #1" }); * @example Multiple records creation * create("Account",[{ Name: "My Account #1" }, { Name: "My Account #2" }]); * @example Create records from data on state * create("Account", * $.data.map((account) => ({ * Name: account.label * }) * )); * @example Update a record with a relationship * create("Account", { * Name: "My Account #1" , * "Project__r": { * "Metrics_ID__c": "jfh5LAnxu1i4na" * } * }); * @function * @param {string} sObjectName - API name of the sObject. * @param {(Object|Object[])} records - Field attributes for the new record, or an array of field attributes. * @state {SalesforceResultState} * @returns {Operation} */ export function create(sObjectName: string, records: (any | any[])): Operation; /** * Fetches and logs metadata for an sObject and pushes the result to `state.data`. * If `sObjectName` is not specified, it will print the total number of all available sObjects and push the result to `state.data`. * @public * @example Fetch metadata for all available sObjects * describe() * @example Fetch metadata for Account sObject * describe('Account') * @function * @param {string} sObjectName - The API name of the sObject. If omitted, fetches metadata for all sObjects. * @state {SalesforceState} * @returns {Operation} */ export function describe(sObjectName: string): Operation; /** * Delete records of an sObject. * @public * @example Delete a single record * destroy("Account", "001XXXXXXXXXXXXXXX"); * @example Allow operation to fail if any record fails to delete * destroy("Account", ["001XXXXXXXXXXXXXXX", "001YYYYYYYYYYYYYYY"], { * failOnError: true, * }); * @example Using a state variable * fn((state) => { * state.data = ["001XXXXXXXXXXXXXXX", "001YYYYYYYYYYYYYYY"]; * return state; * }); * destroy("Account", $.data); * @function * @param {string} sObjectName - API name of the sObject. * @param {string|string[]} ids - ID or array of IDs of records to delete * @param {object} [options] - Options for the destroy delete operation. * @param {boolean} [options.failOnError=false] - If true, the operation will fail if any record fails to delete. * @state {SalesforceResultState} * @returns {Operation} */ export function destroy(sObjectName: string, ids: string | string[], options?: { failOnError?: boolean; }): Operation; /** * Alias for "create(sObjectName, records)". * @public * @example Single record creation * insert("Account", { Name: "My Account #1" }); * @example Multiple records creation * insert("Account",[{ Name: "My Account #1" }, { Name: "My Account #2" }]); * @example Using a state variable * fn((state) => { * state.data = [{ Name: "My Account #1" }, { Name: "My Account #2" }]; * return state; * }); * insert("Account", $.data); * @function * @param {string} sObjectName - API name of the sObject. * @param {(Object|Object[])} records - Field attributes for the new record, or an array of field attributes. * @state {SalesforceState} * @returns {Operation} */ export function insert(sObjectName: string, records: (any | any[])): Operation; /** * Executes an SOQL (Salesforce Object Query Language) query to retrieve records from Salesforce. * Note that in an event of a query error, error logs will be printed but the operation will not throw the error. * * The Salesforce query API is subject to rate limits, {@link https://sforce.co/3W9zyaQ learn more here}. * @public * @example Run a query and download all matching records * query('SELECT Id FROM Patient__c', { limit: Infinity }); * @example Run a query and limit records * query('SELECT Id From Account Limit 10'); * @example Query patients by Health ID * query(state => `SELECT Id FROM Patient__c WHERE Health_ID__c = '${state.data.healthId}'`); * @example Query patients by Health ID using a lazy state reference * query(`SELECT Id FROM Patient__c WHERE Health_ID__c = '${$.data.healthId}'`); * @function * @param {string} query - A SOQL query string. Must be less than 4000 characters in WHERE clause * @param {object} [options] - Query options * @param {number} [options.limit=10000] - Maximum number of records to fetch. If `limit: Infinity` is passed, all records will be fetched. * @state {SalesforceState} * @state {Array} data - Array of result objects * @state {Object} response - An object of result metadata. * { done, totalSize, nextRecordsUrl?: string } * where nextRecordsUrl is only present when done is false * @returns {Operation} */ export function query(query: string, options?: { limit?: number; }): Operation; /** * Create a new sObject record, or updates it if it already exists. Relationships in the record should be nested and not use dot-notation syntax * @public * @example Single record upsert * upsert("UpsertTable__c", "ExtId__c", { Name: "Record #1", ExtId__c : 'ID-0000001' }); * @example Multiple record upsert * upsert("UpsertTable__c", "ExtId__c", [ * { Name: "Record #1", ExtId__c : 'ID-0000001' }, * { Name: "Record #2", ExtId__c : 'ID-0000002' }, * ]); * @example Update a record with a relationship * upsert("UpsertTable__c", { * Name: "Record #1", * "Project__r": { * "Metrics_ID__c": "jfh5LAnxu1i4na" * } * }); * @function * @param {string} sObjectName - API name of the sObject. * @magic sObjectName - $.children[?(!@.meta.system)].name * @param {string} externalId - The external ID of the sObject. * @magic externalId - $.children[?(@.name=="{{args.sObject}}")].children[?(@.meta.externalId)].name * @param {(Object|Object[])} records - Field attributes for the records to upsert, or an array of field attributes. * @magic records - $.children[?(@.name=="{{args.sObject}}")].children[?(!@.meta.externalId)] * @state {SalesforceState} * @returns {Operation} */ export function upsert(sObjectName: string, externalId: string, records: (any | any[])): Operation; /** * Update an sObject record or records. Relationships in the record should be nested and not use dot-notation syntax * @public * @function * @example Single record update * update("Account", { * Id: "0010500000fxbcuAAA", * Name: "Updated Account #1", * }); * @example Multiple records update * update("Account", [ * { Id: "0010500000fxbcuAAA", Name: "Updated Account #1" }, * { Id: "0010500000fxbcvAAA", Name: "Updated Account #2" }, * ]); * @example Update a record with a relationship * update("Account", { * Id: "0010500000fxbcuAAA", * "Project__r": { * "Metrics_ID__c": "jfh5LAnxu1i4na" * } * }); * @param {string} sObjectName - API name of the sObject. * @param {(object|object[])} records - Field attributes for the new object. * @state {SalesforceResultState} * @returns {Operation} */ export function update(sObjectName: string, records: (object | object[])): Operation; /** * Retrieves a Salesforce sObject(s). * @public * @example Retrieve a specific ContentVersion record * retrieve('ContentVersion', '0684K0000020Au7QAE/VersionData'); * @function * @param {string} sObjectName - The sObject to retrieve * @param {string} id - The id of the record * @state {SalesforceState} * @returns {Operation} */ export function retrieve(sObjectName: string, id: string): Operation; export function sfRequest(httpRequest: any): any; export type State = { /** * JSON Data. */ data: object; /** * History of all previous operations. */ references: Array; }; export type Operation = Function; /** * State object */ export type SalesforceState = { /** * - API response data. Can be either an object or array of objects */ data: any; /** * - History of all previous states */ references: any; }; /** * State object */ export type SalesforceResultState = { /** * - Summary of the response from Salesforce */ data: any; /** * - `true` if Salesforce reports no errors from the operation */ success: any; /** * - Array of ids for every successful completion */ completed: any; /** * - Array of errors reported by Salesforce */ errors: any; /** * - History of all previous states */ references: any; }; /** * @typedef {object} State * @property {object} data JSON Data. * @property {Array} references History of all previous operations. * @ignore */ /** * @typedef {function} Operation * @param {State} state * @ignore */ /** * State object * @typedef {Object} SalesforceState * @property data - API response data. Can be either an object or array of objects * @property references - History of all previous states * @private **/ /** * State object * @typedef {Object} SalesforceResultState * @property data - Summary of the response from Salesforce * @property data.success - `true` if Salesforce reports no errors from the operation * @property data.completed - Array of ids for every successful completion * @property data.errors - Array of errors reported by Salesforce * @property references - History of all previous states **/ export let connection: any; export { alterState, arrayToString, as, chunk, combine, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, group, humanProper, index, join, jsonValue, lastReferenceValue, log, map, merge, referencePath, scrubEmojis, source, sourceValue, toArray } from "@openfn/language-common";