sf-browserforce 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.
- package/LICENSE +21 -0
- package/README.md +266 -0
- package/bin/run +9 -0
- package/bin/run.cmd +3 -0
- package/lib/browserforce-command.d.ts +27 -0
- package/lib/browserforce-command.js +162 -0
- package/lib/browserforce-command.js.map +1 -0
- package/lib/browserforce.d.ts +27 -0
- package/lib/browserforce.js +163 -0
- package/lib/browserforce.js.map +1 -0
- package/lib/commands/browserforce/apply.d.ts +10 -0
- package/lib/commands/browserforce/apply.js +83 -0
- package/lib/commands/browserforce/apply.js.map +1 -0
- package/lib/commands/browserforce/playwright.d.ts +9 -0
- package/lib/commands/browserforce/playwright.js +53 -0
- package/lib/commands/browserforce/playwright.js.map +1 -0
- package/lib/config-parser.d.ts +16 -0
- package/lib/config-parser.js +24 -0
- package/lib/config-parser.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/lib/jsforce-utils.d.ts +5 -0
- package/lib/jsforce-utils.js +14 -0
- package/lib/jsforce-utils.js.map +1 -0
- package/lib/pages/login.d.ts +7 -0
- package/lib/pages/login.js +17 -0
- package/lib/pages/login.js.map +1 -0
- package/lib/plugin.d.ts +15 -0
- package/lib/plugin.js +28 -0
- package/lib/plugin.js.map +1 -0
- package/lib/plugins/activity-settings/index.d.ts +9 -0
- package/lib/plugins/activity-settings/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/activity-settings/index.e2e-spec.js +36 -0
- package/lib/plugins/activity-settings/index.e2e-spec.js.map +1 -0
- package/lib/plugins/activity-settings/index.js +102 -0
- package/lib/plugins/activity-settings/index.js.map +1 -0
- package/lib/plugins/auth-providers/index.d.ts +13 -0
- package/lib/plugins/auth-providers/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/auth-providers/index.e2e-spec.js +78 -0
- package/lib/plugins/auth-providers/index.e2e-spec.js.map +1 -0
- package/lib/plugins/auth-providers/index.js +135 -0
- package/lib/plugins/auth-providers/index.js.map +1 -0
- package/lib/plugins/company-information/index.d.ts +8 -0
- package/lib/plugins/company-information/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/company-information/index.e2e-spec.js +37 -0
- package/lib/plugins/company-information/index.e2e-spec.js.map +1 -0
- package/lib/plugins/company-information/index.js +114 -0
- package/lib/plugins/company-information/index.js.map +1 -0
- package/lib/plugins/customer-portal/available-custom-objects/index.d.ts +14 -0
- package/lib/plugins/customer-portal/available-custom-objects/index.js +203 -0
- package/lib/plugins/customer-portal/available-custom-objects/index.js.map +1 -0
- package/lib/plugins/customer-portal/available-custom-objects/index.test.d.ts +1 -0
- package/lib/plugins/customer-portal/available-custom-objects/index.test.js +39 -0
- package/lib/plugins/customer-portal/available-custom-objects/index.test.js.map +1 -0
- package/lib/plugins/customer-portal/enabled/index.d.ts +6 -0
- package/lib/plugins/customer-portal/enabled/index.js +89 -0
- package/lib/plugins/customer-portal/enabled/index.js.map +1 -0
- package/lib/plugins/customer-portal/enabled/index.test.d.ts +1 -0
- package/lib/plugins/customer-portal/enabled/index.test.js +34 -0
- package/lib/plugins/customer-portal/enabled/index.test.js.map +1 -0
- package/lib/plugins/customer-portal/index.d.ts +15 -0
- package/lib/plugins/customer-portal/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/customer-portal/index.e2e-spec.js +188 -0
- package/lib/plugins/customer-portal/index.e2e-spec.js.map +1 -0
- package/lib/plugins/customer-portal/index.js +58 -0
- package/lib/plugins/customer-portal/index.js.map +1 -0
- package/lib/plugins/customer-portal/index.test.d.ts +1 -0
- package/lib/plugins/customer-portal/index.test.js +84 -0
- package/lib/plugins/customer-portal/index.test.js.map +1 -0
- package/lib/plugins/customer-portal/portals/index.d.ts +25 -0
- package/lib/plugins/customer-portal/portals/index.js +254 -0
- package/lib/plugins/customer-portal/portals/index.js.map +1 -0
- package/lib/plugins/customer-portal/portals/index.test.d.ts +1 -0
- package/lib/plugins/customer-portal/portals/index.test.js +140 -0
- package/lib/plugins/customer-portal/portals/index.test.js.map +1 -0
- package/lib/plugins/density-settings/index.d.ts +10 -0
- package/lib/plugins/density-settings/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/density-settings/index.e2e-spec.js +39 -0
- package/lib/plugins/density-settings/index.e2e-spec.js.map +1 -0
- package/lib/plugins/density-settings/index.js +101 -0
- package/lib/plugins/density-settings/index.js.map +1 -0
- package/lib/plugins/deprecated.d.ts +4 -0
- package/lib/plugins/deprecated.js +28 -0
- package/lib/plugins/deprecated.js.map +1 -0
- package/lib/plugins/email-deliverability/index.d.ts +9 -0
- package/lib/plugins/email-deliverability/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/email-deliverability/index.e2e-spec.js +55 -0
- package/lib/plugins/email-deliverability/index.e2e-spec.js.map +1 -0
- package/lib/plugins/email-deliverability/index.js +109 -0
- package/lib/plugins/email-deliverability/index.js.map +1 -0
- package/lib/plugins/high-velocity-sales-settings/index.d.ts +10 -0
- package/lib/plugins/high-velocity-sales-settings/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/high-velocity-sales-settings/index.e2e-spec.js +29 -0
- package/lib/plugins/high-velocity-sales-settings/index.e2e-spec.js.map +1 -0
- package/lib/plugins/high-velocity-sales-settings/index.js +105 -0
- package/lib/plugins/high-velocity-sales-settings/index.js.map +1 -0
- package/lib/plugins/high-velocity-sales-settings/page.d.ts +8 -0
- package/lib/plugins/high-velocity-sales-settings/page.js +27 -0
- package/lib/plugins/high-velocity-sales-settings/page.js.map +1 -0
- package/lib/plugins/history-tracking/index.d.ts +19 -0
- package/lib/plugins/history-tracking/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/history-tracking/index.e2e-spec.js +128 -0
- package/lib/plugins/history-tracking/index.e2e-spec.js.map +1 -0
- package/lib/plugins/history-tracking/index.js +272 -0
- package/lib/plugins/history-tracking/index.js.map +1 -0
- package/lib/plugins/home-page-layouts/index.d.ts +14 -0
- package/lib/plugins/home-page-layouts/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/home-page-layouts/index.e2e-spec.js +47 -0
- package/lib/plugins/home-page-layouts/index.e2e-spec.js.map +1 -0
- package/lib/plugins/home-page-layouts/index.js +145 -0
- package/lib/plugins/home-page-layouts/index.js.map +1 -0
- package/lib/plugins/home-page-layouts/index.test.d.ts +1 -0
- package/lib/plugins/home-page-layouts/index.test.js +104 -0
- package/lib/plugins/home-page-layouts/index.test.js.map +1 -0
- package/lib/plugins/index.d.ts +28 -0
- package/lib/plugins/index.js +29 -0
- package/lib/plugins/index.js.map +1 -0
- package/lib/plugins/lightning-experience-settings/index.d.ts +17 -0
- package/lib/plugins/lightning-experience-settings/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/lightning-experience-settings/index.e2e-spec.js +48 -0
- package/lib/plugins/lightning-experience-settings/index.e2e-spec.js.map +1 -0
- package/lib/plugins/lightning-experience-settings/index.js +149 -0
- package/lib/plugins/lightning-experience-settings/index.js.map +1 -0
- package/lib/plugins/linkedin-sales-navigator-settings/index.d.ts +8 -0
- package/lib/plugins/linkedin-sales-navigator-settings/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/linkedin-sales-navigator-settings/index.e2e-spec.js +29 -0
- package/lib/plugins/linkedin-sales-navigator-settings/index.e2e-spec.js.map +1 -0
- package/lib/plugins/linkedin-sales-navigator-settings/index.js +93 -0
- package/lib/plugins/linkedin-sales-navigator-settings/index.js.map +1 -0
- package/lib/plugins/linkedin-sales-navigator-settings/page.d.ts +9 -0
- package/lib/plugins/linkedin-sales-navigator-settings/page.js +35 -0
- package/lib/plugins/linkedin-sales-navigator-settings/page.js.map +1 -0
- package/lib/plugins/login-as-user/index.d.ts +9 -0
- package/lib/plugins/login-as-user/index.js +104 -0
- package/lib/plugins/login-as-user/index.js.map +1 -0
- package/lib/plugins/logout-login-as-user/index.d.ts +6 -0
- package/lib/plugins/logout-login-as-user/index.js +76 -0
- package/lib/plugins/logout-login-as-user/index.js.map +1 -0
- package/lib/plugins/omni-channel-settings/index.d.ts +9 -0
- package/lib/plugins/omni-channel-settings/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/omni-channel-settings/index.e2e-spec.js +30 -0
- package/lib/plugins/omni-channel-settings/index.e2e-spec.js.map +1 -0
- package/lib/plugins/omni-channel-settings/index.js +97 -0
- package/lib/plugins/omni-channel-settings/index.js.map +1 -0
- package/lib/plugins/opportunity-splits/index.d.ts +9 -0
- package/lib/plugins/opportunity-splits/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/opportunity-splits/index.e2e-spec.js +46 -0
- package/lib/plugins/opportunity-splits/index.e2e-spec.js.map +1 -0
- package/lib/plugins/opportunity-splits/index.js +117 -0
- package/lib/plugins/opportunity-splits/index.js.map +1 -0
- package/lib/plugins/opportunity-splits/pages/layout-selection.d.ts +8 -0
- package/lib/plugins/opportunity-splits/pages/layout-selection.js +15 -0
- package/lib/plugins/opportunity-splits/pages/layout-selection.js.map +1 -0
- package/lib/plugins/opportunity-splits/pages/overview.d.ts +11 -0
- package/lib/plugins/opportunity-splits/pages/overview.js +32 -0
- package/lib/plugins/opportunity-splits/pages/overview.js.map +1 -0
- package/lib/plugins/opportunity-splits/pages/setup.d.ts +9 -0
- package/lib/plugins/opportunity-splits/pages/setup.js +17 -0
- package/lib/plugins/opportunity-splits/pages/setup.js.map +1 -0
- package/lib/plugins/permission-sets/index.d.ts +10 -0
- package/lib/plugins/permission-sets/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/permission-sets/index.e2e-spec.js +47 -0
- package/lib/plugins/permission-sets/index.e2e-spec.js.map +1 -0
- package/lib/plugins/permission-sets/index.js +22 -0
- package/lib/plugins/permission-sets/index.js.map +1 -0
- package/lib/plugins/permission-sets/service-presence-status/index.d.ts +10 -0
- package/lib/plugins/permission-sets/service-presence-status/index.js +124 -0
- package/lib/plugins/permission-sets/service-presence-status/index.js.map +1 -0
- package/lib/plugins/picklists/field-dependencies/index.d.ts +11 -0
- package/lib/plugins/picklists/field-dependencies/index.js +133 -0
- package/lib/plugins/picklists/field-dependencies/index.js.map +1 -0
- package/lib/plugins/picklists/field-dependencies/index.test.d.ts +1 -0
- package/lib/plugins/picklists/field-dependencies/index.test.js +64 -0
- package/lib/plugins/picklists/field-dependencies/index.test.js.map +1 -0
- package/lib/plugins/picklists/field-dependencies/pages.d.ts +15 -0
- package/lib/plugins/picklists/field-dependencies/pages.js +50 -0
- package/lib/plugins/picklists/field-dependencies/pages.js.map +1 -0
- package/lib/plugins/picklists/index.d.ts +23 -0
- package/lib/plugins/picklists/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/picklists/index.e2e-spec.js +128 -0
- package/lib/plugins/picklists/index.e2e-spec.js.map +1 -0
- package/lib/plugins/picklists/index.js +229 -0
- package/lib/plugins/picklists/index.js.map +1 -0
- package/lib/plugins/picklists/pages.d.ts +45 -0
- package/lib/plugins/picklists/pages.js +185 -0
- package/lib/plugins/picklists/pages.js.map +1 -0
- package/lib/plugins/picklists/standard-value-set.d.ts +1 -0
- package/lib/plugins/picklists/standard-value-set.js +80 -0
- package/lib/plugins/picklists/standard-value-set.js.map +1 -0
- package/lib/plugins/record-types/index.d.ts +14 -0
- package/lib/plugins/record-types/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/record-types/index.e2e-spec.js +76 -0
- package/lib/plugins/record-types/index.e2e-spec.js.map +1 -0
- package/lib/plugins/record-types/index.js +133 -0
- package/lib/plugins/record-types/index.js.map +1 -0
- package/lib/plugins/record-types/pages.d.ts +14 -0
- package/lib/plugins/record-types/pages.js +50 -0
- package/lib/plugins/record-types/pages.js.map +1 -0
- package/lib/plugins/relate-contact-to-multiple-accounts/index.d.ts +11 -0
- package/lib/plugins/relate-contact-to-multiple-accounts/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/relate-contact-to-multiple-accounts/index.e2e-spec.js +30 -0
- package/lib/plugins/relate-contact-to-multiple-accounts/index.e2e-spec.js.map +1 -0
- package/lib/plugins/relate-contact-to-multiple-accounts/index.js +120 -0
- package/lib/plugins/relate-contact-to-multiple-accounts/index.js.map +1 -0
- package/lib/plugins/reports-and-dashboards/folder-sharing/index.d.ts +8 -0
- package/lib/plugins/reports-and-dashboards/folder-sharing/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/reports-and-dashboards/folder-sharing/index.e2e-spec.js +3 -0
- package/lib/plugins/reports-and-dashboards/folder-sharing/index.e2e-spec.js.map +1 -0
- package/lib/plugins/reports-and-dashboards/folder-sharing/index.js +116 -0
- package/lib/plugins/reports-and-dashboards/folder-sharing/index.js.map +1 -0
- package/lib/plugins/reports-and-dashboards/index.d.ts +11 -0
- package/lib/plugins/reports-and-dashboards/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/reports-and-dashboards/index.e2e-spec.js +3 -0
- package/lib/plugins/reports-and-dashboards/index.e2e-spec.js.map +1 -0
- package/lib/plugins/reports-and-dashboards/index.js +29 -0
- package/lib/plugins/reports-and-dashboards/index.js.map +1 -0
- package/lib/plugins/salesforce-cpq-config/formConfig.d.ts +17 -0
- package/lib/plugins/salesforce-cpq-config/formConfig.js +649 -0
- package/lib/plugins/salesforce-cpq-config/formConfig.js.map +1 -0
- package/lib/plugins/salesforce-cpq-config/index.d.ts +7 -0
- package/lib/plugins/salesforce-cpq-config/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/salesforce-cpq-config/index.e2e-spec.js +37 -0
- package/lib/plugins/salesforce-cpq-config/index.e2e-spec.js.map +1 -0
- package/lib/plugins/salesforce-cpq-config/index.js +261 -0
- package/lib/plugins/salesforce-cpq-config/index.js.map +1 -0
- package/lib/plugins/salesforce-to-salesforce/index.d.ts +9 -0
- package/lib/plugins/salesforce-to-salesforce/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/salesforce-to-salesforce/index.e2e-spec.js +34 -0
- package/lib/plugins/salesforce-to-salesforce/index.e2e-spec.js.map +1 -0
- package/lib/plugins/salesforce-to-salesforce/index.js +107 -0
- package/lib/plugins/salesforce-to-salesforce/index.js.map +1 -0
- package/lib/plugins/scheduled-batches/index.d.ts +10 -0
- package/lib/plugins/scheduled-batches/index.js +145 -0
- package/lib/plugins/scheduled-batches/index.js.map +1 -0
- package/lib/plugins/scheduled-batches/page.d.ts +19 -0
- package/lib/plugins/scheduled-batches/page.js +39 -0
- package/lib/plugins/scheduled-batches/page.js.map +1 -0
- package/lib/plugins/security/authentication-configuration/index.d.ts +15 -0
- package/lib/plugins/security/authentication-configuration/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/security/authentication-configuration/index.e2e-spec.js +129 -0
- package/lib/plugins/security/authentication-configuration/index.e2e-spec.js.map +1 -0
- package/lib/plugins/security/authentication-configuration/index.js +200 -0
- package/lib/plugins/security/authentication-configuration/index.js.map +1 -0
- package/lib/plugins/security/certificate-and-key-management/index.d.ts +23 -0
- package/lib/plugins/security/certificate-and-key-management/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/security/certificate-and-key-management/index.e2e-spec.js +59 -0
- package/lib/plugins/security/certificate-and-key-management/index.e2e-spec.js.map +1 -0
- package/lib/plugins/security/certificate-and-key-management/index.js +233 -0
- package/lib/plugins/security/certificate-and-key-management/index.js.map +1 -0
- package/lib/plugins/security/certificate-and-key-management/index.test.d.ts +1 -0
- package/lib/plugins/security/certificate-and-key-management/index.test.js +61 -0
- package/lib/plugins/security/certificate-and-key-management/index.test.js.map +1 -0
- package/lib/plugins/security/index.d.ts +13 -0
- package/lib/plugins/security/index.js +41 -0
- package/lib/plugins/security/index.js.map +1 -0
- package/lib/plugins/service-channels/capacity/index.d.ts +18 -0
- package/lib/plugins/service-channels/capacity/index.js +194 -0
- package/lib/plugins/service-channels/capacity/index.js.map +1 -0
- package/lib/plugins/service-channels/index.d.ts +12 -0
- package/lib/plugins/service-channels/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/service-channels/index.e2e-spec.js +67 -0
- package/lib/plugins/service-channels/index.e2e-spec.js.map +1 -0
- package/lib/plugins/service-channels/index.js +37 -0
- package/lib/plugins/service-channels/index.js.map +1 -0
- package/lib/plugins/slack/index.d.ts +9 -0
- package/lib/plugins/slack/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/slack/index.e2e-spec.js +47 -0
- package/lib/plugins/slack/index.e2e-spec.js.map +1 -0
- package/lib/plugins/slack/index.js +111 -0
- package/lib/plugins/slack/index.js.map +1 -0
- package/lib/plugins/user-access-policies/index.d.ts +19 -0
- package/lib/plugins/user-access-policies/index.e2e-spec.d.ts +1 -0
- package/lib/plugins/user-access-policies/index.e2e-spec.js +61 -0
- package/lib/plugins/user-access-policies/index.e2e-spec.js.map +1 -0
- package/lib/plugins/user-access-policies/index.js +176 -0
- package/lib/plugins/user-access-policies/index.js.map +1 -0
- package/lib/plugins/user-access-policies/page.d.ts +30 -0
- package/lib/plugins/user-access-policies/page.js +114 -0
- package/lib/plugins/user-access-policies/page.js.map +1 -0
- package/lib/plugins/utils.d.ts +13 -0
- package/lib/plugins/utils.js +159 -0
- package/lib/plugins/utils.js.map +1 -0
- package/oclif.manifest.json +177 -0
- package/package.json +65 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import assert from 'assert';
|
|
2
|
+
import * as child from 'child_process';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import { HistoryTracking } from './index.js';
|
|
6
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
7
|
+
describe(HistoryTracking.name, function () {
|
|
8
|
+
let plugin;
|
|
9
|
+
before(() => {
|
|
10
|
+
plugin = new HistoryTracking(global.browserforce);
|
|
11
|
+
});
|
|
12
|
+
const enableHistoryTracking = [
|
|
13
|
+
{
|
|
14
|
+
objectApiName: 'Account',
|
|
15
|
+
enableHistoryTracking: true,
|
|
16
|
+
fieldHistoryTracking: [
|
|
17
|
+
{
|
|
18
|
+
fieldApiName: 'PersonBirthdate',
|
|
19
|
+
enableHistoryTracking: true,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
fieldApiName: 'Test__pc',
|
|
23
|
+
enableHistoryTracking: true,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
objectApiName: 'Opportunity',
|
|
29
|
+
enableHistoryTracking: true,
|
|
30
|
+
fieldHistoryTracking: [
|
|
31
|
+
{
|
|
32
|
+
fieldApiName: 'Type',
|
|
33
|
+
enableHistoryTracking: true,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
objectApiName: 'Test__c',
|
|
39
|
+
fieldHistoryTracking: [
|
|
40
|
+
{
|
|
41
|
+
fieldApiName: 'Owner',
|
|
42
|
+
enableHistoryTracking: true,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
fieldApiName: 'Test__c',
|
|
46
|
+
enableHistoryTracking: true,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
objectApiName: 'Task',
|
|
52
|
+
fieldHistoryTracking: [
|
|
53
|
+
{
|
|
54
|
+
fieldApiName: 'Test__c',
|
|
55
|
+
enableHistoryTracking: true,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
const disableHistoryTracking = [
|
|
61
|
+
{
|
|
62
|
+
objectApiName: 'Account',
|
|
63
|
+
enableHistoryTracking: true,
|
|
64
|
+
fieldHistoryTracking: [
|
|
65
|
+
{
|
|
66
|
+
fieldApiName: 'PersonBirthdate',
|
|
67
|
+
enableHistoryTracking: false,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
fieldApiName: 'Test__pc',
|
|
71
|
+
enableHistoryTracking: true,
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
objectApiName: 'Opportunity',
|
|
77
|
+
enableHistoryTracking: false,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
objectApiName: 'Test__c',
|
|
81
|
+
fieldHistoryTracking: [
|
|
82
|
+
{
|
|
83
|
+
fieldApiName: 'Owner',
|
|
84
|
+
enableHistoryTracking: true,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
fieldApiName: 'Test__c',
|
|
88
|
+
enableHistoryTracking: false,
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
objectApiName: 'Task',
|
|
94
|
+
fieldHistoryTracking: [
|
|
95
|
+
{
|
|
96
|
+
fieldApiName: 'Test__c',
|
|
97
|
+
enableHistoryTracking: false,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
it('should create custom object and fields as a prerequisite', () => {
|
|
103
|
+
const sourceDeployCmd = child.spawnSync('sf', [
|
|
104
|
+
'project',
|
|
105
|
+
'deploy',
|
|
106
|
+
'start',
|
|
107
|
+
'-d',
|
|
108
|
+
path.join(__dirname, 'sfdx-source'),
|
|
109
|
+
'--json',
|
|
110
|
+
]);
|
|
111
|
+
assert.deepStrictEqual(sourceDeployCmd.status, 0, sourceDeployCmd.output.toString());
|
|
112
|
+
});
|
|
113
|
+
it('should enable history tracking for objects and fields', async () => {
|
|
114
|
+
await plugin.run(enableHistoryTracking);
|
|
115
|
+
const res = await plugin.retrieve(enableHistoryTracking);
|
|
116
|
+
assert.deepStrictEqual(res, enableHistoryTracking);
|
|
117
|
+
});
|
|
118
|
+
it('should disable history tracking for objects and fields', async () => {
|
|
119
|
+
await plugin.run(disableHistoryTracking);
|
|
120
|
+
const res = await plugin.retrieve(disableHistoryTracking);
|
|
121
|
+
assert.deepStrictEqual(res, disableHistoryTracking);
|
|
122
|
+
});
|
|
123
|
+
it('should remove the CustomObject and field', async () => {
|
|
124
|
+
await global.browserforce.connection.metadata.delete('CustomObject', ['Test__c']);
|
|
125
|
+
await global.browserforce.connection.metadata.delete('CustomField', ['Contact.Test__c']);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=index.e2e-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.e2e-spec.js","sourceRoot":"","sources":["../../../src/plugins/history-tracking/index.e2e-spec.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,KAAK,KAAK,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE;IAC7B,IAAI,MAAuB,CAAC;IAC5B,MAAM,CAAC,GAAG,EAAE;QACV,MAAM,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,MAAM,qBAAqB,GAAG;QAC5B;YACE,aAAa,EAAE,SAAS;YACxB,qBAAqB,EAAE,IAAI;YAC3B,oBAAoB,EAAE;gBACpB;oBACE,YAAY,EAAE,iBAAiB;oBAC/B,qBAAqB,EAAE,IAAI;iBAC5B;gBACD;oBACE,YAAY,EAAE,UAAU;oBACxB,qBAAqB,EAAE,IAAI;iBAC5B;aACF;SACF;QACD;YACE,aAAa,EAAE,aAAa;YAC5B,qBAAqB,EAAE,IAAI;YAC3B,oBAAoB,EAAE;gBACpB;oBACE,YAAY,EAAE,MAAM;oBACpB,qBAAqB,EAAE,IAAI;iBAC5B;aACF;SACF;QACD;YACE,aAAa,EAAE,SAAS;YACxB,oBAAoB,EAAE;gBACpB;oBACE,YAAY,EAAE,OAAO;oBACrB,qBAAqB,EAAE,IAAI;iBAC5B;gBACD;oBACE,YAAY,EAAE,SAAS;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AK,IAAI,EAAE;QACrE,MAAM,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QACxC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;QACzD,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;QACtE,MAAM,MAAM,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QACzC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;QAC1D,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;QACxD,MAAM,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;QAClF,MAAM,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import { waitForPageErrors } from '../../browserforce.js';
|
|
54
|
+
import { BrowserforcePlugin } from '../../plugin.js';
|
|
55
|
+
const BASE_PATH = `/ui/setup/layout/FieldHistoryTracking?pEntity={APINAME}&retURL=${encodeURIComponent('/setup/forcecomHomepage.apexp')}`;
|
|
56
|
+
const ENABLE_HISTORY_SELECTOR = 'input[type="checkbox"][id="enable"]';
|
|
57
|
+
const ENABLE_FIELD_HISTORY_SELECTOR = 'input[id="{APINAME}_fht"]';
|
|
58
|
+
const SAVE_BUTTON_SELECTOR = 'input[type="submit"][name="save"]';
|
|
59
|
+
const UNSUPPORTED_HISTORY_TRACKING_OBJECTS = new Set(['Task']);
|
|
60
|
+
export class HistoryTracking extends BrowserforcePlugin {
|
|
61
|
+
async retrieve(definition) {
|
|
62
|
+
const historyTrackingConfigs = [];
|
|
63
|
+
// We first need to retrieve the corresponding CustomField.TableOrEnumId for all objects
|
|
64
|
+
// This is in case we have field tracking configured for custom fields
|
|
65
|
+
const tableEnumOrIdByObjectApiName = await this.getTableEnumOrIdByObjectApiName(definition);
|
|
66
|
+
// Now we can iterate over all history tracking configurations in the definition
|
|
67
|
+
for (const historyTrackingConfig of definition) {
|
|
68
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
69
|
+
try {
|
|
70
|
+
const historyTrackingResult = { ...historyTrackingConfig };
|
|
71
|
+
// Open the object history tracking setup page
|
|
72
|
+
const page = __addDisposableResource(env_1, await this.browserforce.openPage(BASE_PATH.replace('{APINAME}', tableEnumOrIdByObjectApiName.get(historyTrackingConfig.objectApiName))), true);
|
|
73
|
+
// Retrieve the object history tracking
|
|
74
|
+
// If this is a custom object, this checkbox does not exist, so skip
|
|
75
|
+
if (!historyTrackingConfig.objectApiName.includes('__c') &&
|
|
76
|
+
!UNSUPPORTED_HISTORY_TRACKING_OBJECTS.has(historyTrackingConfig.objectApiName)) {
|
|
77
|
+
historyTrackingResult.enableHistoryTracking = await page.locator(ENABLE_HISTORY_SELECTOR).isChecked();
|
|
78
|
+
}
|
|
79
|
+
// If we have no field history tracking, there is nothing more to do
|
|
80
|
+
if (!historyTrackingConfig.fieldHistoryTracking) {
|
|
81
|
+
historyTrackingConfigs.push(historyTrackingResult);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const fieldHistoryTrackingConfigs = [];
|
|
85
|
+
// If the object history tracking is false, then we already know all field history tracking is false
|
|
86
|
+
// Only so long as this is a standard object
|
|
87
|
+
if (!historyTrackingResult.enableHistoryTracking &&
|
|
88
|
+
!historyTrackingConfig.objectApiName.includes('__c') &&
|
|
89
|
+
!UNSUPPORTED_HISTORY_TRACKING_OBJECTS.has(historyTrackingConfig.objectApiName)) {
|
|
90
|
+
for (const fieldHistoryTracking of historyTrackingConfig.fieldHistoryTracking) {
|
|
91
|
+
fieldHistoryTrackingConfigs.push({
|
|
92
|
+
...fieldHistoryTracking,
|
|
93
|
+
enableHistoryTracking: false,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
historyTrackingResult.fieldHistoryTracking = fieldHistoryTrackingConfigs;
|
|
97
|
+
historyTrackingConfigs.push(historyTrackingResult);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
// We need to determine the correct html selector for each field that is configured
|
|
101
|
+
// This is because custom fields are identified using their CustomField.Id value
|
|
102
|
+
const fieldSelectorByFieldApiName = await this.getFieldSelectorByFieldApiName(tableEnumOrIdByObjectApiName.get(historyTrackingConfig.objectApiName), historyTrackingConfig.fieldHistoryTracking);
|
|
103
|
+
// We can now retrieve the field history settings for the fields specified for the object
|
|
104
|
+
for (const fieldHistoryTracking of historyTrackingConfig.fieldHistoryTracking) {
|
|
105
|
+
const fieldHistoryTrackingResult = { ...fieldHistoryTracking };
|
|
106
|
+
const fieldApiName = fieldSelectorByFieldApiName.get(fieldHistoryTracking.fieldApiName);
|
|
107
|
+
fieldHistoryTrackingResult.enableHistoryTracking = await page
|
|
108
|
+
.locator(ENABLE_FIELD_HISTORY_SELECTOR.replace('{APINAME}', fieldApiName))
|
|
109
|
+
.isChecked();
|
|
110
|
+
fieldHistoryTrackingConfigs.push(fieldHistoryTrackingResult);
|
|
111
|
+
}
|
|
112
|
+
historyTrackingResult.fieldHistoryTracking = fieldHistoryTrackingConfigs;
|
|
113
|
+
historyTrackingConfigs.push(historyTrackingResult);
|
|
114
|
+
}
|
|
115
|
+
catch (e_1) {
|
|
116
|
+
env_1.error = e_1;
|
|
117
|
+
env_1.hasError = true;
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
const result_1 = __disposeResources(env_1);
|
|
121
|
+
if (result_1)
|
|
122
|
+
await result_1;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return historyTrackingConfigs;
|
|
126
|
+
}
|
|
127
|
+
async apply(plan) {
|
|
128
|
+
// We first need to retrieve the corresponding CustomField.TableOrEnumId for all objects
|
|
129
|
+
// This is in case we are configuring field tracking for custom fields
|
|
130
|
+
const tableEnumOrIdByObjectApiName = await this.getTableEnumOrIdByObjectApiName(plan);
|
|
131
|
+
// Now we can iterate over all history tracking configurations in the plan
|
|
132
|
+
for (const historyTrackingConfig of plan) {
|
|
133
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
134
|
+
try {
|
|
135
|
+
// Open the object history tracking setup page
|
|
136
|
+
const page = __addDisposableResource(env_2, await this.browserforce.openPage(BASE_PATH.replace('{APINAME}', tableEnumOrIdByObjectApiName.get(historyTrackingConfig.objectApiName))), true);
|
|
137
|
+
// Retrieve the object history tracking
|
|
138
|
+
// If this is a custom object, this checkbox does not exist, so skip
|
|
139
|
+
if (!historyTrackingConfig.objectApiName.includes('__c') &&
|
|
140
|
+
!UNSUPPORTED_HISTORY_TRACKING_OBJECTS.has(historyTrackingConfig.objectApiName)) {
|
|
141
|
+
const historyTrackingEnabled = await page.locator(ENABLE_HISTORY_SELECTOR).isChecked();
|
|
142
|
+
if (historyTrackingConfig.enableHistoryTracking !== historyTrackingEnabled) {
|
|
143
|
+
// Click the checkbox
|
|
144
|
+
await page.locator(ENABLE_HISTORY_SELECTOR).click();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (historyTrackingConfig.fieldHistoryTracking) {
|
|
148
|
+
// We need to determine the correct html selector for each field that is configured
|
|
149
|
+
// This is because custom fields are identified using their CustomField.Id value
|
|
150
|
+
const fieldSelectorByFieldApiName = await this.getFieldSelectorByFieldApiName(tableEnumOrIdByObjectApiName.get(historyTrackingConfig.objectApiName), historyTrackingConfig.fieldHistoryTracking);
|
|
151
|
+
// We can now retrieve the field history settings for the fields specified for the object
|
|
152
|
+
for (const fieldHistoryTracking of historyTrackingConfig.fieldHistoryTracking) {
|
|
153
|
+
const fieldApiName = fieldSelectorByFieldApiName.get(fieldHistoryTracking.fieldApiName);
|
|
154
|
+
const fieldSelector = ENABLE_FIELD_HISTORY_SELECTOR.replace('{APINAME}', fieldApiName);
|
|
155
|
+
const fieldHistoryTrackingEnabled = await page.locator(fieldSelector).isChecked();
|
|
156
|
+
if (fieldHistoryTracking.enableHistoryTracking !== fieldHistoryTrackingEnabled) {
|
|
157
|
+
// Click the checkbox
|
|
158
|
+
await page.locator(fieldSelector).click();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Save the settings
|
|
163
|
+
await page
|
|
164
|
+
.locator(SAVE_BUTTON_SELECTOR)
|
|
165
|
+
.filter({ visible: true }) // there are three save buttons [not visible, top row, bottom row]
|
|
166
|
+
.first()
|
|
167
|
+
.click();
|
|
168
|
+
await Promise.race([
|
|
169
|
+
page.waitForURL((url) => url.pathname.startsWith('/setup/forcecomHomepage.apexp')),
|
|
170
|
+
waitForPageErrors(page),
|
|
171
|
+
]);
|
|
172
|
+
}
|
|
173
|
+
catch (e_2) {
|
|
174
|
+
env_2.error = e_2;
|
|
175
|
+
env_2.hasError = true;
|
|
176
|
+
}
|
|
177
|
+
finally {
|
|
178
|
+
const result_2 = __disposeResources(env_2);
|
|
179
|
+
if (result_2)
|
|
180
|
+
await result_2;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async queryCustomFieldsAndPopulateMap(fieldApiNameTuples, tableEnumOrId, suffix, fieldSelectorByFieldApiName) {
|
|
185
|
+
const developerNameConditions = fieldApiNameTuples.map(([apiname, namespace]) => namespace
|
|
186
|
+
? `(DeveloperName ='${apiname}' AND NamespacePrefix ='${namespace}')`
|
|
187
|
+
: `(DeveloperName = '${apiname}')`);
|
|
188
|
+
const customFieldsQuery = await this.browserforce.connection.tooling.query(`SELECT Id, DeveloperName, NamespacePrefix FROM CustomField WHERE (${developerNameConditions.join(' OR ')}) AND TableEnumOrId = '${tableEnumOrId}' ORDER By CreatedDate ASC`);
|
|
189
|
+
for (const customField of customFieldsQuery.records) {
|
|
190
|
+
const fieldApiName = `${customField.NamespacePrefix ? `${customField.NamespacePrefix}__` : ''}${customField.DeveloperName}${suffix}`;
|
|
191
|
+
fieldSelectorByFieldApiName.set(fieldApiName, customField.Id.substring(0, 15));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
parseNamespacedFieldApiName(fieldApiName, suffix) {
|
|
195
|
+
const fieldNameWithoutSuffix = fieldApiName.replace(suffix, '');
|
|
196
|
+
const parts = fieldNameWithoutSuffix.split('__');
|
|
197
|
+
const namespace = parts.length > 1 ? parts[0] : undefined;
|
|
198
|
+
const apiname = parts.length > 1 ? parts.slice(1).join('__') : parts[0];
|
|
199
|
+
return [apiname, namespace];
|
|
200
|
+
}
|
|
201
|
+
async getFieldSelectorByFieldApiName(tableEnumOrId, fieldHistoryTrackingConfigs) {
|
|
202
|
+
const fieldSelectorByFieldApiName = new Map();
|
|
203
|
+
const customFieldApiNames = [];
|
|
204
|
+
const personAccountFieldApiNames = [];
|
|
205
|
+
const activityFieldApiNames = [];
|
|
206
|
+
for (const fieldHistoryTrackingConfig of fieldHistoryTrackingConfigs) {
|
|
207
|
+
// If this is a person account field, we must do special handling for this
|
|
208
|
+
if (tableEnumOrId === 'Account' && fieldHistoryTrackingConfig.fieldApiName.includes('__pc')) {
|
|
209
|
+
personAccountFieldApiNames.push(this.parseNamespacedFieldApiName(fieldHistoryTrackingConfig.fieldApiName, '__pc'));
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
// If this is a Task field, we must do special handling for this
|
|
213
|
+
if (tableEnumOrId === 'Task' && fieldHistoryTrackingConfig.fieldApiName.includes('__c')) {
|
|
214
|
+
activityFieldApiNames.push(this.parseNamespacedFieldApiName(fieldHistoryTrackingConfig.fieldApiName, '__c'));
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
// If this is a custom field, we must query for the Field Id
|
|
218
|
+
if (fieldHistoryTrackingConfig.fieldApiName.includes('__c')) {
|
|
219
|
+
customFieldApiNames.push(this.parseNamespacedFieldApiName(fieldHistoryTrackingConfig.fieldApiName, '__c'));
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
// Otherwise, if this is a standard field, the Selector is the Field API Name
|
|
223
|
+
fieldSelectorByFieldApiName.set(fieldHistoryTrackingConfig.fieldApiName, fieldHistoryTrackingConfig.fieldApiName);
|
|
224
|
+
}
|
|
225
|
+
if (customFieldApiNames.length === 0 &&
|
|
226
|
+
personAccountFieldApiNames.length === 0 &&
|
|
227
|
+
activityFieldApiNames.length === 0) {
|
|
228
|
+
return fieldSelectorByFieldApiName;
|
|
229
|
+
}
|
|
230
|
+
if (personAccountFieldApiNames.length > 0) {
|
|
231
|
+
// NOTE: Unfortunately this includes deleted records
|
|
232
|
+
// WORKAROUND: ORDER BY CreatedDate
|
|
233
|
+
await this.queryCustomFieldsAndPopulateMap(personAccountFieldApiNames, 'Contact', '__pc', fieldSelectorByFieldApiName);
|
|
234
|
+
}
|
|
235
|
+
if (customFieldApiNames.length > 0) {
|
|
236
|
+
// NOTE: Unfortunately this includes deleted records
|
|
237
|
+
// WORKAROUND: ORDER BY CreatedDate
|
|
238
|
+
await this.queryCustomFieldsAndPopulateMap(customFieldApiNames, tableEnumOrId, '__c', fieldSelectorByFieldApiName);
|
|
239
|
+
}
|
|
240
|
+
if (activityFieldApiNames.length > 0) {
|
|
241
|
+
await this.queryCustomFieldsAndPopulateMap(activityFieldApiNames, 'Activity', '__c', fieldSelectorByFieldApiName);
|
|
242
|
+
}
|
|
243
|
+
return fieldSelectorByFieldApiName;
|
|
244
|
+
}
|
|
245
|
+
async getTableEnumOrIdByObjectApiName(historyTrackingConfigs) {
|
|
246
|
+
const tableEnumOrIdByObjectApiName = new Map();
|
|
247
|
+
const customObjectApiNames = [];
|
|
248
|
+
for (const historyTrackingConfig of historyTrackingConfigs) {
|
|
249
|
+
// If it is a custom object, the CustomField.TableEnumOrId is the Object Id
|
|
250
|
+
if (historyTrackingConfig.objectApiName.includes('__c')) {
|
|
251
|
+
customObjectApiNames.push(this.parseNamespacedFieldApiName(historyTrackingConfig.objectApiName, '__c'));
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
// Otherwise, if this is a standard object, the CustomField.TableEnumOrId is the Object API Name
|
|
255
|
+
tableEnumOrIdByObjectApiName.set(historyTrackingConfig.objectApiName, historyTrackingConfig.objectApiName);
|
|
256
|
+
}
|
|
257
|
+
if (customObjectApiNames.length === 0) {
|
|
258
|
+
return tableEnumOrIdByObjectApiName;
|
|
259
|
+
}
|
|
260
|
+
// NOTE: Unfortunately this includes deleted records
|
|
261
|
+
// WORKAROUND: ORDER BY CreatedDate
|
|
262
|
+
const customObjectDeveloperNames = customObjectApiNames.map(([apiname, namespace]) => namespace
|
|
263
|
+
? `(DeveloperName = '${apiname}' AND NamespacePrefix = '${namespace}')`
|
|
264
|
+
: `(DeveloperName = '${apiname}')`);
|
|
265
|
+
const customObjectsQuery = await this.browserforce.connection.tooling.query(`SELECT Id, DeveloperName FROM CustomObject WHERE (${customObjectDeveloperNames.join(' OR ')}) ORDER BY CreatedDate ASC`);
|
|
266
|
+
for (const customObject of customObjectsQuery.records) {
|
|
267
|
+
tableEnumOrIdByObjectApiName.set(`${customObject.DeveloperName}__c`, customObject.Id);
|
|
268
|
+
}
|
|
269
|
+
return tableEnumOrIdByObjectApiName;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/history-tracking/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAA0B,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,SAAS,GAAsB,kEAAkE,kBAAkB,CAAC,+BAA+B,CAAC,EAAE,CAAC;AAE7J,MAAM,uBAAuB,GAAG,qCAAqC,CAAC;AACtE,MAAM,6BAA6B,GAAG,2BAA2B,CAAC;AAClE,MAAM,oBAAoB,GAAG,mCAAmC,CAAC;AACjE,MAAM,oCAAoC,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAa/D,MAAM,OAAO,eAAgB,SAAQ,kBAAkB;IAC9C,KAAK,CAAC,QAAQ,CAAC,UAAoC;QACxD,MAAM,sBAAsB,GAA4B,EAAE,CAAC;QAE3D,wFAAwF;QACxF,sEAAsE;QACtE,MAAM,4BAA4B,GAAG,MAAM,IAAI,CAAC,+BAA+B,CAAC,UAAU,CAAC,CAAC;QAE5F,gFAAgF;QAChF,KAAK,MAAM,qBAAqB,IAAI,UAAU,EAAE,CAAC;;;gBAC/C,MAAM,qBAAqB,GAAG,EAAE,GAAG,qBAAqB,EAAE,CAAC;gBAE3D,8CAA8C;gBAC9C,MAAY,IAAI,kCAAG,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CACjD,SAAS,CAAC,OAAO,CACf,WAAW,EACX,4BAA4B,CAAC,GAAG,CAAC,qBAAqB,CAAC,aAAa,CAAC,CACjD,CACvB,OAAA,CAAC;gBAEF,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Aa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACxD,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,2BAA2B,CAAC,qBAAqB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC;gBACxG,SAAS;YACX,CAAC;YAED,gGAAgG;YAChG,4BAA4B,CAAC,GAAG,CAAC,qBAAqB,CAAC,aAAa,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAC;QAC7G,CAAC;QAED,IAAI,oBAAoB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtC,OAAO,4BAA4B,CAAC;QACtC,CAAC;QAED,oDAAoD;QACpD,mCAAmC;QACnC,MAAM,0BAA0B,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,CACnF,SAAS;YACP,CAAC,CAAC,qBAAqB,OAAO,4BAA4B,SAAS,IAAI;YACvE,CAAC,CAAC,qBAAqB,OAAO,IAAI,CACrC,CAAC;QACF,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CACzE,qDAAqD,0BAA0B,CAAC,IAAI,CAClF,MAAM,CACP,4BAA4B,CAC9B,CAAC;QAEF,KAAK,MAAM,YAAY,IAAI,kBAAkB,CAAC,OAAO,EAAE,CAAC;YACtD,4BAA4B,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,aAAa,KAAK,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;QACxF,CAAC;QAED,OAAO,4BAA4B,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BrowserforcePlugin } from '../../plugin.js';
|
|
2
|
+
type Config = {
|
|
3
|
+
homePageLayoutAssignments: HomePageLayoutAssignment[];
|
|
4
|
+
};
|
|
5
|
+
type HomePageLayoutAssignment = {
|
|
6
|
+
profile: string;
|
|
7
|
+
layout: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class HomePageLayouts extends BrowserforcePlugin {
|
|
10
|
+
retrieve(): Promise<Config>;
|
|
11
|
+
diff(source: Config, target: Config): Config | undefined;
|
|
12
|
+
apply(config: Config): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import assert from 'assert';
|
|
2
|
+
import { HomePageLayouts } from './index.js';
|
|
3
|
+
describe(HomePageLayouts.name, function () {
|
|
4
|
+
let plugin;
|
|
5
|
+
before(() => {
|
|
6
|
+
plugin = new HomePageLayouts(global.browserforce);
|
|
7
|
+
});
|
|
8
|
+
const configPageDefault = {
|
|
9
|
+
homePageLayoutAssignments: [
|
|
10
|
+
{
|
|
11
|
+
profile: 'Standard User',
|
|
12
|
+
layout: '',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
profile: 'System Administrator',
|
|
16
|
+
layout: '',
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
const configOrgDefault = {
|
|
21
|
+
homePageLayoutAssignments: [
|
|
22
|
+
{
|
|
23
|
+
profile: 'Standard User',
|
|
24
|
+
layout: 'DE Default',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
profile: 'System Administrator',
|
|
28
|
+
layout: 'DE Default',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
it('should assign some layouts', async () => {
|
|
33
|
+
await plugin.run(configPageDefault);
|
|
34
|
+
});
|
|
35
|
+
it('should be assigned', async () => {
|
|
36
|
+
const res = await plugin.run(configPageDefault);
|
|
37
|
+
assert.deepStrictEqual(res, { message: 'no action necessary' });
|
|
38
|
+
});
|
|
39
|
+
it('should unassign some layouts', async () => {
|
|
40
|
+
await plugin.apply(configOrgDefault);
|
|
41
|
+
});
|
|
42
|
+
it('should be unassigned', async () => {
|
|
43
|
+
const res = await plugin.run(configOrgDefault);
|
|
44
|
+
assert.deepStrictEqual(res, { message: 'no action necessary' });
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=index.e2e-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.e2e-spec.js","sourceRoot":"","sources":["../../../src/plugins/home-page-layouts/index.e2e-spec.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE;IAC7B,IAAI,MAAuB,CAAC;IAC5B,MAAM,CAAC,GAAG,EAAE;QACV,MAAM,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG;QACxB,yBAAyB,EAAE;YACzB;gBACE,OAAO,EAAE,eAAe;gBACxB,MAAM,EAAE,EAAE;aACX;YACD;gBACE,OAAO,EAAE,sBAAsB;gBAC/B,MAAM,EAAE,EAAE;aACX;SACF;KACF,CAAC;IACF,MAAM,gBAAgB,GAAG;QACvB,yBAAyB,EAAE;YACzB;gBACE,OAAO,EAAE,eAAe;gBACxB,MAAM,EAAE,YAAY;aACrB;YACD;gBACE,OAAO,EAAE,sBAAsB;gBAC/B,MAAM,EAAE,YAAY;aACrB;SACF;KACF,CAAC;IACF,EAAE,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;QAC1C,MAAM,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,oBAAoB,EAAE,KAAK,IAAI,EAAE;QAClC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAChD,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC/C,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import { waitForPageErrors } from '../../browserforce.js';
|
|
54
|
+
import { BrowserforcePlugin } from '../../plugin.js';
|
|
55
|
+
const BASE_PATH = `/setup/ui/assignhomelayoutedit.jsp?retURL=${encodeURIComponent('/setup/forcecomHomepage.apexp')}`;
|
|
56
|
+
const BASE_SELECTOR = 'table.detailList';
|
|
57
|
+
const SAVE_BUTTON_SELECTOR = 'input[name="save"]';
|
|
58
|
+
export class HomePageLayouts extends BrowserforcePlugin {
|
|
59
|
+
async retrieve() {
|
|
60
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
61
|
+
try {
|
|
62
|
+
const page = __addDisposableResource(env_1, await this.browserforce.openPage(BASE_PATH), true);
|
|
63
|
+
await page.locator(BASE_SELECTOR).waitFor();
|
|
64
|
+
const profiles = (await page.locator('table.detailList tbody tr td label').allTextContents()).map((label) => label.replace(/^\*/, '')); // removing * from assistiveText
|
|
65
|
+
const layouts = (await page.locator('table.detailList tbody tr td select option:checked').allTextContents()).map((layout) => (layout === 'Home Page Default' ? '' : layout)); // value is "default" instead of an id
|
|
66
|
+
const homePageLayoutAssignments = profiles.map((profile, i) => ({
|
|
67
|
+
profile,
|
|
68
|
+
layout: layouts[i],
|
|
69
|
+
}));
|
|
70
|
+
return {
|
|
71
|
+
homePageLayoutAssignments,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
catch (e_1) {
|
|
75
|
+
env_1.error = e_1;
|
|
76
|
+
env_1.hasError = true;
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
const result_1 = __disposeResources(env_1);
|
|
80
|
+
if (result_1)
|
|
81
|
+
await result_1;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
diff(source, target) {
|
|
85
|
+
target.homePageLayoutAssignments.sort(compareAssignment);
|
|
86
|
+
const profileNames = target.homePageLayoutAssignments.map((assignment) => assignment.profile);
|
|
87
|
+
source.homePageLayoutAssignments = source.homePageLayoutAssignments
|
|
88
|
+
.filter((assignment) => profileNames.includes(assignment.profile))
|
|
89
|
+
.sort(compareAssignment);
|
|
90
|
+
return super.diff(source, target);
|
|
91
|
+
}
|
|
92
|
+
async apply(config) {
|
|
93
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
94
|
+
try {
|
|
95
|
+
const profilesList = config.homePageLayoutAssignments
|
|
96
|
+
.map((assignment) => {
|
|
97
|
+
return `'${assignment.profile}'`;
|
|
98
|
+
})
|
|
99
|
+
.join(',');
|
|
100
|
+
const layoutsList = config.homePageLayoutAssignments
|
|
101
|
+
.map((assignment) => {
|
|
102
|
+
return `'${assignment.layout}'`;
|
|
103
|
+
})
|
|
104
|
+
.join(',');
|
|
105
|
+
const profiles = await this.browserforce.connection.tooling.query(`SELECT Id, Name FROM Profile WHERE Name IN (${profilesList})`);
|
|
106
|
+
const homePageLayouts = await this.browserforce.connection.tooling.query(`SELECT Id, Name FROM HomePageLayout WHERE Name IN (${layoutsList})`);
|
|
107
|
+
const page = __addDisposableResource(env_2, await this.browserforce.openPage(BASE_PATH), true);
|
|
108
|
+
await page.locator(BASE_SELECTOR).waitFor();
|
|
109
|
+
for (const assignment of config.homePageLayoutAssignments) {
|
|
110
|
+
const homePageLayoutName = assignment.layout;
|
|
111
|
+
const profile = profiles.records.find((p) => p.Name === assignment.profile);
|
|
112
|
+
if (!profile) {
|
|
113
|
+
throw new Error(`could not find profile '${assignment.profile}'`);
|
|
114
|
+
}
|
|
115
|
+
let homePageLayout = homePageLayouts.records.find((l) => l.Name === homePageLayoutName);
|
|
116
|
+
if (homePageLayoutName === '') {
|
|
117
|
+
homePageLayout = { Id: 'default', Name: 'default' };
|
|
118
|
+
}
|
|
119
|
+
if (homePageLayout === undefined) {
|
|
120
|
+
throw new Error(`Could not find home page layout "${homePageLayoutName}" in list of home page layouts: ${homePageLayouts.records.map((l) => l.Name)}`);
|
|
121
|
+
}
|
|
122
|
+
const profileSelector = `select[id='${profile.Id.substring(0, 15)}']`;
|
|
123
|
+
await page.locator(profileSelector).selectOption(homePageLayout.Id.substring(0, 15));
|
|
124
|
+
}
|
|
125
|
+
await page.locator(SAVE_BUTTON_SELECTOR).first().click();
|
|
126
|
+
await Promise.race([
|
|
127
|
+
page.waitForURL((url) => url.pathname === '/setup/forcecomHomepage.apexp'),
|
|
128
|
+
waitForPageErrors(page),
|
|
129
|
+
]);
|
|
130
|
+
}
|
|
131
|
+
catch (e_2) {
|
|
132
|
+
env_2.error = e_2;
|
|
133
|
+
env_2.hasError = true;
|
|
134
|
+
}
|
|
135
|
+
finally {
|
|
136
|
+
const result_2 = __disposeResources(env_2);
|
|
137
|
+
if (result_2)
|
|
138
|
+
await result_2;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function compareAssignment(a, b) {
|
|
143
|
+
return `${a.profile}:${a.layout}`.localeCompare(`${b.profile}:${b.layout}`, 'en', { numeric: true });
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/home-page-layouts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAA0B,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,SAAS,GAAsB,6CAA6C,kBAAkB,CAAC,+BAA+B,CAAC,EAAE,CAAC;AAExI,MAAM,aAAa,GAAG,kBAAkB,CAAC;AACzC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AAmBlD,MAAM,OAAO,eAAgB,SAAQ,kBAAkB;IAC9C,KAAK,CAAC,QAAQ;;;YACnB,MAAY,IAAI,kCAAG,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAA,CAAC;YAC/D,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,CAAC;YAE5C,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,oCAAoC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC1G,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CACzB,CAAC,CAAC,gCAAgC;YAEnC,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,oDAAoD,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,GAAG,CAC9G,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,KAAK,mBAAmB,CAAC,C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