Skip to content
This repository has been archived by the owner on Oct 24, 2022. It is now read-only.

Commit

Permalink
updated documentation for relationship and lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
santiagogak committed Nov 23, 2017
1 parent d1662cb commit 55b012d
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 22 deletions.
66 changes: 64 additions & 2 deletions lib/FakeAdaptor.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @module FakeAdaptor */
'use strict';

Object.defineProperty(exports, "__esModule", {
Expand Down Expand Up @@ -137,8 +138,17 @@ var _lodashFp = require('lodash-fp');

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

/** @module FakeAdaptor */

/**
* Flattens an array of operations.
* @example
* steps(
* createIf(params),
* update(params)
* )
* @function
* @returns {Array}
*/
function steps() {
for (var _len = arguments.length, operations = Array(_len), _key = 0; _key < _len; _key++) {
operations[_key] = arguments[_key];
Expand All @@ -147,13 +157,40 @@ function steps() {
return (0, _lodashFp.flatten)(operations);
}

// TODO: use the one from language-common
/**
* Expands references.
* @example
* expandReferences(
* state,
* {
* attr1: "foo",
* attr2: "bar"
* }
* )
* @function
* @param {Object} attrs - Field attributes for the new object.
* @param {State} state - Runtime state.
* @returns {State}
*/
function expandReferences(attrs, state) {
// TODO: use the one from language-common
return (0, _lodashFp.mapValues)(function (value) {
return typeof value == 'function' ? value(state) : value;
})(attrs);
}

/**
* Create a new object.
* @example
* create('obj_name', {
* attr1: "foo",
* attr2: "bar"
* })
* @function
* @param {String} sObject - API name of the sObject.
* @param {Object} fields - Field attributes for the new object.
* @returns {Operation}
*/
function create(sObject, fields) {

return function (state) {
Expand All @@ -171,6 +208,18 @@ function create(sObject, fields) {
};
}

/**
* Update an object.
* @example
* update('obj_name', {
* attr1: "foo",
* attr2: "bar"
* })
* @function
* @param {String} sObject - API name of the sObject.
* @param {Object} fields - Field attributes for the new object.
* @returns {Operation}
*/
function update(sObject, fields) {

return function (state) {
Expand All @@ -188,6 +237,19 @@ function update(sObject, fields) {
};
}

/**
* Upsert an object.
* @example
* upsert('obj_name', 'ext_id', {
* attr1: "foo",
* attr2: "bar"
* })
* @function
* @param {String} sObject - API name of the sObject.
* @param {String} externalId - ID.
* @param {Object} fields - Field attributes for the new object.
* @returns {Operation}
*/
function upsert(sObject, externalId, fields) {

return function (state) {
Expand Down
23 changes: 13 additions & 10 deletions lib/sourceHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope

/**
* Adds a lookup or 'dome insert' to a record.
* @example <caption>Example</caption>
* lookup("relationship_name__r", "externalID on related object", "$.path")
* @constructor
* @public
* @example
* lookup("relationship_name__r", "externalID on related object", "$.path")
* @function
* @param {string} relationshipName - `__r` relationship field on the record.
* @param {string} externalID - Salesforce ExternalID field.
* @param {string} externalId - Salesforce ExternalID field.
* @param {string} path - JSONPath to data source.
* @returns {object}
*/
Expand All @@ -30,13 +31,15 @@ function lookup(relationshipName, externalId, path) {

/**
* Adds a lookup or 'dome insert' to a record.
* @example <caption>Data Sourced Value</caption>
* relationship("relationship_name__r", "externalID on related object", dataSource("path"))
* @example <caption>Fixed Value</caption>
* relationship("relationship_name__r", "externalID on related object", "hello world")
* @constructor
* @public
* @example
* Data Sourced Value:
* relationship("relationship_name__r", "externalID on related object", dataSource("path"))
* Fixed Value:
* relationship("relationship_name__r", "externalID on related object", "hello world")
* @function
* @param {string} relationshipName - `__r` relationship field on the record.
* @param {string} externalID - Salesforce ExternalID field.
* @param {string} externalId - Salesforce ExternalID field.
* @param {string} dataSource - resolvable source.
* @returns {object}
*/
Expand Down
23 changes: 13 additions & 10 deletions src/sourceHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { sourceValue, field } from 'language-common';

/**
* Adds a lookup or 'dome insert' to a record.
* @example <caption>Example</caption>
* lookup("relationship_name__r", "externalID on related object", "$.path")
* @constructor
* @public
* @example
* lookup("relationship_name__r", "externalID on related object", "$.path")
* @function
* @param {string} relationshipName - `__r` relationship field on the record.
* @param {string} externalID - Salesforce ExternalID field.
* @param {string} externalId - Salesforce ExternalID field.
* @param {string} path - JSONPath to data source.
* @returns {object}
*/
Expand All @@ -20,13 +21,15 @@ export function lookup(relationshipName, externalId, path) {

/**
* Adds a lookup or 'dome insert' to a record.
* @example <caption>Data Sourced Value</caption>
* relationship("relationship_name__r", "externalID on related object", dataSource("path"))
* @example <caption>Fixed Value</caption>
* relationship("relationship_name__r", "externalID on related object", "hello world")
* @constructor
* @public
* @example
* Data Sourced Value:
* relationship("relationship_name__r", "externalID on related object", dataSource("path"))
* Fixed Value:
* relationship("relationship_name__r", "externalID on related object", "hello world")
* @function
* @param {string} relationshipName - `__r` relationship field on the record.
* @param {string} externalID - Salesforce ExternalID field.
* @param {string} externalId - Salesforce ExternalID field.
* @param {string} dataSource - resolvable source.
* @returns {object}
*/
Expand Down

0 comments on commit 55b012d

Please sign in to comment.