Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .changeset/proud-melons-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
'@openfn/language-salesforce': major
---

- Add `bulk1` functions for bulk insert, update, upsert, and destroy
- Removed `bulk()` function in favor of explicit `bulk1` and `bulk2` APIs
- Removed `bulkQuery()` function in favor of `bulk1.query()` and `bulk2.query()`

# Migration Guide

The legacy `bulk()` and `bulkQuery()` functions have been replaced with `bulk1`
and `bulk2` APIs that provide better control and clarity:

## Bulk Operations

**Before:**

````javascript
bulk('Account', 'insert', records, options);
bulk('Account', 'update', records, options);
bulk('Account', 'upsert', records, { extIdField: 'Id__c' });
bulk('Account', 'delete', records, options);
```
**After:**

```javascript
// Bulk API 1.0 - More reliable, supports failOnError
bulk1.insert('Account', records, { failOnError: true });
bulk1.update('Account', records, { batchSize: 5000 });
bulk1.upsert('Account', 'Id__c', records);
bulk1.destroy('Account', records);

// Bulk API 2.0 - Faster performance, simplified error handling
bulk2.insert('Account', records);
bulk2.update('Account', records);
bulk2.upsert('Account', 'Id__c', records);
bulk2.destroy('Account', records);
````

### Bulk Queries

**Before**

```js
bulkQuery('select Id, Name from Account');
```

**After**

```js
bulk1.query('select Id, Name from Account');
// or
bulk2.query('select Id, Name from Account');
```
162 changes: 0 additions & 162 deletions packages/salesforce/ast.json
Original file line number Diff line number Diff line change
@@ -1,167 +1,5 @@
{
"operations": [
{
"name": "bulk",
"params": [
"sObjectName",
"operation",
"records",
"options"
],
"docs": {
"description": "Create and execute a bulk job. Nested relationships will be flattened to dot notation automatically.\nThis function uses {@link https://sforce.co/4fDLJnk Bulk API},\nwhich is subject to {@link https://sforce.co/4b6kn6z rate limits}.",
"tags": [
{
"title": "public",
"description": null,
"type": null
},
{
"title": "example",
"description": "bulk(\n \"Patient__c\",\n \"insert\",\n (state) => state.patients.map((x) => ({ Age__c: x.age, Name: x.name })),\n { failOnError: true }\n);",
"caption": "Bulk insert"
},
{
"title": "example",
"description": "bulk(\n \"vera__Beneficiary__c\",\n \"upsert\",\n [\n {\n vera__Reporting_Period__c: 2023,\n vera__Geographic_Area__c: \"Uganda\",\n \"vera__Indicator__r.vera__ExtId__c\": 1001,\n vera__Result_UID__c: \"1001_2023_Uganda\",\n },\n ],\n { extIdField: \"vera__Result_UID__c\" }\n);",
"caption": "Bulk upsert"
},
{
"title": "example",
"description": "bulk(\n \"vera__Beneficiary__c\",\n \"upsert\",\n [\n {\n vera__Reporting_Period__c: 2023,\n \"vera_Project\": {\n \"Metrics_ID__c\": \"jfh5LAnxu1i4na\"\n }\n },\n ],\n { extIdField: \"vera__Result_UID__c\" }\n);",
"caption": "Bulk upsert with a nested relationship"
},
{
"title": "example",
"description": "fn((state) => {\n state.accounts = state.data.map((a) => ({ Id: a.id, Name: a.name }));\n return state;\n});\nbulk(\"Account\", \"update\", $.accounts, { failOnError: true });",
"caption": "Bulk update Account records using a lazy state reference"
},
{
"title": "function",
"description": null,
"name": null
},
{
"title": "param",
"description": "API name of the sObject.",
"type": {
"type": "NameExpression",
"name": "string"
},
"name": "sObjectName"
},
{
"title": "param",
"description": "The bulk operation to be performed.Eg `insert`, `update` or `upsert`",
"type": {
"type": "NameExpression",
"name": "string"
},
"name": "operation"
},
{
"title": "param",
"description": "an array of records, or a function which returns an array.",
"type": {
"type": "NameExpression",
"name": "array"
},
"name": "records"
},
{
"title": "param",
"description": "Options to configure the request. In addition to these, you can pass any of the options supported by the {@link https://bit.ly/41tyvVU jsforce API}.",
"type": {
"type": "OptionalType",
"expression": {
"type": "NameExpression",
"name": "BulkOptions"
}
},
"name": "options"
},
{
"title": "state",
"description": "{SalesforceResultState}"
},
{
"title": "returns",
"description": null,
"type": {
"type": "NameExpression",
"name": "Operation"
}
}
]
},
"valid": true
},
{
"name": "bulkQuery",
"params": [
"query",
"options"
],
"docs": {
"description": "Execute an SOQL Bulk Query.\nThis function query large data sets and reduce the number of API requests.\n`bulkQuery()` uses {@link https://sforce.co/4azgczz Bulk API v2.0 Query} which is available in API version 47.0 and later.\nThis API is subject to {@link https://sforce.co/4b6kn6z rate limits}.",
"tags": [
{
"title": "public",
"description": null,
"type": null
},
{
"title": "example",
"description": "bulkQuery(`SELECT Id FROM Patient__c WHERE Health_ID__c = '${$.data.healthId}'`);",
"caption": "Bulk query patient records where \"Health_ID__c\" is equal to the value in \"state.data.healthId\""
},
{
"title": "example",
"description": "bulkQuery(\n (state) =>\n `SELECT Id FROM Patient__c WHERE Health_ID__c = '${state.data.field1}'`,\n { pollTimeout: 10000, pollInterval: 6000 }\n);",
"caption": "Bulk query with custom polling options"
},
{
"title": "function",
"description": null,
"name": null
},
{
"title": "param",
"description": "A query string.",
"type": {
"type": "NameExpression",
"name": "string"
},
"name": "query"
},
{
"title": "param",
"description": "Options passed to the bulk api.",
"type": {
"type": "OptionalType",
"expression": {
"type": "NameExpression",
"name": "BulkQueryOptions"
}
},
"name": "options"
},
{
"title": "state",
"description": "{SalesforceState}"
},
{
"title": "returns",
"description": null,
"type": {
"type": "NameExpression",
"name": "Operation"
}
}
]
},
"valid": true
},
{
"name": "create",
"params": [
Expand Down
Loading