diff --git a/.changeset/stale-islands-see.md b/.changeset/stale-islands-see.md new file mode 100644 index 0000000000..edfa29dca4 --- /dev/null +++ b/.changeset/stale-islands-see.md @@ -0,0 +1,99 @@ +--- +'@openfn/language-puntosolidario-rd': minor +'@openfn/language-googlehealthcare': minor +'@openfn/language-azure-storage': minor +'@openfn/language-googlesheets': minor +'@openfn/language-browserless': minor +'@openfn/language-fhir-ndr-et': minor +'@openfn/language-googledrive': minor +'@openfn/language-khanacademy': minor +'@openfn/language-kobotoolbox': minor +'@openfn/language-medicmobile': minor +'@openfn/language-resourcemap': minor +'@openfn/language-motherduck': minor +'@openfn/language-postgresql': minor +'@openfn/language-salesforce': minor +'@openfn/language-sunbird-rc': minor +'@openfn/language-ghana-bdr': minor +'@openfn/language-ghana-nia': minor +'@openfn/language-lamisplus': minor +'@openfn/language-mailchimp': minor +'@openfn/language-openboxes': minor +'@openfn/language-satusehat': minor +'@openfn/language-siuben-rd': minor +'@openfn/language-surveycto': minor +'@openfn/language-telerivet': minor +'@openfn/language-wigal-sms': minor +'@openfn/language-bigquery': minor +'@openfn/language-commcare': minor +'@openfn/language-dynamics': minor +'@openfn/language-facebook': minor +'@openfn/language-mtn-momo': minor +'@openfn/language-opencrvs': minor +'@openfn/language-openelis': minor +'@openfn/language-openimis': minor +'@openfn/language-openlmis': minor +'@openfn/language-pdfshift': minor +'@openfn/language-rapidpro': minor +'@openfn/language-whatsapp': minor +'@openfn/language-beyonic': minor +'@openfn/language-cartodb': minor +'@openfn/language-chatgpt': minor +'@openfn/language-erpnext': minor +'@openfn/language-fhir-fr': minor +'@openfn/language-ibipimo': minor +'@openfn/language-mailgun': minor +'@openfn/language-memento': minor +'@openfn/language-mojatax': minor +'@openfn/language-mongodb': minor +'@openfn/language-monnify': minor +'@openfn/language-msgraph': minor +'@openfn/language-msupply': minor +'@openfn/language-openhim': minor +'@openfn/language-openmrs': minor +'@openfn/language-openspp': minor +'@openfn/language-pesapal': minor +'@openfn/language-primero': minor +'@openfn/language-progres': minor +'@openfn/language-senaite': minor +'@openfn/language-arcgis': minor +'@openfn/language-aws-s3': minor +'@openfn/language-claude': minor +'@openfn/language-godata': minor +'@openfn/language-hubtel': minor +'@openfn/language-inform': minor +'@openfn/language-intuit': minor +'@openfn/language-maximo': minor +'@openfn/language-openfn': minor +'@openfn/language-stripe': minor +'@openfn/language-twilio': minor +'@openfn/language-vtiger': minor +'@openfn/language-asana': minor +'@openfn/language-dhis2': minor +'@openfn/language-divoc': minor +'@openfn/language-gmail': minor +'@openfn/language-ihris': minor +'@openfn/language-magpi': minor +'@openfn/language-minio': minor +'@openfn/language-mogli': minor +'@openfn/language-mpesa': minor +'@openfn/language-mssql': minor +'@openfn/language-mysql': minor +'@openfn/language-nexmo': minor +'@openfn/language-redis': minor +'@openfn/language-dagu': minor +'@openfn/language-fhir': minor +'@openfn/language-hive': minor +'@openfn/language-http': minor +'@openfn/language-odoo': minor +'@openfn/language-ping': minor +'@openfn/language-sftp': minor +'@openfn/language-varo': minor +'@openfn/language-zata': minor +'@openfn/language-zoho': minor +'@openfn/language-cht': minor +'@openfn/language-ocl': minor +'@openfn/language-odk': minor +--- + +export `log` function from common diff --git a/packages/arcgis/ast.json b/packages/arcgis/ast.json index 61b1598158..e4878da674 100644 --- a/packages/arcgis/ast.json +++ b/packages/arcgis/ast.json @@ -747,6 +747,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/arcgis/src/Adaptor.js b/packages/arcgis/src/Adaptor.js index a24d139643..30bdfec611 100644 --- a/packages/arcgis/src/Adaptor.js +++ b/packages/arcgis/src/Adaptor.js @@ -21,6 +21,7 @@ export { fnIf, group, lastReferenceValue, + log, map, merge, scrubEmojis, diff --git a/packages/asana/ast.json b/packages/asana/ast.json index b18757f91c..3a425196ae 100644 --- a/packages/asana/ast.json +++ b/packages/asana/ast.json @@ -1227,6 +1227,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/asana/src/Adaptor.js b/packages/asana/src/Adaptor.js index edc2dccf9c..42a136da48 100644 --- a/packages/asana/src/Adaptor.js +++ b/packages/asana/src/Adaptor.js @@ -50,13 +50,13 @@ export function getTask(taskGid, params, callback) { const [resolvedTaskGid, resolvedParams] = expandReferences( state, taskGid, - params + params, ); const response = await util.request( state, `tasks/${resolvedTaskGid}`, { query: resolvedParams }, - callback + callback, ); return util.prepareNextState(state, response); }; @@ -87,14 +87,14 @@ export function getTasks(projectGid, params, callback) { const [resolvedProjectGid, resolvedParams] = expandReferences( state, projectGid, - params + params, ); const results = await util.requestWithPagination( state, `projects/${resolvedProjectGid}/tasks`, { query: resolvedParams }, - callback + callback, ); console.log(`Fetched ${results.length} tasks`); return composeNextState(state, results); @@ -121,14 +121,14 @@ export function updateTask(taskGid, data, callback) { const [resolvedTaskGid, resolvedData] = expandReferences( state, taskGid, - data + data, ); const response = await util.request( state, `tasks/${resolvedTaskGid}`, { body: { data: resolvedData }, method: 'PUT' }, - callback + callback, ); return util.prepareNextState(state, response); }; @@ -157,7 +157,7 @@ export function createTask(params, callback) { state, 'tasks', { body: { data: resolvedParams }, method: 'POST' }, - callback + callback, ); return util.prepareNextState(state, response); }; @@ -189,7 +189,7 @@ export function upsertTask(projectGid, params, callback) { const [resolvedProjectGid, { externalId, data }] = expandReferences( state, projectGid, - params + params, ); return util @@ -198,7 +198,7 @@ export function upsertTask(projectGid, params, callback) { }) .then(next => { const matchingTask = next.find( - task => task[externalId] === data[externalId] + task => task[externalId] === data[externalId], ); if (matchingTask) { console.log('Matching task found. Performing update.'); @@ -247,7 +247,7 @@ export function searchTask(task, query = {}, options = {}) { state, task, query, - options + options, ); const { workspaceGid = state.configuration.workspaceGid } = resolvedOptions; const { resource_subtype = 'default_task', ...restQuery } = resolvedQuery; @@ -263,7 +263,7 @@ export function searchTask(task, query = {}, options = {}) { text: resolvedTask, ...restQuery, }, - } + }, ); return util.prepareNextState(state, response); @@ -322,7 +322,7 @@ export function createTaskStory(taskGid, params, callback) { query: { opt_fields, opt_pretty }, method: 'POST', }, - callback + callback, ); return util.prepareNextState(state, response); }; @@ -362,7 +362,7 @@ export function request(path, params = {}, callback) { const [resolvedPath, resolvedParams] = expandReferences( state, path, - params + params, ); const { body, query, method } = resolvedParams; @@ -371,7 +371,7 @@ export function request(path, params = {}, callback) { state, resolvedPath, { method, body, query }, - callback + callback, ); return util.prepareNextState(state, response); @@ -380,6 +380,7 @@ export function request(path, params = {}, callback) { export { alterState, + as, combine, cursor, dataPath, @@ -391,7 +392,7 @@ export { fn, fnIf, lastReferenceValue, + log, merge, sourceValue, - as, } from '@openfn/language-common'; diff --git a/packages/aws-s3/ast.json b/packages/aws-s3/ast.json index 1e11141797..914d695bbb 100644 --- a/packages/aws-s3/ast.json +++ b/packages/aws-s3/ast.json @@ -870,6 +870,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/aws-s3/src/Adaptor.js b/packages/aws-s3/src/Adaptor.js index 4d84e59136..e686171840 100644 --- a/packages/aws-s3/src/Adaptor.js +++ b/packages/aws-s3/src/Adaptor.js @@ -137,6 +137,7 @@ export { fnIf, group, lastReferenceValue, + log, map, merge, scrubEmojis, diff --git a/packages/azure-storage/ast.json b/packages/azure-storage/ast.json index 7747c62f60..cb8adcb4bb 100644 --- a/packages/azure-storage/ast.json +++ b/packages/azure-storage/ast.json @@ -756,6 +756,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/azure-storage/src/Adaptor.js b/packages/azure-storage/src/Adaptor.js index ae45d90358..f8260f17cb 100644 --- a/packages/azure-storage/src/Adaptor.js +++ b/packages/azure-storage/src/Adaptor.js @@ -242,6 +242,7 @@ export { fn, fnIf, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/beyonic/ast.json b/packages/beyonic/ast.json index e225e8be66..0a0432b94a 100644 --- a/packages/beyonic/ast.json +++ b/packages/beyonic/ast.json @@ -599,6 +599,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/beyonic/src/Adaptor.js b/packages/beyonic/src/Adaptor.js index 649dac6654..bb836f4477 100644 --- a/packages/beyonic/src/Adaptor.js +++ b/packages/beyonic/src/Adaptor.js @@ -104,13 +104,14 @@ export function createCollectionRequest(data) { export { combine, - fn, - fnIf, - field, - fields, - sourceValue, - merge, dataPath, dataValue, + field, + fields, + fn, + fnIf, lastReferenceValue, + log, + merge, + sourceValue, } from '@openfn/language-common'; diff --git a/packages/bigquery/ast.json b/packages/bigquery/ast.json index bb6d8eeb8f..07ad18d2f7 100644 --- a/packages/bigquery/ast.json +++ b/packages/bigquery/ast.json @@ -698,6 +698,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/bigquery/src/Adaptor.js b/packages/bigquery/src/Adaptor.js index 3da27059d8..0249d968ac 100644 --- a/packages/bigquery/src/Adaptor.js +++ b/packages/bigquery/src/Adaptor.js @@ -116,17 +116,18 @@ export function load( } export { - fn, - fnIf, alterState, - dataPath, combine, + dataPath, dataValue, each, field, fields, + fn, + fnIf, lastReferenceValue, + log, merge, - sourceValue, parseCsv, + sourceValue, } from '@openfn/language-common'; diff --git a/packages/browserless/ast.json b/packages/browserless/ast.json index 858bbb13f8..8ec58e0471 100644 --- a/packages/browserless/ast.json +++ b/packages/browserless/ast.json @@ -853,6 +853,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/browserless/src/Adaptor.js b/packages/browserless/src/Adaptor.js index 7d0e5e61fd..e98a1f909f 100644 --- a/packages/browserless/src/Adaptor.js +++ b/packages/browserless/src/Adaptor.js @@ -52,6 +52,7 @@ export { fnIf, group, lastReferenceValue, + log, map, merge, scrubEmojis, diff --git a/packages/cartodb/ast.json b/packages/cartodb/ast.json index c0d117d77b..954e1cc491 100644 --- a/packages/cartodb/ast.json +++ b/packages/cartodb/ast.json @@ -629,6 +629,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/cartodb/src/Adaptor.js b/packages/cartodb/src/Adaptor.js index 60747a2699..858004fe6b 100644 --- a/packages/cartodb/src/Adaptor.js +++ b/packages/cartodb/src/Adaptor.js @@ -92,14 +92,15 @@ export function addRow(table, rowData) { export { combine, - fn, - fnIf, - field, - fields, - sourceValue, - each, - merge, dataPath, dataValue, + each, + field, + fields, + fn, + fnIf, lastReferenceValue, + log, + merge, + sourceValue, } from '@openfn/language-common'; diff --git a/packages/chatgpt/ast.json b/packages/chatgpt/ast.json index d846887be5..a4a99f6d92 100644 --- a/packages/chatgpt/ast.json +++ b/packages/chatgpt/ast.json @@ -670,6 +670,55 @@ ] }, "valid": false + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/chatgpt/src/Adaptor.js b/packages/chatgpt/src/Adaptor.js index 6c44149c1f..d8aa64648d 100644 --- a/packages/chatgpt/src/Adaptor.js +++ b/packages/chatgpt/src/Adaptor.js @@ -57,7 +57,7 @@ export function execute(...operations) { return state => { return commonExecute( createClient, - ...operations + ...operations, )({ ...initialState, ...state, @@ -80,7 +80,7 @@ export function prompt(message, opts) { const [resolvedMessage, resolvedOpts] = expandReferences( state, message, - opts + opts, ); const payload = { @@ -124,7 +124,7 @@ export function deepResearch(message, opts) { const [resolvedMessage, resolvedOpts] = expandReferences( state, message, - opts + opts, ); const payload = { @@ -144,15 +144,16 @@ export function deepResearch(message, opts) { export { combine, + cursor, dataPath, dataValue, dateFns, - cursor, each, field, fields, fn, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/cht/ast.json b/packages/cht/ast.json index 28e2a97774..40b02ac4f3 100644 --- a/packages/cht/ast.json +++ b/packages/cht/ast.json @@ -883,6 +883,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/cht/src/Adaptor.js b/packages/cht/src/Adaptor.js index 020d229d5f..854e2b6839 100644 --- a/packages/cht/src/Adaptor.js +++ b/packages/cht/src/Adaptor.js @@ -111,7 +111,7 @@ export function request(method, path, body, options = {}, callback = s => s) { { data: resolvedData, ...resolvedoptions, - } + }, ); return util.prepareNextState(state, response, callback); @@ -119,17 +119,18 @@ export function request(method, path, body, options = {}, callback = s => s) { } export { + as, combine, + cursor, dataPath, dataValue, dateFns, - cursor, each, field, fields, fn, lastReferenceValue, + log, merge, sourceValue, - as } from '@openfn/language-common'; diff --git a/packages/claude/ast.json b/packages/claude/ast.json index 492b64aa1a..e6bcc73805 100644 --- a/packages/claude/ast.json +++ b/packages/claude/ast.json @@ -617,6 +617,55 @@ ] }, "valid": false + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/claude/src/Adaptor.js b/packages/claude/src/Adaptor.js index 525d736867..1003c1edbe 100644 --- a/packages/claude/src/Adaptor.js +++ b/packages/claude/src/Adaptor.js @@ -47,7 +47,7 @@ export function execute(...operations) { return state => { return commonExecute( createClient, - ...operations + ...operations, )({ ...initialState, ...state, @@ -74,7 +74,7 @@ export function prompt(message, opts) { const [resolvedMessage, resolvedOpts] = expandReferences( state, message, - opts + opts, ); const payload = { @@ -91,15 +91,16 @@ export function prompt(message, opts) { export { combine, + cursor, dataPath, dataValue, dateFns, - cursor, each, field, fields, fn, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/commcare/ast.json b/packages/commcare/ast.json index fa290a7ae0..da0de4b0db 100644 --- a/packages/commcare/ast.json +++ b/packages/commcare/ast.json @@ -1196,6 +1196,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/commcare/src/Adaptor.js b/packages/commcare/src/Adaptor.js index 38f2e0aee7..b1a0475b09 100644 --- a/packages/commcare/src/Adaptor.js +++ b/packages/commcare/src/Adaptor.js @@ -463,6 +463,7 @@ export { fn, fnIf, lastReferenceValue, + log, map, merge, sourceValue, diff --git a/packages/dagu/ast.json b/packages/dagu/ast.json index acfe2034bd..52231c8930 100644 --- a/packages/dagu/ast.json +++ b/packages/dagu/ast.json @@ -956,6 +956,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/dagu/src/Adaptor.js b/packages/dagu/src/Adaptor.js index 3c9e2360f0..4fbb937d10 100644 --- a/packages/dagu/src/Adaptor.js +++ b/packages/dagu/src/Adaptor.js @@ -102,6 +102,7 @@ export { fnIf, group, lastReferenceValue, + log, map, merge, scrubEmojis, diff --git a/packages/dhis2/ast.json b/packages/dhis2/ast.json index 164d198333..844a6ee6db 100644 --- a/packages/dhis2/ast.json +++ b/packages/dhis2/ast.json @@ -1194,6 +1194,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/dhis2/src/Adaptor.js b/packages/dhis2/src/Adaptor.js index 582b338a1c..66a1de2ceb 100644 --- a/packages/dhis2/src/Adaptor.js +++ b/packages/dhis2/src/Adaptor.js @@ -663,6 +663,7 @@ export { fnIf, group, lastReferenceValue, + log, map, merge, sourceValue, diff --git a/packages/divoc/ast.json b/packages/divoc/ast.json index 0def9f4213..03a5d0224b 100644 --- a/packages/divoc/ast.json +++ b/packages/divoc/ast.json @@ -612,6 +612,55 @@ ] }, "valid": false + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/divoc/src/Adaptor.js b/packages/divoc/src/Adaptor.js index 7208292a48..c63f69cead 100644 --- a/packages/divoc/src/Adaptor.js +++ b/packages/divoc/src/Adaptor.js @@ -2,7 +2,6 @@ import { execute as commonExecute } from '@openfn/language-common'; import { expandReferences } from '@openfn/language-common/util'; import * as util from './Utils.js'; - /** * State object * @typedef {Object} DivocHttpState @@ -18,7 +17,7 @@ import * as util from './Utils.js'; * @private * @example * execute(certifyVaccination({}))(state) - * @param {Operations} operations + * @param {Operations} operations * @returns {operation} */ export function execute(...operations) { @@ -28,11 +27,10 @@ export function execute(...operations) { }; return state => { - return commonExecute(...operations)({...initialState,...state}) - } + return commonExecute(...operations)({ ...initialState, ...state }); + }; } - /** * Certify a vaccination * @public @@ -89,34 +87,36 @@ export function execute(...operations) { */ export function certifyVaccination(data) { return async state => { - const [resolvedData] = expandReferences(state, data); const { baseUrl } = state.configuration; const options = { method: 'POST', data: resolvedData, - } - + }; + + const response = await util.request( + { ...state.configuration }, + '/v1/certify', + options, + ); - const response = await util.request({...state.configuration}, '/v1/certify', options); - return util.prepareNextState(state, response); - } + }; } - export { combine, + cursor, dataPath, dataValue, dateFns, - cursor, each, field, fields, fn, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/dynamics/ast.json b/packages/dynamics/ast.json index 79cf0f7b2a..29f5e3a6ff 100644 --- a/packages/dynamics/ast.json +++ b/packages/dynamics/ast.json @@ -530,6 +530,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/dynamics/src/Adaptor.js b/packages/dynamics/src/Adaptor.js index 53d7307922..a3dc8337db 100644 --- a/packages/dynamics/src/Adaptor.js +++ b/packages/dynamics/src/Adaptor.js @@ -73,7 +73,7 @@ export function createEntity(params) { console.log('Create entity succeeded.'); resolve(response); } - } + }, ); }).then(data => { const nextState = { @@ -148,7 +148,7 @@ export function query(params) { console.log(JSON.parse(body)); resolve(response); } - } + }, ); }).then(data => { const nextState = { @@ -201,7 +201,7 @@ export function updateEntity(params) { console.log('Update succeeded.'); resolve(response); } - } + }, ); }).then(data => { const nextState = { @@ -252,7 +252,7 @@ export function deleteEntity(params) { console.log('Delete succeeded.'); resolve(response); } - } + }, ); }).then(data => { const nextState = { @@ -265,16 +265,17 @@ export function deleteEntity(params) { } export { + alterState, combine, + dataPath, + dataValue, + each, field, fields, - sourceValue, - alterState, fn, fnIf, - each, - merge, - dataPath, - dataValue, lastReferenceValue, + log, + merge, + sourceValue, } from '@openfn/language-common'; diff --git a/packages/erpnext/ast.json b/packages/erpnext/ast.json index 542c164d81..e32684b11f 100644 --- a/packages/erpnext/ast.json +++ b/packages/erpnext/ast.json @@ -954,6 +954,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/erpnext/src/Adaptor.js b/packages/erpnext/src/Adaptor.js index f5a38313b8..b2f826e962 100644 --- a/packages/erpnext/src/Adaptor.js +++ b/packages/erpnext/src/Adaptor.js @@ -373,6 +373,7 @@ export { fn, fnIf, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/facebook/ast.json b/packages/facebook/ast.json index 29692fe992..6fe8e32383 100644 --- a/packages/facebook/ast.json +++ b/packages/facebook/ast.json @@ -574,6 +574,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/facebook/src/Adaptor.js b/packages/facebook/src/Adaptor.js index dd769b2eb3..cb70378320 100644 --- a/packages/facebook/src/Adaptor.js +++ b/packages/facebook/src/Adaptor.js @@ -93,7 +93,7 @@ export function postMessage(params) { console.log('Post Message succeeded.'); resolve(body); } - } + }, ); }).then(response => { const nextState = composeNextState(state, response); @@ -103,16 +103,17 @@ export function postMessage(params) { } export { + alterState, combine, + dataPath, + dataValue, + each, field, fields, - sourceValue, fn, fnIf, - alterState, - each, - merge, - dataPath, - dataValue, lastReferenceValue, + log, + merge, + sourceValue, } from '@openfn/language-common'; diff --git a/packages/fhir-fr/ast.json b/packages/fhir-fr/ast.json index 540b4e3653..70624756ac 100644 --- a/packages/fhir-fr/ast.json +++ b/packages/fhir-fr/ast.json @@ -563,6 +563,55 @@ ] }, "valid": false + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/fhir-fr/src/Adaptor.js b/packages/fhir-fr/src/Adaptor.js index 8c7dfcb689..f71a7d3e8c 100644 --- a/packages/fhir-fr/src/Adaptor.js +++ b/packages/fhir-fr/src/Adaptor.js @@ -6,15 +6,16 @@ import * as util from './Utils'; export { combine, + cursor, dataPath, dataValue, dateFns, - cursor, each, field, fields, fn, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/fhir-ndr-et/ast.json b/packages/fhir-ndr-et/ast.json index f4c872727a..2add3ee3af 100644 --- a/packages/fhir-ndr-et/ast.json +++ b/packages/fhir-ndr-et/ast.json @@ -637,6 +637,55 @@ ] }, "valid": false + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/fhir-ndr-et/src/Adaptor.js b/packages/fhir-ndr-et/src/Adaptor.js index a6587c642b..6245fbe11e 100644 --- a/packages/fhir-ndr-et/src/Adaptor.js +++ b/packages/fhir-ndr-et/src/Adaptor.js @@ -54,7 +54,7 @@ export const create = (resourceType, resource, params, callback = s => s) => { state.configuration, 'POST', resolvedResourceType, - opts + opts, ); return util.prepareNextState(state, response, callback); }; @@ -62,14 +62,15 @@ export const create = (resourceType, resource, params, callback = s => s) => { export { combine, + cursor, dataPath, dataValue, - cursor, each, field, fields, fn, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/fhir/ast.json b/packages/fhir/ast.json index 0e14c20ea1..d13aa71c5c 100644 --- a/packages/fhir/ast.json +++ b/packages/fhir/ast.json @@ -894,6 +894,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/fhir/src/Adaptor.js b/packages/fhir/src/Adaptor.js index 2d9187cd8a..fb416960b5 100644 --- a/packages/fhir/src/Adaptor.js +++ b/packages/fhir/src/Adaptor.js @@ -278,6 +278,7 @@ export { fn, fnIf, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/ghana-bdr/ast.json b/packages/ghana-bdr/ast.json index 057325b587..554534ffac 100644 --- a/packages/ghana-bdr/ast.json +++ b/packages/ghana-bdr/ast.json @@ -778,6 +778,55 @@ ] }, "valid": false + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/ghana-bdr/src/Adaptor.js b/packages/ghana-bdr/src/Adaptor.js index f108e8d21f..e3123ca9ec 100644 --- a/packages/ghana-bdr/src/Adaptor.js +++ b/packages/ghana-bdr/src/Adaptor.js @@ -89,16 +89,17 @@ export function sendBirthNotification(data) { export { combine, - fn, - fnIf, - each, - merge, - field, - fields, cursor, - dateFns, dataPath, dataValue, - sourceValue, + dateFns, + each, + field, + fields, + fn, + fnIf, lastReferenceValue, + log, + merge, + sourceValue, } from '@openfn/language-common'; diff --git a/packages/ghana-nia/ast.json b/packages/ghana-nia/ast.json index fae83e875f..4d7ccd63b0 100644 --- a/packages/ghana-nia/ast.json +++ b/packages/ghana-nia/ast.json @@ -778,6 +778,55 @@ ] }, "valid": false + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/ghana-nia/src/Adaptor.js b/packages/ghana-nia/src/Adaptor.js index 50d1d66dc4..9e80a4c909 100644 --- a/packages/ghana-nia/src/Adaptor.js +++ b/packages/ghana-nia/src/Adaptor.js @@ -106,16 +106,17 @@ export function registerChild(data) { export { combine, - fn, - fnIf, - each, - merge, - field, - fields, cursor, - dateFns, dataPath, dataValue, - sourceValue, + dateFns, + each, + field, + fields, + fn, + fnIf, lastReferenceValue, + log, + merge, + sourceValue, } from '@openfn/language-common'; diff --git a/packages/gmail/ast.json b/packages/gmail/ast.json index ee592b3fc5..441452541f 100644 --- a/packages/gmail/ast.json +++ b/packages/gmail/ast.json @@ -739,6 +739,55 @@ ] }, "valid": false + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/gmail/src/Adaptor.js b/packages/gmail/src/Adaptor.js index 179482b145..2520579af5 100644 --- a/packages/gmail/src/Adaptor.js +++ b/packages/gmail/src/Adaptor.js @@ -240,6 +240,7 @@ export { fn, fnIf, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/godata/ast.json b/packages/godata/ast.json index 45dac62752..db20167128 100644 --- a/packages/godata/ast.json +++ b/packages/godata/ast.json @@ -1376,6 +1376,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/godata/src/Adaptor.js b/packages/godata/src/Adaptor.js index 7432f0a81a..08b33692b0 100644 --- a/packages/godata/src/Adaptor.js +++ b/packages/godata/src/Adaptor.js @@ -26,7 +26,7 @@ export function execute(...operations) { return state => { return commonExecute( login, - ...operations + ...operations, /* logout */ )({ ...initialState, ...state }).catch(e => { console.error(e); @@ -324,7 +324,7 @@ export function upsertOutbreak(outbreak, callback) { const { apiUrl, access_token } = state.configuration; const [resolvedOutbreak] = expandReferences(state, outbreak); - const {externalId, data} = resolvedOutbreak; + const { externalId, data } = resolvedOutbreak; const filter = JSON.stringify({ where: { id: externalId } }); @@ -668,7 +668,7 @@ export function upsertLocation(externalId, goDataLocation, callback) { if (response.data.length > 1) { console.log( response.data.length, - 'locations found; aborting upsert.' + 'locations found; aborting upsert.', ); return response; } else if (response.data.length === 1) { @@ -827,7 +827,7 @@ export function upsertReferenceData(externalId, goDataReferenceData, callback) { if (response.data.length > 1) { console.log( response.data.length, - 'reference data found; aborting upsert.' + 'reference data found; aborting upsert.', ); return response; } else if (response.data.length === 1) { @@ -883,16 +883,17 @@ export { axios }; // What functions do you want from the common adaptor? export { - combine, - fn, - fnIf, alterState, + combine, dataPath, dataValue, each, field, fields, + fn, + fnIf, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/googledrive/ast.json b/packages/googledrive/ast.json index 61e96e2cfb..59f1646532 100644 --- a/packages/googledrive/ast.json +++ b/packages/googledrive/ast.json @@ -1040,6 +1040,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/googledrive/src/Adaptor.js b/packages/googledrive/src/Adaptor.js index 233840ad33..19a326aad8 100644 --- a/packages/googledrive/src/Adaptor.js +++ b/packages/googledrive/src/Adaptor.js @@ -238,23 +238,24 @@ export function update(fileId, content) { } export { + alterState, + arrayToString, as, - fn, - fnIf, - util, - each, - field, - merge, chunk, - fields, - cursor, combine, - dateFns, - parseCsv, + cursor, dataPath, dataValue, - alterState, - sourceValue, - arrayToString, + dateFns, + each, + field, + fields, + fn, + fnIf, lastReferenceValue, + log, + merge, + parseCsv, + sourceValue, + util, } from '@openfn/language-common'; diff --git a/packages/googlehealthcare/ast.json b/packages/googlehealthcare/ast.json index 54f122e32d..f27791bac5 100644 --- a/packages/googlehealthcare/ast.json +++ b/packages/googlehealthcare/ast.json @@ -634,6 +634,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/googlehealthcare/src/Adaptor.js b/packages/googlehealthcare/src/Adaptor.js index 2f8c34ab6d..ddb34e9758 100644 --- a/packages/googlehealthcare/src/Adaptor.js +++ b/packages/googlehealthcare/src/Adaptor.js @@ -158,6 +158,7 @@ export { fn, fnIf, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/googlesheets/ast.json b/packages/googlesheets/ast.json index 9d269ab4d1..26ba70e92b 100644 --- a/packages/googlesheets/ast.json +++ b/packages/googlesheets/ast.json @@ -870,6 +870,55 @@ ] }, "valid": false + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/googlesheets/src/Adaptor.js b/packages/googlesheets/src/Adaptor.js index 9a17e0cb4f..5efe55924f 100644 --- a/packages/googlesheets/src/Adaptor.js +++ b/packages/googlesheets/src/Adaptor.js @@ -245,6 +245,7 @@ export { fn, fnIf, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/hive/ast.json b/packages/hive/ast.json index 763390ae8c..485aab203e 100644 --- a/packages/hive/ast.json +++ b/packages/hive/ast.json @@ -669,6 +669,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/hive/src/Adaptor.js b/packages/hive/src/Adaptor.js index e017812846..3762a0f3bf 100644 --- a/packages/hive/src/Adaptor.js +++ b/packages/hive/src/Adaptor.js @@ -132,8 +132,9 @@ export { fields, fn, fnIf, - parseCsv, lastReferenceValue, + log, merge, + parseCsv, sourceValue, } from '@openfn/language-common'; diff --git a/packages/http/ast.json b/packages/http/ast.json index 31ea46e893..c383e78b5c 100644 --- a/packages/http/ast.json +++ b/packages/http/ast.json @@ -1556,6 +1556,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/http/src/Adaptor.js b/packages/http/src/Adaptor.js index 6555886c4e..1806f55e8c 100644 --- a/packages/http/src/Adaptor.js +++ b/packages/http/src/Adaptor.js @@ -209,6 +209,7 @@ export { group, humanProper, lastReferenceValue, + log, map, merge, parseCsv, diff --git a/packages/hubtel/ast.json b/packages/hubtel/ast.json index 19cbfbd30f..2dd276f8d5 100644 --- a/packages/hubtel/ast.json +++ b/packages/hubtel/ast.json @@ -698,6 +698,55 @@ ] }, "valid": false + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/hubtel/src/Adaptor.js b/packages/hubtel/src/Adaptor.js index 128f716fe7..02b4291ac7 100644 --- a/packages/hubtel/src/Adaptor.js +++ b/packages/hubtel/src/Adaptor.js @@ -45,7 +45,7 @@ export function request(method, path, body, options = {}) { { body: resolvedData, ...resolvedoptions, - } + }, ); return util.prepareNextState(state, response); @@ -77,15 +77,16 @@ export function request(method, path, body, options = {}) { export { combine, + cursor, dataPath, dataValue, dateFns, - cursor, each, field, fields, fn, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/ibipimo/ast.json b/packages/ibipimo/ast.json index 8847e155ff..a1952b77e9 100644 --- a/packages/ibipimo/ast.json +++ b/packages/ibipimo/ast.json @@ -1151,6 +1151,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/ibipimo/src/Adaptor.js b/packages/ibipimo/src/Adaptor.js index 2418e59953..0577e98f6d 100644 --- a/packages/ibipimo/src/Adaptor.js +++ b/packages/ibipimo/src/Adaptor.js @@ -243,6 +243,7 @@ export { fnIf, group, lastReferenceValue, + log, map, merge, scrubEmojis, diff --git a/packages/ihris/ast.json b/packages/ihris/ast.json index 61b1598158..e4878da674 100644 --- a/packages/ihris/ast.json +++ b/packages/ihris/ast.json @@ -747,6 +747,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/ihris/src/Adaptor.js b/packages/ihris/src/Adaptor.js index 0c98c69fc5..10a0e79789 100644 --- a/packages/ihris/src/Adaptor.js +++ b/packages/ihris/src/Adaptor.js @@ -14,6 +14,7 @@ export { fnIf, group, lastReferenceValue, + log, map, merge, scrubEmojis, diff --git a/packages/inform/ast.json b/packages/inform/ast.json index e6c0b7858b..f0b5c46747 100644 --- a/packages/inform/ast.json +++ b/packages/inform/ast.json @@ -1103,6 +1103,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/inform/src/Adaptor.js b/packages/inform/src/Adaptor.js index 1d2406788c..961bc49519 100644 --- a/packages/inform/src/Adaptor.js +++ b/packages/inform/src/Adaptor.js @@ -235,6 +235,7 @@ export function downloadAttachment(attachmentId, options = {}) { } export { + as, combine, cursor, dataPath, @@ -247,9 +248,9 @@ export { fnIf, group, lastReferenceValue, + log, merge, scrubEmojis, sourceValue, util, - as, } from '@openfn/language-common'; diff --git a/packages/intuit/ast.json b/packages/intuit/ast.json index 540b4e3653..70624756ac 100644 --- a/packages/intuit/ast.json +++ b/packages/intuit/ast.json @@ -563,6 +563,55 @@ ] }, "valid": false + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/intuit/src/Adaptor.js b/packages/intuit/src/Adaptor.js index 0e7ff9cbd6..933f6cc6ac 100644 --- a/packages/intuit/src/Adaptor.js +++ b/packages/intuit/src/Adaptor.js @@ -1,16 +1,16 @@ - // More functions can be added here as needed export { combine, + cursor, dataPath, dataValue, dateFns, - cursor, each, field, fields, fn, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/khanacademy/ast.json b/packages/khanacademy/ast.json index f5abc45050..46f6a4607c 100644 --- a/packages/khanacademy/ast.json +++ b/packages/khanacademy/ast.json @@ -511,6 +511,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/khanacademy/src/Adaptor.js b/packages/khanacademy/src/Adaptor.js index 8cd7b606f1..00f91a2aa0 100644 --- a/packages/khanacademy/src/Adaptor.js +++ b/packages/khanacademy/src/Adaptor.js @@ -43,13 +43,13 @@ export function fetch(params) { const { email, password, consumerKey, secretKey } = state.configuration; const [resolvedParams] = expandReferences(state, params); - const {getEndpoint, queryParams, postUrl} = resolvedParams; + const { getEndpoint, queryParams, postUrl } = resolvedParams; const query = qs.stringify(queryParams); const getUrl = resolveUrl( 'https://www.khanacademy.org/api/v1' + '/', - getEndpoint + '?' + query + getEndpoint + '?' + query, ); console.log('Fetching data from URL: ' + getUrl); @@ -79,7 +79,7 @@ export function fetch(params) { console.log('Token request successful.'); resolve(qs.parse(body)); } - } + }, ); }) @@ -114,7 +114,7 @@ export function fetch(params) { console.log('Token auhorization successful.'); resolve(auth); } - } + }, ); }); }) @@ -144,7 +144,7 @@ export function fetch(params) { console.log('Token exchange successful.'); resolve(qs.parse(body)); } - } + }, ); }); }) @@ -175,7 +175,7 @@ export function fetch(params) { console.log(body); resolve(body); } - } + }, ); }); }) @@ -197,7 +197,7 @@ export function fetch(params) { console.log('POST succeeded.'); resolve(body); } - } + }, ); }); }) @@ -206,15 +206,16 @@ export function fetch(params) { } export { - combine, - fn, - fnIf, - field, - sourceValue, - fields, alterState, - merge, + combine, dataPath, dataValue, + field, + fields, + fn, + fnIf, lastReferenceValue, + log, + merge, + sourceValue, } from '@openfn/language-common'; diff --git a/packages/kobotoolbox/ast.json b/packages/kobotoolbox/ast.json index d70b5a9a50..e487ab21bb 100644 --- a/packages/kobotoolbox/ast.json +++ b/packages/kobotoolbox/ast.json @@ -923,6 +923,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/kobotoolbox/src/Adaptor.js b/packages/kobotoolbox/src/Adaptor.js index dee446cfb5..c4c6f561a1 100644 --- a/packages/kobotoolbox/src/Adaptor.js +++ b/packages/kobotoolbox/src/Adaptor.js @@ -147,6 +147,7 @@ export { fnIf, group, lastReferenceValue, + log, map, merge, sourceValue, diff --git a/packages/lamisplus/ast.json b/packages/lamisplus/ast.json index 3886983c94..8a28edf5fc 100644 --- a/packages/lamisplus/ast.json +++ b/packages/lamisplus/ast.json @@ -795,6 +795,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/lamisplus/src/Adaptor.js b/packages/lamisplus/src/Adaptor.js index 5e0dfb50d1..e49ed1ae8c 100644 --- a/packages/lamisplus/src/Adaptor.js +++ b/packages/lamisplus/src/Adaptor.js @@ -99,6 +99,7 @@ export { fnIf, group, lastReferenceValue, + log, map, merge, scrubEmojis, diff --git a/packages/magpi/ast.json b/packages/magpi/ast.json index 203de1c7a4..c81cf428cf 100644 --- a/packages/magpi/ast.json +++ b/packages/magpi/ast.json @@ -617,6 +617,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/magpi/src/Adaptor.js b/packages/magpi/src/Adaptor.js index cec2a1df58..847764277d 100644 --- a/packages/magpi/src/Adaptor.js +++ b/packages/magpi/src/Adaptor.js @@ -100,18 +100,18 @@ export function fetchSurveyData(params) { } console.log( - `Converted ${submissions.length} submission(s) to JSON:` + `Converted ${submissions.length} submission(s) to JSON:`, ); // console.log(submissions); resolve(submissions); } else { console.log( - 'There is no survey data matching the current parameters.' + 'There is no survey data matching the current parameters.', ); resolve([]); } } - } + }, ); }) .then(submissions => { @@ -132,7 +132,7 @@ export function fetchSurveyData(params) { } else { console.log('POST succeeded.'); } - } + }, ); }); return submissions; @@ -142,7 +142,7 @@ export function fetchSurveyData(params) { // TODO: if Magpi API does not return in date order, find oldest... state.lastSubmissionDate = submissions[0].LastSubmissionDate; console.log( - `Set \"lastSubmissionDate\" for next run to: ${submissions[0].LastSubmissionDate}` + `Set \"lastSubmissionDate\" for next run to: ${submissions[0].LastSubmissionDate}`, ); } // Set the lastSubmissionDate for the next time the job runs. @@ -183,16 +183,17 @@ export function submitRecord(jsonData) { } export { - combine, - fn, - fnIf, alterState, - field, - fields, - sourceValue, - each, - merge, + combine, dataPath, dataValue, + each, + field, + fields, + fn, + fnIf, lastReferenceValue, + log, + merge, + sourceValue, } from '@openfn/language-common'; diff --git a/packages/mailchimp/ast.json b/packages/mailchimp/ast.json index 89129d30dd..c9a853f1b4 100644 --- a/packages/mailchimp/ast.json +++ b/packages/mailchimp/ast.json @@ -1450,6 +1450,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/mailchimp/src/Adaptor.js b/packages/mailchimp/src/Adaptor.js index fc17727d1f..1b58d681e4 100644 --- a/packages/mailchimp/src/Adaptor.js +++ b/packages/mailchimp/src/Adaptor.js @@ -462,17 +462,18 @@ export { axios, md5 }; // What functions do you want from the common adaptor? export { - combine, - fn, - fnIf, alterState, + chunk, + combine, dataPath, dataValue, each, field, fields, + fn, + fnIf, lastReferenceValue, + log, merge, - chunk, sourceValue, } from '@openfn/language-common'; diff --git a/packages/mailgun/ast.json b/packages/mailgun/ast.json index d95d0c5789..a15716aa6a 100644 --- a/packages/mailgun/ast.json +++ b/packages/mailgun/ast.json @@ -570,6 +570,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/mailgun/src/Adaptor.js b/packages/mailgun/src/Adaptor.js index 81b92da141..e29ea8c166 100644 --- a/packages/mailgun/src/Adaptor.js +++ b/packages/mailgun/src/Adaptor.js @@ -44,7 +44,7 @@ export function execute(...operations) { return commonExecute( setupClient, ...operations, - teardownClient + teardownClient, )({ ...initialState, ...state }); }; } @@ -113,17 +113,18 @@ export function send(params) { } export { - combine, - fn, - fnIf, - field, alterState, - fields, - sourceValue, - merge, - each, + beta, + combine, dataPath, dataValue, + each, + field, + fields, + fn, + fnIf, lastReferenceValue, - beta, + log, + merge, + sourceValue, } from '@openfn/language-common'; diff --git a/packages/maximo/ast.json b/packages/maximo/ast.json index acd96b8ca8..efbdb48fe6 100644 --- a/packages/maximo/ast.json +++ b/packages/maximo/ast.json @@ -662,6 +662,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/maximo/src/Adaptor.js b/packages/maximo/src/Adaptor.js index 0a39a2aa11..55d0fd70a3 100644 --- a/packages/maximo/src/Adaptor.js +++ b/packages/maximo/src/Adaptor.js @@ -98,10 +98,10 @@ export function fetch(params) { console.log('POST succeeded.'); resolve(getResponseBody); } - } + }, ); } - } + }, ); }) .then(response => { @@ -168,7 +168,7 @@ export function create(params) { console.log('POST succeeded.'); resolve(body); } - } + }, ); }).then(data => { const nextState = { ...state, response: { body: data } }; @@ -236,7 +236,7 @@ export function update(params) { console.log('Update succeeded.'); resolve(body); } - } + }, ); }).then(data => { const nextState = { ...state, response: { body: data } }; @@ -304,7 +304,7 @@ export function update75(params) { console.log('Update succeeded.'); resolve(body); } - } + }, ); }).then(data => { const nextState = { ...state, response: { body: data } }; @@ -314,16 +314,17 @@ export function update75(params) { } export { + alterState, combine, + dataPath, + dataValue, + each, field, fields, - sourceValue, fn, fnIf, - alterState, - each, - merge, - dataPath, - dataValue, lastReferenceValue, + log, + merge, + sourceValue, } from '@openfn/language-common'; diff --git a/packages/medicmobile/ast.json b/packages/medicmobile/ast.json index fe422f95e3..1d79bf7558 100644 --- a/packages/medicmobile/ast.json +++ b/packages/medicmobile/ast.json @@ -690,6 +690,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/medicmobile/src/Adaptor.js b/packages/medicmobile/src/Adaptor.js index aa04ed416d..d2e977ca89 100644 --- a/packages/medicmobile/src/Adaptor.js +++ b/packages/medicmobile/src/Adaptor.js @@ -61,7 +61,7 @@ export function fetchSubmissions(formId, params, postUrl) { json: submissions[i], }); console.log( - `Posted submission ${submissions[i].fields.meta.instanceID} ✓` + `Posted submission ${submissions[i].fields.meta.instanceID} ✓`, ); } return state; @@ -93,7 +93,7 @@ export function changesApi(params, callback) { if (error) return error; console.log(response); return new Error( - `Server responded with ${response.statusCode}:\n ${response.body}` + `Server responded with ${response.statusCode}:\n ${response.body}`, ); } @@ -142,7 +142,7 @@ export function changesApi(params, callback) { console.log('Request Success ✓'); resolve(body); } - } + }, ) .auth(username, password); }).then(response => { @@ -198,16 +198,17 @@ export function pickFormData(formId) { } export { - combine, - fn, - fnIf, alterState, + combine, dataPath, dataValue, each, field, fields, + fn, + fnIf, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/memento/ast.json b/packages/memento/ast.json index e39e0f2569..362a01dba3 100644 --- a/packages/memento/ast.json +++ b/packages/memento/ast.json @@ -1131,6 +1131,55 @@ }, "valid": true }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/memento/src/Adaptor.js b/packages/memento/src/Adaptor.js index f6c0c1b6fa..41f837267b 100644 --- a/packages/memento/src/Adaptor.js +++ b/packages/memento/src/Adaptor.js @@ -232,6 +232,7 @@ export { fnIf, group, lastReferenceValue, + log, map, merge, scrubEmojis, diff --git a/packages/minio/ast.json b/packages/minio/ast.json index 80739bb073..222b5cf597 100644 --- a/packages/minio/ast.json +++ b/packages/minio/ast.json @@ -1383,6 +1383,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/minio/src/Adaptor.js b/packages/minio/src/Adaptor.js index 13f9892b2c..d8109e9e5c 100644 --- a/packages/minio/src/Adaptor.js +++ b/packages/minio/src/Adaptor.js @@ -363,7 +363,6 @@ export { cursor, dataPath, dataValue, - parseCsv, dateFns, each, field, @@ -372,8 +371,10 @@ export { fnIf, group, lastReferenceValue, + log, map, merge, + parseCsv, scrubEmojis, sourceValue, util, diff --git a/packages/mogli/ast.json b/packages/mogli/ast.json index 474870cf75..dd3aa8e8ea 100644 --- a/packages/mogli/ast.json +++ b/packages/mogli/ast.json @@ -825,6 +825,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/mogli/src/Adaptor.js b/packages/mogli/src/Adaptor.js index 740741c4a0..3a1b08f666 100644 --- a/packages/mogli/src/Adaptor.js +++ b/packages/mogli/src/Adaptor.js @@ -199,23 +199,24 @@ function expandReferences(state, attrs) { export { lookup, relationship } from './sourceHelpers.js'; export { - each, - join, - fields, - field, - source, - sourceValue, + alterState, + arrayToString, + beta, combine, - merge, dataPath, dataValue, - referencePath, - lastReferenceValue, - index, - beta, - toArray, - arrayToString, - alterState, + each, + field, + fields, fn, fnIf, + index, + join, + lastReferenceValue, + log, + merge, + referencePath, + source, + sourceValue, + toArray, } from '@openfn/language-common'; diff --git a/packages/mojatax/ast.json b/packages/mojatax/ast.json index e1121dfa29..e3d051c22f 100644 --- a/packages/mojatax/ast.json +++ b/packages/mojatax/ast.json @@ -736,6 +736,55 @@ ] }, "valid": false + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/mojatax/src/Adaptor.js b/packages/mojatax/src/Adaptor.js index 28c6f3820b..a9644f8f70 100644 --- a/packages/mojatax/src/Adaptor.js +++ b/packages/mojatax/src/Adaptor.js @@ -45,7 +45,7 @@ export function execute(...operations) { return state => { return commonExecute( util.authorize, - ...operations + ...operations, )({ ...initialState, ...state, @@ -103,7 +103,7 @@ export function request(method, path, body, options = {}, callback = s => s) { { data: resolvedData, ...resolvedoptions, - } + }, ); return util.prepareNextState(state, response, callback); @@ -112,15 +112,16 @@ export function request(method, path, body, options = {}, callback = s => s) { export { combine, + cursor, dataPath, dataValue, dateFns, - cursor, each, field, fields, fn, lastReferenceValue, + log, merge, sourceValue, } from '@openfn/language-common'; diff --git a/packages/mongodb/ast.json b/packages/mongodb/ast.json index 88472a52e9..42e2507b54 100644 --- a/packages/mongodb/ast.json +++ b/packages/mongodb/ast.json @@ -660,6 +660,55 @@ ] }, "valid": true + }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true } ] } \ No newline at end of file diff --git a/packages/mongodb/src/Adaptor.js b/packages/mongodb/src/Adaptor.js index 2f373e39a3..6aae132028 100644 --- a/packages/mongodb/src/Adaptor.js +++ b/packages/mongodb/src/Adaptor.js @@ -29,7 +29,7 @@ export function execute(...operations) { return commonExecute( connect, ...operations, - disconnect + disconnect, )({ ...initialState, ...state }); }; } @@ -43,17 +43,19 @@ export function execute(...operations) { * @returns {State} */ function connect(state) { - const { clusterHostname, username, password, protocol = "mongodb+srv", options = { "retryWrites": true, "w": "majority" } } = state.configuration; - + const { + clusterHostname, + username, + password, + protocol = 'mongodb+srv', + options = { retryWrites: true, w: 'majority' }, + } = state.configuration; + const uri = `${protocol}://${encodeURIComponent( - username - )}:${encodeURIComponent( - password - )}@${clusterHostname}/test${ - Object.keys(options).length ? "?" : "" - }${ - encodeURIComponent(new URLSearchParams(options).toString()) - }`; + username, + )}:${encodeURIComponent(password)}@${clusterHostname}/test${ + Object.keys(options).length ? '?' : '' + }${encodeURIComponent(new URLSearchParams(options).toString())}`; const client = new MongoClient(uri, { useNewUrlParser: true }); @@ -114,7 +116,7 @@ export function insertDocuments(params) { state.client.close(); } else { console.log( - `Inserted ${documents.length} documents into the collection` + `Inserted ${documents.length} documents into the collection`, ); console.log(JSON.stringify(result, null, 2)); const nextState = composeNextState(state, result); @@ -213,15 +215,15 @@ export function updateDocument(params) { } else { console.log( `Updated a document matching ${JSON.stringify( - filter - )} in the collection.` + filter, + )} in the collection.`, ); console.log(JSON.stringify(result, null, 2)); const nextState = composeNextState(state, result); if (callback) resolve(callback(nextState)); resolve(nextState); } - } + }, ); }); } catch (error) { @@ -232,16 +234,17 @@ export function updateDocument(params) { } export { + alterState, combine, + dataPath, + dataValue, + each, field, fields, - sourceValue, fn, fnIf, - alterState, - each, - merge, - dataPath, - dataValue, lastReferenceValue, + log, + merge, + sourceValue, } from '@openfn/language-common'; diff --git a/packages/monnify/ast.json b/packages/monnify/ast.json index 35d215b3b5..0c23cf6613 100644 --- a/packages/monnify/ast.json +++ b/packages/monnify/ast.json @@ -1005,6 +1005,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/monnify/src/Adaptor.js b/packages/monnify/src/Adaptor.js index d2f445cb08..75c2eda34c 100644 --- a/packages/monnify/src/Adaptor.js +++ b/packages/monnify/src/Adaptor.js @@ -182,6 +182,7 @@ export { fnIf, group, lastReferenceValue, + log, map, merge, scrubEmojis, diff --git a/packages/motherduck/ast.json b/packages/motherduck/ast.json index 9e00fdb417..8e68d36af3 100644 --- a/packages/motherduck/ast.json +++ b/packages/motherduck/ast.json @@ -988,6 +988,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/motherduck/src/Adaptor.js b/packages/motherduck/src/Adaptor.js index 991e5e0ed9..0cc673e096 100644 --- a/packages/motherduck/src/Adaptor.js +++ b/packages/motherduck/src/Adaptor.js @@ -269,6 +269,7 @@ export function insert(table, records, options = {}) { export { alterState, arrayToString, + as, combine, cursor, dataPath, @@ -281,10 +282,10 @@ export { fnIf, group, lastReferenceValue, + log, map, merge, sourceValue, - as, } from '@openfn/language-common'; export { util }; diff --git a/packages/mpesa/ast.json b/packages/mpesa/ast.json index 4903230b92..264fd5cdf4 100644 --- a/packages/mpesa/ast.json +++ b/packages/mpesa/ast.json @@ -303,7 +303,7 @@ "tags": [ { "title": "example", - "description": "request(\"POST\", \"/mpesa/c2b/v1/registerurl\", \n {\n \"ShortCode\": 600426,\n \"ResponseType\": \"Completed\",\n \"ConfirmationURL\": \"https://mydomain.com/confirmation\",\n \"ValidationURL\": \"https://mydomain.com/validation\"\n });", + "description": "request(\"POST\", \"/mpesa/c2b/v1/registerurl\",\n {\n \"ShortCode\": 600426,\n \"ResponseType\": \"Completed\",\n \"ConfirmationURL\": \"https://mydomain.com/confirmation\",\n \"ValidationURL\": \"https://mydomain.com/validation\"\n });", "caption": "Register a URL to receive payment notifications" }, { @@ -933,6 +933,55 @@ }, "valid": false }, + { + "name": "log", + "params": [ + "args" + ], + "docs": { + "description": "Outputs a message, like calling `console.log`. Use this at the top level of your job code, but not inside callbacks.", + "tags": [ + { + "title": "public", + "description": null, + "type": null + }, + { + "title": "function", + "description": null, + "name": null + }, + { + "title": "example", + "description": "log('Patient List::', $.patients);", + "caption": "Log values from state" + }, + { + "title": "example", + "description": "fn((state) => {\n console.log(state.data);\n return state;\n})", + "caption": "Use console.log inside a callback or fn block" + }, + { + "title": "param", + "description": "A value or message to display in the logs", + "type": { + "type": "NameExpression", + "name": "any" + }, + "name": "args" + }, + { + "title": "returns", + "description": null, + "type": { + "type": "NameExpression", + "name": "Operation" + } + } + ] + }, + "valid": true + }, { "name": "as", "params": [ diff --git a/packages/mpesa/src/Adaptor.js b/packages/mpesa/src/Adaptor.js index 8b82a3a43e..d81291db18 100644 --- a/packages/mpesa/src/Adaptor.js +++ b/packages/mpesa/src/Adaptor.js @@ -19,7 +19,6 @@ import * as util from './Utils.js'; * @property {object} headers - An object of headers to append to the request. */ - /** * STKPush request data object * @typedef {Object} STKPushObject @@ -33,7 +32,6 @@ import * as util from './Utils.js'; * @property {string} TransactionDesc - Any additional information/comment that can be sent along with the request from you system. */ - /** * Initiate a STK pin prompt to a Safaricom mobile number. * @function @@ -55,10 +53,9 @@ import * as util from './Utils.js'; */ export function stkPush(data, options = {}) { return async state => { - const { short_code, pass_key } = state.configuration; - const timestamp = util.getTimestamp() + const timestamp = util.getTimestamp(); const password = short_code + pass_key + timestamp; @@ -72,17 +69,21 @@ export function stkPush(data, options = {}) { console.log('Initiating STK Push request...'); - const response = await util.request(state, 'POST', '/mpesa/stkpush/v1/processrequest', { ...options, body }) - return util.prepareNextState(state, response) - } + const response = await util.request( + state, + 'POST', + '/mpesa/stkpush/v1/processrequest', + { ...options, body }, + ); + return util.prepareNextState(state, response); + }; } - /** * Check transaction status data object. * @typedef {Object} TransactionStatusObject * @public - * @property {string} Initiator - The name of the initiator initiating the request. + * @property {string} Initiator - The name of the initiator initiating the request. * @property {string} SecurityCredential - Encrypted credential of the user getting transaction status. * @property {string} TransactionID - Unique identifier to identify a transaction on Mpesa. * @property {number} PartyA - Organization/MSISDN receiving the transaction. @@ -93,7 +94,6 @@ export function stkPush(data, options = {}) { * @property {string} Occassion - Optional parameter. */ - /** * Check the status of the transaction * @function @@ -117,7 +117,6 @@ export function stkPush(data, options = {}) { */ export function checkTransactionStatus(data, options = {}) { return async state => { - const { short_code, pass_key } = state.configuration; const timestamp = util.getTimestamp(); @@ -129,14 +128,19 @@ export function checkTransactionStatus(data, options = {}) { Password: Buffer.from(password).toString('base64'), Timestamp: timestamp, CommandID: 'TransactionStatusQuery', - ...data + ...data, }; console.log('Initiating check transaction request...'); - const response = await util.request(state, 'POST', '/mpesa/transactionstatus/v1/query', { ...options, body }); - return util.prepareNextState(state, response) - } + const response = await util.request( + state, + 'POST', + '/mpesa/transactionstatus/v1/query', + { ...options, body }, + ); + return util.prepareNextState(state, response); + }; } /** @@ -146,7 +150,7 @@ export function checkTransactionStatus(data, options = {}) { * @property {numeric} ShortCode - Usually, a unique number is tagged to an M-PESA pay bill/till number of the organization. * @property {string} ResponseType - This parameter specifies what is to happen if for any reason the validation URL is not reachable. Sample values: 'Canceled', 'Completed' * @property {URL} ConfirmationURL - This is the URL that receives the confirmation request from API upon payment completion. - * @property {URL} ValidationURL - This is the URL that receives the validation request from the API upon payment submission. + * @property {URL} ValidationURL - This is the URL that receives the validation request from the API upon payment submission. */ /** @@ -167,15 +171,18 @@ export function checkTransactionStatus(data, options = {}) { */ export function registerUrl(data, options) { return async state => { - console.log('Initiating register URL request...'); - const response = await util.request(state, 'POST', '/mpesa/c2b/v1/registerurl', { ...options, body: { ...data } }); - return util.prepareNextState(state, response) - } + const response = await util.request( + state, + 'POST', + '/mpesa/c2b/v1/registerurl', + { ...options, body: { ...data } }, + ); + return util.prepareNextState(state, response); + }; } - /** * Remit tax parameter definition * @typedef {Object} RemitTaxObject @@ -212,20 +219,24 @@ export function registerUrl(data, options) { */ export function remitTax(data, options = {}) { return async state => { - const body = { SenderIdentifierType: '4', RecieverIdentifierType: '4', PartyB: 572572, CommandID: 'PayTaxToKRA', ...data, - } + }; console.log('Initiating remit tax request...'); - const response = await util.request(state, 'POST', '/mpesa/b2b/v1/remittax', { ...options, body }); - return util.prepareNextState(state, response) - } + const response = await util.request( + state, + 'POST', + '/mpesa/b2b/v1/remittax', + { ...options, body }, + ); + return util.prepareNextState(state, response); + }; } /** @@ -242,7 +253,6 @@ export function remitTax(data, options = {}) { * @property {URL} ResultURL - A URL that will be used to send transaction results after processing. */ - /** * Pay for goods and services directly from your business account to a till number, merchant store number or Merchant HO * @function @@ -267,25 +277,29 @@ export function remitTax(data, options = {}) { */ export function buyGoods(data, options = {}) { return async state => { - const body = { CommandID: 'BusinessBuyGoods', SenderIdentifierType: '4', RecieverIdentifierType: '4', ...data, - } + }; console.log('Initiating buy goods request...'); - const response = await util.request(state, 'POST', '/mpesa/b2b/v1/paymentrequest', { ...options, body }); - return util.prepareNextState(state, response) - } + const response = await util.request( + state, + 'POST', + '/mpesa/b2b/v1/paymentrequest', + { ...options, body }, + ); + return util.prepareNextState(state, response); + }; } /** * Make a general HTTP request * @example