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

Commit

Permalink
provide expansion for createIf logical
Browse files Browse the repository at this point in the history
  • Loading branch information
taylordowns2000 committed May 27, 2021
1 parent 85a8969 commit 36044ca
Show file tree
Hide file tree
Showing 8 changed files with 2,741 additions and 237 deletions.
1,492 changes: 1,492 additions & 0 deletions ast.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/Adaptor.js
Expand Up @@ -365,6 +365,7 @@ const createIf = (0, _lodashFp.curry)(function (logical, sObject, attrs, state)
connection
} = state;
const finalAttrs = (0, _languageCommon.expandReferences)(attrs)(state);
logical = (0, _languageCommon.expandReferences)(logical)(state);

if (logical) {
console.info(`Creating ${sObject}`, finalAttrs);
Expand Down Expand Up @@ -615,4 +616,4 @@ function steps(...operations) {
return (0, _lodashFp.flatten)(operations);
}

exports.axios = _axios.default;
exports.axios = _axios.default;
2 changes: 1 addition & 1 deletion lib/FakeAdaptor.js
Expand Up @@ -330,4 +330,4 @@ function execute(...operations) {
console.info('Job failed.');
});
};
}
}
6 changes: 3 additions & 3 deletions lib/index.js
Expand Up @@ -13,9 +13,9 @@ var FakeAdaptor = _interopRequireWildcard(require("./FakeAdaptor"));

exports.FakeAdaptor = FakeAdaptor;

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var _default = Adaptor;
exports.default = _default;
exports.default = _default;
2 changes: 1 addition & 1 deletion lib/sourceHelpers.js
Expand Up @@ -56,4 +56,4 @@ function relationship(relationshipName, externalId, dataSource) {
[externalId]: dataSource
};
});
}
}
1,444 changes: 1,218 additions & 226 deletions package-lock.json

Large diffs are not rendered by default.

25 changes: 21 additions & 4 deletions package.json
Expand Up @@ -5,9 +5,12 @@
"homepage": "https://docs.openfn.org",
"main": "lib/index.js",
"scripts": {
"build": "make",
"build": "node_modules/.bin/babel src -d lib && npm run ast",
"test": "mocha --require @babel/register",
"test:watch": "mocha -w --require @babel/register"
"test:watch": "mocha -w --require @babel/register",
"ast": "simple-ast --adaptor ./src/Adaptor.js --output ast.json",
"postversion": "git push && git push --tags",
"version": "npm run build && git add -A lib ast.json"
},
"author": "Open Function Group",
"license": "LGPLv3",
Expand All @@ -16,7 +19,8 @@
"url": "git://github.com/OpenFn/language-salesforce.git"
},
"files": [
"lib/"
"lib/",
"ast.json"
],
"dependencies": {
"@openfn/language-common": "1.2.8",
Expand All @@ -32,6 +36,7 @@
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"@babel/register": "^7.9.0",
"@openfn/simple-ast": "^0.3.0",
"assertion-error": "^1.0.1",
"chai": "^4.2.0",
"deep-eql": "^4.0.0",
Expand All @@ -40,5 +45,17 @@
"nock": "^13.0.5",
"sinon": "^9.2.3",
"type-detect": "^1.0.0"
}
},
"directories": {
"lib": "./lib"
},
"bundledDependencies": [
"@openfn/language-common",
"axios",
"jsforce",
"JSONPath",
"lodash-fp",
"mustache",
"yargs"
]
}
4 changes: 3 additions & 1 deletion src/Adaptor.js
Expand Up @@ -226,6 +226,8 @@ export const create = curry(function (sObject, attrs, state) {
export const createIf = curry(function (logical, sObject, attrs, state) {
let { connection } = state;
const finalAttrs = expandReferences(attrs)(state);
logical = expandReferences(logical)(state);

if (logical) {
console.info(`Creating ${sObject}`, finalAttrs);
} else {
Expand Down Expand Up @@ -309,7 +311,7 @@ export const upsertIf = curry(function (
let { connection } = state;
const finalAttrs = expandReferences(attrs)(state);
logical = expandReferences(logical)(state);

if (logical) {
console.info(
`Upserting ${sObject} with externalId`,
Expand Down

0 comments on commit 36044ca

Please sign in to comment.