@simplysf/simply-sobject 1.0.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.
@@ -0,0 +1,19 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ export type SObjectBackupResult = {
3
+ sobject: string;
4
+ recordCount: number;
5
+ path: string;
6
+ };
7
+ export default class SObjectBackup extends SfCommand<SObjectBackupResult> {
8
+ static readonly summary: string;
9
+ static readonly description: string;
10
+ static readonly examples: string[];
11
+ static readonly flags: {
12
+ 'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ 'output-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ sobject: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
15
+ 'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
16
+ 'flags-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ };
18
+ run(): Promise<SObjectBackupResult>;
19
+ }
@@ -0,0 +1,92 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
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
+ /* eslint-disable no-await-in-loop */
17
+ import fs from 'node:fs';
18
+ import path from 'node:path';
19
+ import { createObjectCsvWriter } from 'csv-writer';
20
+ import { Messages } from '@salesforce/core';
21
+ import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
22
+ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
23
+ const messages = Messages.loadMessages('@simplysf/simply-sobject', 'simply.sobject.backup');
24
+ const BATCH_SIZE = 500;
25
+ export default class SObjectBackup extends SfCommand {
26
+ static summary = messages.getMessage('summary');
27
+ static description = messages.getMessage('description');
28
+ static examples = messages.getMessages('examples');
29
+ static flags = {
30
+ ...SfCommand.baseFlags,
31
+ 'api-version': Flags.orgApiVersion(),
32
+ 'output-dir': Flags.directory({
33
+ summary: messages.getMessage('flags.output-dir.summary'),
34
+ description: messages.getMessage('flags.output-dir.description'),
35
+ char: 'd',
36
+ }),
37
+ sobject: Flags.string({
38
+ summary: messages.getMessage('flags.sobject.summary'),
39
+ description: messages.getMessage('flags.sobject.description'),
40
+ char: 's',
41
+ required: true,
42
+ }),
43
+ 'target-org': Flags.requiredOrg(),
44
+ };
45
+ async run() {
46
+ const { flags } = await this.parse(SObjectBackup);
47
+ const targetOrgConnection = flags['target-org']?.getConnection(flags['api-version']);
48
+ if (!targetOrgConnection) {
49
+ throw messages.createError('error.targetOrgConnectionFailed');
50
+ }
51
+ const sobjectName = flags.sobject;
52
+ this.spinner.start(messages.getMessage('info.describingSobject', [sobjectName]));
53
+ const sobjectDescribe = await targetOrgConnection.describe(sobjectName);
54
+ const queryableFields = sobjectDescribe.fields.map((field) => field.name);
55
+ this.spinner.stop();
56
+ const soql = `SELECT ${queryableFields.join(',')} FROM ${sobjectName}`;
57
+ const outputDir = flags['output-dir'] ?? '.';
58
+ if (!fs.existsSync(outputDir)) {
59
+ fs.mkdirSync(outputDir, { recursive: true });
60
+ }
61
+ const outputPath = path.join(outputDir, `${sobjectName}_${buildTimestamp()}.csv`);
62
+ const csvWriter = createObjectCsvWriter({
63
+ path: outputPath,
64
+ header: queryableFields.map((field) => ({ id: field, title: field })),
65
+ });
66
+ this.spinner.start(messages.getMessage('info.exportingData', [sobjectName]));
67
+ const recordStream = await targetOrgConnection.bulk2.query(soql);
68
+ let recordCount = 0;
69
+ let batch = [];
70
+ for await (const record of recordStream) {
71
+ batch.push(record);
72
+ recordCount++;
73
+ if (batch.length >= BATCH_SIZE) {
74
+ await csvWriter.writeRecords(batch);
75
+ batch = [];
76
+ this.spinner.status = `${recordCount}`;
77
+ }
78
+ }
79
+ if (batch.length > 0) {
80
+ await csvWriter.writeRecords(batch);
81
+ }
82
+ this.spinner.stop();
83
+ this.info(messages.getMessage('info.complete', [recordCount, outputPath]));
84
+ return { sobject: sobjectName, recordCount, path: outputPath };
85
+ }
86
+ }
87
+ function buildTimestamp() {
88
+ const now = new Date();
89
+ const pad = (n) => n.toString().padStart(2, '0');
90
+ return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}_${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
91
+ }
92
+ //# sourceMappingURL=backup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup.js","sourceRoot":"","sources":["../../../../src/commands/simply/sobject/backup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,qCAAqC;AACrC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAE/D,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,uBAAuB,CAAC,CAAC;AAE5F,MAAM,UAAU,GAAG,GAAG,CAAC;AAQvB,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAA8B;IAChE,MAAM,CAAU,O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,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ export type SObjectDeduplicateResult = {
3
+ primaryObjectApiName: string;
4
+ totalRecords: number;
5
+ duplicateCount: number;
6
+ uniqueCount: number;
7
+ deleteFile: string;
8
+ uniqueFile: string;
9
+ modifiedFiles: string[];
10
+ };
11
+ export default class SObjectDeduplicate extends SfCommand<SObjectDeduplicateResult> {
12
+ static readonly summary: string;
13
+ static readonly description: string;
14
+ static readonly examples: string[];
15
+ static readonly flags: {
16
+ 'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ config: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
18
+ 'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
19
+ 'output-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ 'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
21
+ 'flags-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
+ };
23
+ run(): Promise<SObjectDeduplicateResult>;
24
+ }
@@ -0,0 +1,199 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
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
+ /* eslint-disable no-await-in-loop */
17
+ import fs from 'node:fs';
18
+ import path from 'node:path';
19
+ import { createObjectCsvWriter } from 'csv-writer';
20
+ import { Messages } from '@salesforce/core';
21
+ import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
22
+ import { DeduplicateConfigSchema } from '../../../schemas/deduplicate/deduplicateConfig.js';
23
+ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
24
+ const messages = Messages.loadMessages('@simplysf/simply-sobject', 'simply.sobject.deduplicate');
25
+ async function deduplicateAssociatedObject(options) {
26
+ const { connection, objectName, lookupFields, uniquePrimaryObjectMap, primaryObjectCompositeKeyFields, outputDir } = options;
27
+ const fieldsToQuery = [...lookupFields];
28
+ lookupFields.forEach((lookupField) => {
29
+ primaryObjectCompositeKeyFields.forEach((compositeKeyField) => {
30
+ fieldsToQuery.push(`${lookupField.replace('__c', '__r')}.${compositeKeyField}`);
31
+ });
32
+ });
33
+ const recordStream = await connection.bulk2.query(`SELECT Id,${fieldsToQuery.join(',')} FROM ${objectName}`);
34
+ const modifiedFile = path.join(outputDir, `${objectName}_Modified.csv`);
35
+ const columns = ['Id', ...lookupFields];
36
+ const writer = createObjectCsvWriter({ path: modifiedFile, header: columns.map((c) => ({ id: c, title: c })) });
37
+ for await (const record of recordStream) {
38
+ const associatedRecord = record;
39
+ const modifiedRecord = {};
40
+ for (const lookupField of lookupFields) {
41
+ if (!associatedRecord[lookupField]) {
42
+ continue;
43
+ }
44
+ let compositeKey = '';
45
+ for (const compositeKeyField of primaryObjectCompositeKeyFields) {
46
+ const objectKey = `${lookupField.replace('__c', '__r')}.${compositeKeyField}`;
47
+ compositeKey += `${String(associatedRecord[objectKey] ?? '')}_`;
48
+ }
49
+ compositeKey = compositeKey.slice(0, -1);
50
+ const uniqueRecordId = uniquePrimaryObjectMap.get(compositeKey);
51
+ if (uniqueRecordId === associatedRecord[lookupField]) {
52
+ continue;
53
+ }
54
+ modifiedRecord.Id = associatedRecord.Id;
55
+ modifiedRecord[lookupField] = uniqueRecordId;
56
+ }
57
+ if (modifiedRecord.Id) {
58
+ await writer.writeRecords([modifiedRecord]);
59
+ }
60
+ }
61
+ return modifiedFile;
62
+ }
63
+ export default class SObjectDeduplicate extends SfCommand {
64
+ static summary = messages.getMessage('summary');
65
+ static description = messages.getMessage('description');
66
+ static examples = messages.getMessages('examples');
67
+ static flags = {
68
+ ...SfCommand.baseFlags,
69
+ 'api-version': Flags.orgApiVersion(),
70
+ config: Flags.file({
71
+ summary: messages.getMessage('flags.config.summary'),
72
+ description: messages.getMessage('flags.config.description'),
73
+ char: 'c',
74
+ exists: true,
75
+ required: true,
76
+ }),
77
+ 'dry-run': Flags.boolean({
78
+ summary: messages.getMessage('flags.dry-run.summary'),
79
+ description: messages.getMessage('flags.dry-run.description'),
80
+ default: false,
81
+ }),
82
+ 'output-dir': Flags.directory({
83
+ summary: messages.getMessage('flags.output-dir.summary'),
84
+ description: messages.getMessage('flags.output-dir.description'),
85
+ }),
86
+ 'target-org': Flags.requiredOrg(),
87
+ };
88
+ async run() {
89
+ const { flags } = await this.parse(SObjectDeduplicate);
90
+ const targetOrgConnection = flags['target-org']?.getConnection(flags['api-version']);
91
+ if (!targetOrgConnection) {
92
+ throw messages.createError('error.targetOrgConnectionFailed');
93
+ }
94
+ this.spinner.start(messages.getMessage('info.readingConfig'));
95
+ const configContent = fs.readFileSync(flags.config, 'utf-8');
96
+ const parsed = DeduplicateConfigSchema.safeParse(JSON.parse(configContent));
97
+ if (!parsed.success) {
98
+ throw messages.createError('error.invalidConfig', [parsed.error.message]);
99
+ }
100
+ const config = parsed.data;
101
+ this.spinner.stop();
102
+ const { primaryObjectApiName, primaryObjectFilter, primaryObjectCompositeKeyField, primaryObjectFields, primaryObjectCompositeKeyFields, associatedObjects, } = config;
103
+ const outputDir = flags['output-dir'] ?? path.join('temp', primaryObjectApiName);
104
+ if (fs.existsSync(outputDir)) {
105
+ fs.rmSync(outputDir, { recursive: true, force: true });
106
+ }
107
+ fs.mkdirSync(outputDir, { recursive: true });
108
+ const deleteFile = path.join(outputDir, `${primaryObjectApiName}_Delete.csv`);
109
+ const uniqueFile = path.join(outputDir, `${primaryObjectApiName}_Unique.csv`);
110
+ const columns = ['Id', primaryObjectCompositeKeyField];
111
+ const deleteWriter = createObjectCsvWriter({
112
+ path: deleteFile,
113
+ header: columns.map((c) => ({ id: c, title: c })),
114
+ });
115
+ const uniqueWriter = createObjectCsvWriter({
116
+ path: uniqueFile,
117
+ header: columns.map((c) => ({ id: c, title: c })),
118
+ });
119
+ this.spinner.start(messages.getMessage('info.queryingPrimary', [primaryObjectApiName]));
120
+ const whereClause = primaryObjectFilter ? `WHERE ${primaryObjectFilter}` : '';
121
+ const soql = `SELECT ${[...primaryObjectFields, ...primaryObjectCompositeKeyFields].join(',')} FROM ${primaryObjectApiName} ${whereClause} ORDER BY CreatedDate ASC`;
122
+ const primaryRecordStream = await targetOrgConnection.bulk2.query(soql);
123
+ let totalRecords = 0;
124
+ let duplicateCount = 0;
125
+ const uniquePrimaryObjectMap = new Map();
126
+ for await (const record of primaryRecordStream) {
127
+ totalRecords++;
128
+ const primaryRecord = record;
129
+ let compositeKey = '';
130
+ const nullCompositeKeyFields = [];
131
+ for (const field of primaryObjectCompositeKeyFields) {
132
+ const value = primaryRecord[field];
133
+ compositeKey += `${String(value ?? '')}_`;
134
+ if (!value) {
135
+ nullCompositeKeyFields.push(field);
136
+ }
137
+ }
138
+ compositeKey = compositeKey.slice(0, -1);
139
+ const recordId = primaryRecord.Id;
140
+ if (nullCompositeKeyFields.length > 0) {
141
+ this.warn(messages.getMessage('warning.blankCompositeKey', [recordId, compositeKey, nullCompositeKeyFields.join(',')]));
142
+ }
143
+ if (uniquePrimaryObjectMap.has(compositeKey)) {
144
+ duplicateCount++;
145
+ await deleteWriter.writeRecords([{ Id: recordId, [primaryObjectCompositeKeyField]: compositeKey }]);
146
+ continue;
147
+ }
148
+ await uniqueWriter.writeRecords([{ Id: recordId, [primaryObjectCompositeKeyField]: compositeKey }]);
149
+ uniquePrimaryObjectMap.set(compositeKey, recordId);
150
+ }
151
+ this.spinner.stop();
152
+ this.info(messages.getMessage('info.duplicatesFound', [duplicateCount]));
153
+ const modifiedFiles = [];
154
+ if (duplicateCount > 0 && !flags['dry-run']) {
155
+ this.spinner.start(messages.getMessage('info.calculatingReplacements'));
156
+ const associatedObjectEntries = Object.entries(associatedObjects);
157
+ const results = await Promise.allSettled(associatedObjectEntries.map(([objectName, lookupFields]) => deduplicateAssociatedObject({
158
+ connection: targetOrgConnection,
159
+ objectName,
160
+ lookupFields,
161
+ uniquePrimaryObjectMap,
162
+ primaryObjectCompositeKeyFields,
163
+ outputDir,
164
+ })));
165
+ results.forEach((result, index) => {
166
+ const [objectName] = associatedObjectEntries[index];
167
+ if (result.status === 'fulfilled') {
168
+ modifiedFiles.push(result.value);
169
+ }
170
+ else {
171
+ this.warn(messages.getMessage('warning.associatedObjectFailed', [objectName, String(result.reason)]));
172
+ }
173
+ });
174
+ this.spinner.stop();
175
+ }
176
+ const result = {
177
+ primaryObjectApiName,
178
+ totalRecords,
179
+ duplicateCount,
180
+ uniqueCount: uniquePrimaryObjectMap.size,
181
+ deleteFile,
182
+ uniqueFile,
183
+ modifiedFiles,
184
+ };
185
+ this.table({
186
+ data: [
187
+ { Metric: 'Total Records', Value: String(result.totalRecords) },
188
+ { Metric: 'Duplicates Found', Value: String(result.duplicateCount) },
189
+ { Metric: 'Unique Records', Value: String(result.uniqueCount) },
190
+ ],
191
+ columns: [
192
+ { key: 'Metric', name: 'METRIC' },
193
+ { key: 'Value', name: 'VALUE' },
194
+ ],
195
+ });
196
+ return result;
197
+ }
198
+ }
199
+ //# sourceMappingURL=deduplicate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deduplicate.js","sourceRoot":"","sources":["../../../../src/commands/simply/sobject/deduplicate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,qCAAqC;AACrC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAA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CAAC,CAAC;YAEH,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACtB,CAAC;QAED,MAAM,MAAM,GAA6B;YACvC,oBAAoB;YACpB,YAAY;YACZ,cAAc;YACd,WAAW,EAAE,sBAAsB,CAAC,IAAI;YACxC,UAAU;YACV,UAAU;YACV,aAAa;SACd,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC;YACT,IAAI,EAAE;gBACJ,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE;gBAC/D,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;gBACpE,EAAE,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE;aAChE;YACD,OAAO,EAAE;gBACP,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACjC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;aAChC;SACF,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
package/lib/index.js ADDED
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
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
+ export default {};
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,eAAe,EAAE,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ export declare const DeduplicateConfigSchema: z.ZodObject<{
3
+ primaryObjectApiName: z.ZodString;
4
+ primaryObjectFilter: z.ZodOptional<z.ZodString>;
5
+ primaryObjectCompositeKeyField: z.ZodString;
6
+ primaryObjectFields: z.ZodArray<z.ZodString>;
7
+ primaryObjectCompositeKeyFields: z.ZodArray<z.ZodString>;
8
+ associatedObjects: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
9
+ }, z.core.$strip>;
10
+ export type DeduplicateConfig = z.infer<typeof DeduplicateConfigSchema>;
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
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
+ import { z } from 'zod';
17
+ export const DeduplicateConfigSchema = z.object({
18
+ primaryObjectApiName: z.string(),
19
+ primaryObjectFilter: z.string().optional(),
20
+ primaryObjectCompositeKeyField: z.string(),
21
+ primaryObjectFields: z.array(z.string()),
22
+ primaryObjectCompositeKeyFields: z.array(z.string()).min(1),
23
+ associatedObjects: z.record(z.string(), z.array(z.string())),
24
+ });
25
+ //# sourceMappingURL=deduplicateConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deduplicateConfig.js","sourceRoot":"","sources":["../../../src/schemas/deduplicate/deduplicateConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE;IAChC,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1C,8BAA8B,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1C,mBAAmB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACxC,+BAA+B,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3D,iBAAiB,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;CAC7D,CAAC,CAAC"}
@@ -0,0 +1,45 @@
1
+ # summary
2
+
3
+ Back up SObject data to a CSV file.
4
+
5
+ # description
6
+
7
+ Describes the given SObject, queries every field via the Bulk API, and writes the results to a timestamped CSV file.
8
+
9
+ # flags.sobject.summary
10
+
11
+ SObject API name
12
+
13
+ # flags.sobject.description
14
+
15
+ The API name of the SObject to back up.
16
+
17
+ # flags.output-dir.summary
18
+
19
+ Output directory
20
+
21
+ # flags.output-dir.description
22
+
23
+ The directory to save the backup CSV file to. Defaults to the current directory.
24
+
25
+ # examples
26
+
27
+ - <%= config.bin %> <%= command.id %> --target-org myOrg --sobject Account
28
+
29
+ - <%= config.bin %> <%= command.id %> --target-org myOrg --sobject Custom_Object__c --output-dir backups
30
+
31
+ # error.targetOrgConnectionFailed
32
+
33
+ Unable to establish connection to the org.
34
+
35
+ # info.describingSobject
36
+
37
+ Describing SObject: %s...
38
+
39
+ # info.exportingData
40
+
41
+ Exporting data for %s...
42
+
43
+ # info.complete
44
+
45
+ Backed up %s records to: %s
@@ -0,0 +1,69 @@
1
+ # summary
2
+
3
+ Identify and prepare deduplication of an SObject's records.
4
+
5
+ # description
6
+
7
+ Queries an SObject, groups records by a composite key built from configured fields, and writes CSV files listing which records are unique and which are duplicates that should be deleted. For each associated object with lookups to the primary object, also writes a CSV of the lookup field updates needed to re-point duplicate references at the surviving unique record. This command does not perform any deletes or updates in the org; it only prepares the CSV files for a subsequent data load.
8
+
9
+ # flags.config.summary
10
+
11
+ Path to a deduplication configuration file
12
+
13
+ # flags.config.description
14
+
15
+ The path to a JSON file describing the primary object, its composite key fields, and any associated objects with lookups to it.
16
+
17
+ # flags.dry-run.summary
18
+
19
+ Skip calculating associated object lookup replacements
20
+
21
+ # flags.dry-run.description
22
+
23
+ When set, only the primary object's unique/duplicate CSV files are generated; associated object lookup replacement files are not calculated.
24
+
25
+ # flags.output-dir.summary
26
+
27
+ Output directory
28
+
29
+ # flags.output-dir.description
30
+
31
+ The directory to write the generated CSV files to. Defaults to ./temp/<primaryObjectApiName>.
32
+
33
+ # examples
34
+
35
+ - <%= config.bin %> <%= command.id %> --target-org myOrg --config config/deduplicate-account.json
36
+
37
+ - <%= config.bin %> <%= command.id %> --target-org myOrg --config config/deduplicate-account.json --dry-run
38
+
39
+ # error.targetOrgConnectionFailed
40
+
41
+ Unable to establish connection to the org.
42
+
43
+ # error.invalidConfig
44
+
45
+ The deduplication configuration file is invalid: %s
46
+
47
+ # info.readingConfig
48
+
49
+ Reading and validating configuration file...
50
+
51
+ # info.queryingPrimary
52
+
53
+ Querying %s via the Bulk API...
54
+
55
+ # info.duplicatesFound
56
+
57
+ %s records identified as duplicates.
58
+
59
+ # info.calculatingReplacements
60
+
61
+ Calculating lookup replacements for associated objects...
62
+
63
+ # warning.blankCompositeKey
64
+
65
+ Record %s (%s) has the following blank composite key fields: %s
66
+
67
+ # warning.associatedObjectFailed
68
+
69
+ Failed to calculate lookup replacements for %s: %s
package/package.json ADDED
@@ -0,0 +1,201 @@
1
+ {
2
+ "name": "@simplysf/simply-sobject",
3
+ "description": "Utilities for working with SObjects",
4
+ "version": "1.0.0",
5
+ "author": "@ClayChipps",
6
+ "homepage": "https://github.com/SimplySF/simply",
7
+ "bugs": "https://github.com/SimplySF/simply/issues",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/SimplySF/simply",
11
+ "directory": "packages/simply-sobject"
12
+ },
13
+ "engines": {
14
+ "node": ">=22.0.0"
15
+ },
16
+ "files": [
17
+ "/lib",
18
+ "/messages",
19
+ "/npm-shrinkwrap.json",
20
+ "/oclif.lock",
21
+ "/oclif.manifest.json"
22
+ ],
23
+ "keywords": [
24
+ "force",
25
+ "salesforce",
26
+ "sfdx",
27
+ "salesforcedx",
28
+ "sfdx-plugin",
29
+ "sf-plugin",
30
+ "sf"
31
+ ],
32
+ "license": "Apache-2.0",
33
+ "exports": "./lib/index.js",
34
+ "type": "module",
35
+ "oclif": {
36
+ "bin": "sf",
37
+ "commands": "./lib/commands",
38
+ "devPlugins": [
39
+ "@oclif/plugin-command-snapshot",
40
+ "@oclif/plugin-help",
41
+ "@salesforce/plugin-command-reference"
42
+ ],
43
+ "flexibleTaxonomy": true,
44
+ "plugins": [],
45
+ "repositoryPrefix": "<%- repo %>/blob/@simplysf/simply-sobject@<%- version %>/packages/simply-sobject/<%- commandPath %>",
46
+ "topics": {
47
+ "simply": {
48
+ "description": "Commands for simplifying Salesforce",
49
+ "subtopics": {
50
+ "sobject": {
51
+ "description": "Commands for working with SObjects"
52
+ }
53
+ }
54
+ }
55
+ },
56
+ "topicSeparator": " "
57
+ },
58
+ "dependencies": {
59
+ "@oclif/core": "^4.11.2",
60
+ "@salesforce/core": "^8.30.0",
61
+ "@salesforce/kit": "^3.2.6",
62
+ "@salesforce/sf-plugins-core": "^12.2.16",
63
+ "csv-writer": "^1.6.0",
64
+ "zod": "^4.1.12"
65
+ },
66
+ "devDependencies": {
67
+ "@oclif/plugin-command-snapshot": "^5.3.19",
68
+ "@salesforce/plugin-command-reference": "^3.1.99"
69
+ },
70
+ "publishConfig": {
71
+ "access": "public"
72
+ },
73
+ "scripts": {
74
+ "build": "wireit",
75
+ "compile": "wireit",
76
+ "fix-license": "eslint src test --fix --rule \"header/header: [2]\"",
77
+ "format": "wireit",
78
+ "link-check": "wireit",
79
+ "lint": "wireit",
80
+ "readme": "oclif readme --no-aliases",
81
+ "test": "wireit",
82
+ "test:nuts": "nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 1200000 --parallel --jobs 5",
83
+ "test:only": "wireit",
84
+ "test:watch": "mocha --watch \"./test/**/*.test.ts\""
85
+ },
86
+ "wireit": {
87
+ "build": {
88
+ "dependencies": [
89
+ "compile",
90
+ "lint"
91
+ ]
92
+ },
93
+ "compile": {
94
+ "command": "tsc -p . --pretty --incremental",
95
+ "files": [
96
+ "src/**/*.ts",
97
+ "**/tsconfig.json",
98
+ "messages/**"
99
+ ],
100
+ "output": [
101
+ "lib/**",
102
+ "*.tsbuildinfo"
103
+ ],
104
+ "clean": "if-file-deleted"
105
+ },
106
+ "format": {
107
+ "command": "prettier --write \"+(src|test|schemas)/**/*.+(ts|js|json)|command-snapshot.json\"",
108
+ "files": [
109
+ "src/**/*.ts",
110
+ "test/**/*.ts",
111
+ "schemas/**/*.json",
112
+ "command-snapshot.json",
113
+ ".prettier*"
114
+ ],
115
+ "output": []
116
+ },
117
+ "lint": {
118
+ "command": "eslint src test --color --cache --cache-location .eslintcache",
119
+ "files": [
120
+ "src/**/*.ts",
121
+ "test/**/*.ts",
122
+ "messages/**",
123
+ "**/.eslint*",
124
+ "**/tsconfig.json"
125
+ ],
126
+ "output": []
127
+ },
128
+ "test": {
129
+ "dependencies": [
130
+ "test:compile",
131
+ "test:only",
132
+ "test:command-reference",
133
+ "test:deprecation-policy",
134
+ "lint",
135
+ "test:json-schema",
136
+ "link-check"
137
+ ]
138
+ },
139
+ "test:command-reference": {
140
+ "command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" commandreference:generate --erroronwarnings",
141
+ "files": [
142
+ "src/**/*.ts",
143
+ "messages/**",
144
+ "package.json"
145
+ ],
146
+ "output": [
147
+ "tmp/root"
148
+ ]
149
+ },
150
+ "test:deprecation-policy": {
151
+ "command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" snapshot:compare",
152
+ "files": [
153
+ "src/**/*.ts"
154
+ ],
155
+ "output": [],
156
+ "dependencies": [
157
+ "compile"
158
+ ]
159
+ },
160
+ "test:json-schema": {
161
+ "command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" schema:compare",
162
+ "files": [
163
+ "src/**/*.ts",
164
+ "schemas"
165
+ ],
166
+ "output": []
167
+ },
168
+ "test:compile": {
169
+ "command": "tsc -p \"./test\" --pretty",
170
+ "files": [
171
+ "test/**/*.ts",
172
+ "**/tsconfig.json"
173
+ ],
174
+ "output": []
175
+ },
176
+ "test:only": {
177
+ "command": "nyc mocha \"test/**/*.test.ts\"",
178
+ "env": {
179
+ "FORCE_COLOR": "2"
180
+ },
181
+ "files": [
182
+ "test/**/*.ts",
183
+ "src/**/*.ts",
184
+ "**/tsconfig.json",
185
+ ".mocha*",
186
+ "!*.nut.ts",
187
+ ".nycrc"
188
+ ],
189
+ "output": []
190
+ },
191
+ "link-check": {
192
+ "command": "node -e \"process.exit(process.env.CI ? 0 : 1)\" || linkinator \"**/*.md\" --skip \"CHANGELOG.md|node_modules|test/|confluence.internal.salesforce.com|my.salesforce.com|localhost|blob/.*/lib/|%s\" --markdown --retry --directory-listing --verbosity error",
193
+ "files": [
194
+ "./*.md",
195
+ "./!(CHANGELOG).md",
196
+ "messages/**/*.md"
197
+ ],
198
+ "output": []
199
+ }
200
+ }
201
+ }