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

Commit

Permalink
adds @public tag
Browse files Browse the repository at this point in the history
  • Loading branch information
santiagogak committed Sep 7, 2017
1 parent 34797a4 commit ae7f67e
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 34 deletions.
48 changes: 29 additions & 19 deletions lib/Adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ Object.defineProperty(exports, "__esModule", {
});
exports.alterState = exports.arrayToString = exports.toArray = exports.beta = exports.index = exports.lastReferenceValue = exports.referencePath = exports.dataValue = exports.dataPath = exports.merge = exports.combine = exports.map = exports.sourceValue = exports.source = exports.field = exports.fields = exports.join = exports.each = exports.relationship = exports.lookup = exports.reference = exports.update = exports.upsertIf = exports.upsert = exports.createIf = exports.create = exports.describe = undefined;

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /** @module Adaptor */

/**
* @typedef {Object} State
* @property {object} data JSON Data.
* @property {Array<Reference>} references History of all previous operations.
*/

/**
* @typedef {Function} Operation
* @param {State} state
*/

exports.execute = execute;
exports.steps = steps;
Expand Down Expand Up @@ -146,21 +157,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de

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 Adaptor */

/**
* @typedef {Object} State
* @property {object} data JSON Data.
* @property {Array<Reference>} references History of all previous operations.
*/

/**
* @typedef {Function} Operation
* @param {State} state
*/

/**
* Outputs basic information about an sObject to `STDOUT`.
* @public
* @example
* describe(
* 'obj_name',
Expand Down Expand Up @@ -188,6 +187,7 @@ var describe = exports.describe = (0, _lodashFp.curry)(function (sObject, state)

/**
* Create a new object.
* @public
* @example
* create(
* 'obj_name',
Expand Down Expand Up @@ -218,6 +218,7 @@ var create = exports.create = (0, _lodashFp.curry)(function (sObject, attrs, sta

/**
* Create a new object if conditions are met.
* @public
* @example
* createIf(
* true,
Expand Down Expand Up @@ -258,6 +259,7 @@ var createIf = exports.createIf = (0, _lodashFp.curry)(function (logical, sObjec

/**
* Upsert an object.
* @public
* @example
* upsert(
* 'obj_name',
Expand Down Expand Up @@ -290,6 +292,7 @@ var upsert = exports.upsert = (0, _lodashFp.curry)(function (sObject, externalId

/**
* Upsert if conditions are met.
* @public
* @example
* upsert(
* true,
Expand Down Expand Up @@ -332,6 +335,7 @@ var upsertIf = exports.upsertIf = (0, _lodashFp.curry)(function (logical, sObjec

/**
* Update an object.
* @public
* @example
* update(
* 'obj_name',
Expand Down Expand Up @@ -362,13 +366,14 @@ var update = exports.update = (0, _lodashFp.curry)(function (sObject, attrs, sta

/**
* Get a reference ID by an index.
* @public
* @function
* @param {number} position - Position for references array.
* @param {State} references - Array of references.
* @param {State} state - Array of references.
* @returns {State}
*/
var reference = exports.reference = (0, _lodashFp.curry)(function (position, _ref) {
var references = _ref.references;
var reference = exports.reference = (0, _lodashFp.curry)(function (position, state) {
var references = state.references;

return references[position].id;
});
Expand Down Expand Up @@ -446,7 +451,7 @@ function execute() {
* Removes unserializable keys from the state.
* @example
* cleanupState(state)
* @constructor
* @function
* @param {State} state
* @returns {State}
*/
Expand All @@ -457,8 +462,13 @@ function cleanupState(state) {

/**
* Flattens an array of operations.
* @public
* @example
* steps(
* createIf(params),
* update(params)
* )
* @function
* @param {Array} operations - Operations
* @returns {Array}
*/
function steps() {
Expand Down
43 changes: 28 additions & 15 deletions src/Adaptor.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import { execute as commonExecute } from 'language-common';
import jsforce from 'jsforce';
import { curry, mapValues, flatten } from 'lodash-fp';

/** @module Adaptor */

/**
* @typedef {Object} State
* @property {object} data JSON Data.
* @property {Array<Reference>} references History of all previous operations.
*/
* @typedef {Object} State
* @property {object} data JSON Data.
* @property {Array<Reference>} references History of all previous operations.
*/

/**
* @typedef {Function} Operation
* @param {State} state
*/
* @typedef {Function} Operation
* @param {State} state
*/

import { execute as commonExecute } from 'language-common';
import jsforce from 'jsforce';
import { curry, mapValues, flatten } from 'lodash-fp';

/**
* Outputs basic information about an sObject to `STDOUT`.
* @public
* @example
* describe(
* 'obj_name',
Expand Down Expand Up @@ -46,6 +47,7 @@ export const describe = curry(function(sObject, state) {

/**
* Create a new object.
* @public
* @example
* create(
* 'obj_name',
Expand Down Expand Up @@ -77,6 +79,7 @@ export const create = curry(function(sObject, attrs, state) {

/**
* Create a new object if conditions are met.
* @public
* @example
* createIf(
* true,
Expand Down Expand Up @@ -120,6 +123,7 @@ export const createIf = curry(function(logical, sObject, attrs, state) {

/**
* Upsert an object.
* @public
* @example
* upsert(
* 'obj_name',
Expand Down Expand Up @@ -155,6 +159,7 @@ export const upsert = curry(function(sObject, externalId, attrs, state) {

/**
* Upsert if conditions are met.
* @public
* @example
* upsert(
* true,
Expand Down Expand Up @@ -202,6 +207,7 @@ export const upsertIf = curry(function(logical, sObject, externalId, attrs, stat

/**
* Update an object.
* @public
* @example
* update(
* 'obj_name',
Expand Down Expand Up @@ -233,12 +239,14 @@ export const update = curry(function(sObject, attrs, state) {

/**
* Get a reference ID by an index.
* @public
* @function
* @param {number} position - Position for references array.
* @param {State} references - Array of references.
* @param {State} state - Array of references.
* @returns {State}
*/
export const reference = curry(function(position, {references}) {
export const reference = curry(function(position, state) {
const { references } = state;
return references[position].id;
})

Expand Down Expand Up @@ -316,7 +324,7 @@ export function execute(...operations) {
* Removes unserializable keys from the state.
* @example
* cleanupState(state)
* @constructor
* @function
* @param {State} state
* @returns {State}
*/
Expand All @@ -327,8 +335,13 @@ function cleanupState(state) {

/**
* Flattens an array of operations.
* @public
* @example
* steps(
* createIf(params),
* update(params)
* )
* @function
* @param {Array} operations - Operations
* @returns {Array}
*/
export function steps(...operations) {
Expand Down

0 comments on commit ae7f67e

Please sign in to comment.