@simplysf/simply-sobject 1.4.9 → 1.6.0

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.
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  Apache License Version 2.0
2
2
 
3
- Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
3
+ Copyright (c) 2026, Clay Chipps.
4
4
  All rights reserved.
5
5
 
6
6
  Apache License
package/README.md CHANGED
@@ -332,3 +332,7 @@ A filter tree is either a **condition** or a **group**:
332
332
  | `filters` | `Array<Condition \| Group>` | One or more conditions or nested groups, combined per `logic`. |
333
333
 
334
334
  Conditions on `Field`, `CreatedById`, `CreatedDate`, or the parent lookup field are pushed into the underlying SOQL query; conditions on any other field (e.g. `OldValue`/`NewValue`) are applied client-side after the query runs.
335
+
336
+ ## License
337
+
338
+ Licensed under the [Apache-2.0](https://raw.githubusercontent.com/SimplySF/simply-node/main/LICENSE.txt) license.
@@ -16,6 +16,8 @@ export default class SObjectBackup extends SfCommand<SObjectBackupResult> {
16
16
  static readonly flags: {
17
17
  'output-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
18
  sobject: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
19
+ 'include-relationship-fields': import("@oclif/core/interfaces").BooleanFlag<boolean>;
20
+ 'additional-fields': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
21
  'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined>;
20
22
  'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org>;
21
23
  'flags-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
2
+ * Copyright (c) 2026, Clay Chipps.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ import { Messages } from '@salesforce/core';
18
18
  import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
19
19
  import { requireConnection, targetOrgFlags } from '@simplysf/simply-plugin-kit';
20
20
  import { ensureDirectory, queryRecords, timestampForFileName, writeRecordsToCsvFile } from '@simplysf/simply-core';
21
+ import { discoverRelationshipFields } from '../../../common/relationshipFields.js';
21
22
  Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
22
23
  const messages = Messages.loadMessages('@simplysf/simply-sobject', 'simply.sobject.backup');
23
24
  /**
@@ -42,6 +43,17 @@ export default class SObjectBackup extends SfCommand {
42
43
  char: 's',
43
44
  required: true,
44
45
  }),
46
+ 'include-relationship-fields': Flags.boolean({
47
+ summary: messages.getMessage('flags.include-relationship-fields.summary'),
48
+ description: messages.getMessage('flags.include-relationship-fields.description'),
49
+ default: false,
50
+ }),
51
+ 'additional-fields': Flags.string({
52
+ summary: messages.getMessage('flags.additional-fields.summary'),
53
+ description: messages.getMessage('flags.additional-fields.description'),
54
+ char: 'f',
55
+ multiple: true,
56
+ }),
45
57
  };
46
58
  /** @returns The output CSV path and the number of records written. */
47
59
  async run() {
@@ -52,11 +64,19 @@ export default class SObjectBackup extends SfCommand {
52
64
  const sobjectDescribe = await targetOrgConnection.describe(sobjectName);
53
65
  const queryableFields = sobjectDescribe.fields.map((field) => field.name);
54
66
  this.spinner.stop();
55
- const soql = `SELECT ${queryableFields.join(',')} FROM ${sobjectName}`;
67
+ let relationshipFields = [];
68
+ if (flags['include-relationship-fields']) {
69
+ this.spinner.start(messages.getMessage('info.discoveringRelationshipFields'));
70
+ relationshipFields = await discoverRelationshipFields(targetOrgConnection, sobjectDescribe.fields);
71
+ this.spinner.stop();
72
+ }
73
+ const additionalFields = flags['additional-fields'] ?? [];
74
+ const fieldsToQuery = [...new Set([...queryableFields, ...relationshipFields, ...additionalFields])];
75
+ const soql = `SELECT ${fieldsToQuery.join(',')} FROM ${sobjectName}`;
56
76
  const outputDir = ensureDirectory(flags['output-dir'] ?? '.');
57
77
  const outputPath = path.join(outputDir, `${sobjectName}_${timestampForFileName()}.csv`);
58
78
  this.spinner.start(messages.getMessage('info.exportingData', [sobjectName]));
59
- const { recordCount } = await writeRecordsToCsvFile(queryRecords(targetOrgConnection, soql), outputPath, queryableFields);
79
+ const { recordCount } = await writeRecordsToCsvFile(queryRecords(targetOrgConnection, soql), outputPath, fieldsToQuery);
60
80
  this.spinner.stop();
61
81
  this.info(messages.getMessage('info.complete', [recordCount, outputPath]));
62
82
  return { sobject: sobjectName, recordCount, path: outputPath };
@@ -1 +1 @@
1
- {"version":3,"file":"backup.js","sourceRoot":"","sources":["../../../../src/commands/simply/sobject/backup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEnH,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,uBAAuB,CAAC,CAAC;AAS5F;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAA8B;IAChE,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAA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,gBAAgB,CAAC,CAAC,CAAC,CAAC;QAErG,MAAM,IAAI,GAAG,UAAU,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,WAAW,EAAE,CAAC;QAErE,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,CAAC;QAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,WAAW,IAAI,oBAAoB,EAAE,MAAM,CAAC,CAAC;QAExF,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAE7E,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,qBAAqB,CACjD,YAAY,CAAC,mBAAmB,EAAE,IAAI,CAAC,EACvC,UAAU,EACV,aAAa,CACd,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAEpB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;QAE3E,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IACjE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
2
+ * Copyright (c) 2026, Clay Chipps.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
2
+ * Copyright (c) 2026, Clay Chipps.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
2
+ * Copyright (c) 2026, Clay Chipps.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
2
+ * Copyright (c) 2026, Clay Chipps.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
2
+ * Copyright (c) 2026, Clay Chipps.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
2
+ * Copyright (c) 2026, Clay Chipps.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -0,0 +1,18 @@
1
+ import type { Connection } from '@salesforce/core';
2
+ type SObjectField = Awaited<ReturnType<Connection['describe']>>['fields'][number];
3
+ /**
4
+ * Given an SObject's describe fields, discover the identifying fields of every parent it
5
+ * references through a single-target lookup or master-detail relationship, and return them as
6
+ * dot-notation relationship paths ready to add to a SOQL field list (e.g. `RecordTypeId` ->
7
+ * `RecordType.Name`, `RecordType.DeveloperName`).
8
+ *
9
+ * Describe calls for each distinct target object are deduplicated and fetched concurrently;
10
+ * `Connection#describe` already memoizes per-instance, so repeat calls for the same object name
11
+ * (including calls made elsewhere on the same connection) are cheap.
12
+ *
13
+ * @param connection - The org connection to describe relationship targets with.
14
+ * @param fields - The describe fields of the SObject being backed up.
15
+ * @returns Dot-notation relationship field paths, in no particular order.
16
+ */
17
+ export declare function discoverRelationshipFields(connection: Connection, fields: SObjectField[]): Promise<string[]>;
18
+ export {};
@@ -0,0 +1,64 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * @param field - A field from an SObject describe result.
18
+ * @returns Whether `field` is a single-target lookup/master-detail field that can be safely
19
+ * expanded into a dot-notation relationship path. Polymorphic references (e.g. `OwnerId`, which
20
+ * can point at `User` or `Group`) are excluded, since a single dotted path can't reliably select
21
+ * fields across more than one possible target type.
22
+ */
23
+ function isExpandableReferenceField(field) {
24
+ return field.type === 'reference' && Boolean(field.relationshipName) && field.referenceTo?.length === 1;
25
+ }
26
+ /**
27
+ * @param targetDescribe - The describe result of a relationship field's target SObject.
28
+ * @returns The target object's identifying field names: whichever field is flagged as its name
29
+ * field (e.g. `Name`), plus `DeveloperName` when present. For `RecordType`, this yields `Name`
30
+ * and `DeveloperName`; for most other objects, just `Name`.
31
+ */
32
+ function identifyingFieldNames(targetDescribe) {
33
+ return targetDescribe.fields
34
+ .filter((field) => field.nameField || field.name === 'DeveloperName')
35
+ .map((field) => field.name);
36
+ }
37
+ /**
38
+ * Given an SObject's describe fields, discover the identifying fields of every parent it
39
+ * references through a single-target lookup or master-detail relationship, and return them as
40
+ * dot-notation relationship paths ready to add to a SOQL field list (e.g. `RecordTypeId` ->
41
+ * `RecordType.Name`, `RecordType.DeveloperName`).
42
+ *
43
+ * Describe calls for each distinct target object are deduplicated and fetched concurrently;
44
+ * `Connection#describe` already memoizes per-instance, so repeat calls for the same object name
45
+ * (including calls made elsewhere on the same connection) are cheap.
46
+ *
47
+ * @param connection - The org connection to describe relationship targets with.
48
+ * @param fields - The describe fields of the SObject being backed up.
49
+ * @returns Dot-notation relationship field paths, in no particular order.
50
+ */
51
+ export async function discoverRelationshipFields(connection, fields) {
52
+ const referenceFields = fields.filter(isExpandableReferenceField);
53
+ const targetObjectNames = [...new Set(referenceFields.map((field) => field.referenceTo[0]))];
54
+ const targetDescribes = await Promise.all(targetObjectNames.map(async (objectName) => [objectName, await connection.describe(objectName)]));
55
+ const describeByObjectName = new Map(targetDescribes);
56
+ return referenceFields.flatMap((field) => {
57
+ const targetDescribe = describeByObjectName.get(field.referenceTo[0]);
58
+ if (!targetDescribe) {
59
+ return [];
60
+ }
61
+ return identifyingFieldNames(targetDescribe).map((fieldName) => `${field.relationshipName}.${fieldName}`);
62
+ });
63
+ }
64
+ //# sourceMappingURL=relationshipFields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationshipFields.js","sourceRoot":"","sources":["../../src/common/relationshipFields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH;;;;;;GAMG;AACH,SAAS,0BAA0B,CAAC,KAAmB;IACrD,OAAO,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,WAAW,EAAE,MAAM,KAAK,CAAC,CAAC;AAC1G,CAAC;AAED;;;;;GAKG;AACH,SAAS,qBAAqB,CAAC,cAA2D;IACxF,OAAO,cAAc,CAAC,MAAM;SACzB,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,CAAC;SACpE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,UAAsB,EAAE,MAAsB;IAC7F,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;IAElE,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9F,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,GAAG,CACvC,iBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,UAAU,EAAE,MAAM,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAU,CAAC,CAC1G,CAAC;IACF,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC;IAEtD,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACvC,MAAM,cAAc,GAAG,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,WAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QAEvE,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO,qBAAqB,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,gBAAiB,IAAI,SAAS,EAAE,CAAC,CAAC;IAC7G,CAAC,CAAC,CAAC;AACL,CAAC"}
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
2
+ * Copyright (c) 2026, Clay Chipps.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
2
+ * Copyright (c) 2026, Clay Chipps.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
2
+ * Copyright (c) 2026, Clay Chipps.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -22,16 +22,40 @@ Output directory
22
22
 
23
23
  The directory to save the backup CSV file to. Defaults to the current directory.
24
24
 
25
+ # flags.include-relationship-fields.summary
26
+
27
+ Include parent relationship fields
28
+
29
+ # flags.include-relationship-fields.description
30
+
31
+ For every lookup/master-detail field, describe its parent SObject and include its identifying fields (e.g. RecordTypeId includes RecordType.Name and RecordType.DeveloperName). Polymorphic relationship fields, such as OwnerId, are skipped.
32
+
33
+ # flags.additional-fields.summary
34
+
35
+ Additional fields to include
36
+
37
+ # flags.additional-fields.description
38
+
39
+ Extra field API names to include in the query, on top of the SObject's own fields and any fields discovered via --include-relationship-fields. Useful for fields --include-relationship-fields won't discover, such as multi-hop relationship paths (e.g. Owner.Manager.Name) or fields through a polymorphic relationship. Fields already included are not duplicated.
40
+
25
41
  # examples
26
42
 
27
43
  - <%= config.bin %> <%= command.id %> --target-org myOrg --sobject Account
28
44
 
29
45
  - <%= config.bin %> <%= command.id %> --target-org myOrg --sobject Custom_Object__c --output-dir backups
30
46
 
47
+ - <%= config.bin %> <%= command.id %> --target-org myOrg --sobject Account --include-relationship-fields
48
+
49
+ - <%= config.bin %> <%= command.id %> --target-org myOrg --sobject Account --additional-fields Owner.Manager.Name --additional-fields Parent.Owner.Email
50
+
31
51
  # info.describingSobject
32
52
 
33
53
  Describing SObject: %s...
34
54
 
55
+ # info.discoveringRelationshipFields
56
+
57
+ Discovering relationship fields...
58
+
35
59
  # info.exportingData
36
60
 
37
61
  Exporting data for %s...
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@simplysf/simply-sobject",
3
3
  "description": "Utilities for working with SObjects",
4
- "version": "1.4.9",
4
+ "version": "1.6.0",
5
5
  "author": "@ClayChipps",
6
6
  "homepage": "https://github.com/SimplySF/simply-node",
7
7
  "bugs": "https://github.com/SimplySF/simply-node/issues",
@@ -65,9 +65,9 @@
65
65
  "@salesforce/core": "^8.30.0",
66
66
  "@salesforce/kit": "^3.2.6",
67
67
  "@salesforce/sf-plugins-core": "^12.2.16",
68
- "@simplysf/simply-core": "^1.1.13",
69
- "@simplysf/simply-plugin-kit": "^1.0.1",
70
- "@simplysf/simply-report": "^1.0.1",
68
+ "@simplysf/simply-core": "^1.1.17",
69
+ "@simplysf/simply-plugin-kit": "^1.0.4",
70
+ "@simplysf/simply-report": "^1.0.3",
71
71
  "handlebars": "^4.7.9",
72
72
  "zod": "^4.1.12"
73
73
  },
@@ -90,7 +90,7 @@
90
90
  "readme": "oclif readme --no-aliases",
91
91
  "test": "wireit",
92
92
  "test:coverage": "vitest run --coverage --project simply-sobject",
93
- "test:nuts": "vitest run --config vitest.nuts.config.ts --project simply-sobject",
93
+ "test:nuts": "vitest run --config ../../vitest.nuts.config.ts --project simply-sobject",
94
94
  "test:only": "wireit",
95
95
  "test:watch": "vitest watch --project simply-sobject"
96
96
  },
@@ -215,5 +215,5 @@
215
215
  "output": []
216
216
  }
217
217
  },
218
- "gitHead": "8e11d2f2909c7b569993fb8d9a12f3ba27498186"
218
+ "gitHead": "c1134ddedb7cd88cfdd28e5e9596c2d28028b2f3"
219
219
  }