@render-lab/tasks-salesforce 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -10
  3. package/package.json +12 -5
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Render Lab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -29,6 +29,8 @@ import {
29
29
  } from "@render-lab/tasks-salesforce";
30
30
  ```
31
31
 
32
+ Every snippet below runs inside one of your own tasks, where `ctx` is the run context the SDK passes in as the first argument.
33
+
32
34
  Importing any symbol registers all 12 `salesforce.*` tasks with the Workflows `TaskRegistry`.
33
35
 
34
36
  ## Tasks
@@ -68,7 +70,7 @@ Both variables are **required** and read **lazily on the first task call** (neve
68
70
  Prefer `upsertRecord` over `createRecord` in workflows. Keyed on an external ID field, an upsert converges on the same record no matter how many times it replays, so it retries safely where a create cannot. The port maps the HTTP status: **201** means the record was created, **204** means it was updated — that flag rides back on `RecordMutationResult.created`.
69
71
 
70
72
  ```ts
71
- const result = await upsertRecord({
73
+ const result = await ctx.run(upsertRecord, {
72
74
  object: "Account",
73
75
  externalIdField: "ExternalId__c",
74
76
  externalId: "acme-42",
@@ -82,10 +84,10 @@ const result = await upsertRecord({
82
84
  `queryRecords` takes **exactly one** of `soql` (first page) or `nextRecordsUrl` (later pages). Salesforce returns an opaque relative `nextRecordsUrl` while `done` is `false`; follow it until it is `null`:
83
85
 
84
86
  ```ts
85
- let page = await queryRecords({ soql: "SELECT Id, Name FROM Account" });
87
+ let page = await ctx.run(queryRecords, { soql: "SELECT Id, Name FROM Account" });
86
88
  handle(page.records);
87
89
  while (!page.done && page.nextRecordsUrl) {
88
- page = await queryRecords({ nextRecordsUrl: page.nextRecordsUrl });
90
+ page = await ctx.run(queryRecords, { nextRecordsUrl: page.nextRecordsUrl });
89
91
  handle(page.records);
90
92
  }
91
93
  ```
@@ -95,7 +97,7 @@ while (!page.done && page.nextRecordsUrl) {
95
97
  `submitBulkIngest` performs the full create → upload CSV → close (`state: "UploadComplete"`) sequence in one task and returns a `BulkJobRef`. `awaitBulkJob` blocks until the job reaches a terminal state, then you fetch each result category and, if needed, abort:
96
98
 
97
99
  ```ts
98
- const ref = await submitBulkIngest({
100
+ const ref = await ctx.run(submitBulkIngest, {
99
101
  object: "Contact",
100
102
  operation: "upsert",
101
103
  externalIdFieldName: "ExternalId__c", // required only for upsert
@@ -103,16 +105,16 @@ const ref = await submitBulkIngest({
103
105
  });
104
106
 
105
107
  // Blocks (poll-by-throwing) until JobComplete; throws terminally on Aborted/Failed.
106
- const job = await awaitBulkJob({ jobId: ref.id, kind: "ingest" });
108
+ const job = await ctx.run(awaitBulkJob, { jobId: ref.id, kind: "ingest" });
107
109
 
108
110
  for (const resultType of ["successful", "failed", "unprocessed"] as const) {
109
- const results = await getBulkResults({ jobId: ref.id, kind: "ingest", resultType });
111
+ const results = await ctx.run(getBulkResults, { jobId: ref.id, kind: "ingest", resultType });
110
112
  handleCsv(results.csv);
111
113
  }
112
114
 
113
115
  // Recovery: if submitBulkIngest throws after creating the job, its message
114
116
  // carries the job ID so you can inspect or abort it:
115
- await cancelBulkJob({ jobId: ref.id, kind: "ingest" });
117
+ await ctx.run(cancelBulkJob, { jobId: ref.id, kind: "ingest" });
116
118
  ```
117
119
 
118
120
  `submitBulkIngest` rejects a UTF-8 CSV payload larger than 4 MB before any network I/O — split it into smaller batches.
@@ -122,12 +124,12 @@ await cancelBulkJob({ jobId: ref.id, kind: "ingest" });
122
124
  `submitBulkQuery` submits the job (operation defaults to `"query"`; use `"queryAll"` to include archived/deleted rows). Await it, then fetch **bounded** CSV pages using the opaque locator:
123
125
 
124
126
  ```ts
125
- const ref = await submitBulkQuery({ soql: "SELECT Id, Name FROM Account" });
126
- await awaitBulkJob({ jobId: ref.id, kind: "query" });
127
+ const ref = await ctx.run(submitBulkQuery, { soql: "SELECT Id, Name FROM Account" });
128
+ await ctx.run(awaitBulkJob, { jobId: ref.id, kind: "query" });
127
129
 
128
130
  let locator: string | undefined = undefined;
129
131
  do {
130
- const results = await getBulkResults({
132
+ const results = await ctx.run(getBulkResults, {
131
133
  jobId: ref.id,
132
134
  kind: "query",
133
135
  resultType: "query",
package/package.json CHANGED
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "name": "@render-lab/tasks-salesforce",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Durable Salesforce REST and Bulk API 2.0 tasks for Render Workflows.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/render-lab/render-tasks.git",
9
+ "directory": "packages/tasks-salesforce"
10
+ },
11
+ "homepage": "https://github.com/render-lab/render-tasks#readme",
5
12
  "type": "module",
6
13
  "main": "./dist/index.js",
7
14
  "types": "./dist/index.d.ts",
@@ -19,17 +26,17 @@
19
26
  "dist"
20
27
  ],
21
28
  "peerDependencies": {
22
- "@renderinc/sdk": "1.0.0"
29
+ "@renderinc/sdk": "^1.0.0"
23
30
  },
24
31
  "dependencies": {
25
- "@render-lab/tasks-core": "0.2.0"
32
+ "@render-lab/tasks-core": "0.3.1"
26
33
  },
27
34
  "devDependencies": {
28
- "@renderinc/sdk": "1.0.0",
35
+ "@renderinc/sdk": "1.11.0",
29
36
  "@types/node": "^26.1.1",
30
37
  "typescript": "^7.0.2",
31
38
  "vitest": "^4.1.10",
32
- "@render-lab/test-utils": "0.1.0"
39
+ "@render-lab/test-utils": "0.1.1"
33
40
  },
34
41
  "scripts": {
35
42
  "build": "tsc -p tsconfig.json",