-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flow support for change data capture events (#130)
- Loading branch information
1 parent
de90bd1
commit 5d3fb5d
Showing
12 changed files
with
390 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,34 @@ | ||
{ | ||
"packageDirectories": [ | ||
{ | ||
"path": "trigger-actions-framework", | ||
"default": true, | ||
"package": "Trigger Actions Framework", | ||
"versionName": "Version 0.2", | ||
"versionNumber": "0.2.1.NEXT" | ||
} | ||
], | ||
"namespace": "", | ||
"sfdcLoginUrl": "https://login.salesforce.com", | ||
"sourceApiVersion": "56.0", | ||
"packageAliases": { | ||
"Trigger Actions Framework": "0Ho3h0000008Om4CAE", | ||
"Trigger Actions Framework@0.1.0-1": "04t3h000004VaHaAAK", | ||
"Trigger Actions Framework@0.1.2": "04t3h000004VaIdAAK", | ||
"Trigger Actions Framework@0.1.3": "04t3h000004VaInAAK", | ||
"Trigger Actions Framework@0.1.4-0": "04t3h000004VaJWAA0", | ||
"Trigger Actions Framework@0.1.4-1": "04t3h000004VaJbAAK", | ||
"Trigger Actions Framework@0.1.5-0": "04t3h000004VaJqAAK", | ||
"Trigger Actions Framework@0.1.6": "04t3h000004VaLDAA0", | ||
"Trigger Actions Framework@0.1.7": "04t3h000004VaLIAA0", | ||
"Trigger Actions Framework@0.1.8": "04t3h000004VaLNAA0", | ||
"Trigger Actions Framework@0.1.9": "04t3h000004VaLSAA0", | ||
"Trigger Actions Framework@0.2.0": "04t3h000004VaLmAAK", | ||
"Trigger Actions Framework@0.2.1": "04t3h000004VaVFAA0", | ||
"Trigger Actions Framework@0.2.2-1": "04t3h000004OYREAA4", | ||
"Trigger Actions Framework@0.2.3-1": "04t3h000004OYTKAA4", | ||
"Trigger Actions Framework@0.2.5-1": "04t3h000004OYUDAA4", | ||
"Trigger Actions Framework@0.2.6-1": "04t3h000004juLaAAI" | ||
} | ||
} | ||
"packageDirectories": [ | ||
{ | ||
"path": "trigger-actions-framework", | ||
"default": true, | ||
"package": "Trigger Actions Framework", | ||
"versionName": "Version 0.2", | ||
"versionNumber": "0.2.8.NEXT" | ||
} | ||
], | ||
"namespace": "", | ||
"sfdcLoginUrl": "https://login.salesforce.com", | ||
"sourceApiVersion": "59.0", | ||
"packageAliases": { | ||
"Trigger Actions Framework": "0Ho3h0000008Om4CAE", | ||
"Trigger Actions Framework@0.1.0-1": "04t3h000004VaHaAAK", | ||
"Trigger Actions Framework@0.1.2": "04t3h000004VaIdAAK", | ||
"Trigger Actions Framework@0.1.3": "04t3h000004VaInAAK", | ||
"Trigger Actions Framework@0.1.4-0": "04t3h000004VaJWAA0", | ||
"Trigger Actions Framework@0.1.4-1": "04t3h000004VaJbAAK", | ||
"Trigger Actions Framework@0.1.5-0": "04t3h000004VaJqAAK", | ||
"Trigger Actions Framework@0.1.6": "04t3h000004VaLDAA0", | ||
"Trigger Actions Framework@0.1.7": "04t3h000004VaLIAA0", | ||
"Trigger Actions Framework@0.1.8": "04t3h000004VaLNAA0", | ||
"Trigger Actions Framework@0.1.9": "04t3h000004VaLSAA0", | ||
"Trigger Actions Framework@0.2.0": "04t3h000004VaLmAAK", | ||
"Trigger Actions Framework@0.2.1": "04t3h000004VaVFAA0", | ||
"Trigger Actions Framework@0.2.2-1": "04t3h000004OYREAA4", | ||
"Trigger Actions Framework@0.2.3-1": "04t3h000004OYTKAA4", | ||
"Trigger Actions Framework@0.2.5-1": "04t3h000004OYUDAA4", | ||
"Trigger Actions Framework@0.2.6-1": "04t3h000004juLaAAI", | ||
"Trigger Actions Framework@0.2.8": "04t3h000004juLuAAI" | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
trigger-actions-framework/main/default/classes/FlowChangeEventHeader.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
Copyright 2023 Google LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
https://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
@SuppressWarnings('PMD.ApexDoc') | ||
public with sharing class FlowChangeEventHeader { | ||
@InvocableVariable | ||
@AuraEnabled | ||
public String entityName; | ||
@InvocableVariable | ||
@AuraEnabled | ||
public List<String> recordIds; | ||
@InvocableVariable | ||
@AuraEnabled | ||
public String changeType; | ||
@InvocableVariable | ||
@AuraEnabled | ||
public String changeOrigin; | ||
@InvocableVariable | ||
@AuraEnabled | ||
public String transactionKey; | ||
@InvocableVariable | ||
@AuraEnabled | ||
public Integer sequenceNumber; | ||
@InvocableVariable | ||
@AuraEnabled | ||
public Long commitTimestamp; | ||
@InvocableVariable | ||
@AuraEnabled | ||
public String commitUser; | ||
@InvocableVariable | ||
@AuraEnabled | ||
public Long commitNumber; | ||
@InvocableVariable | ||
@AuraEnabled | ||
public List<String> nulledFields; | ||
@InvocableVariable | ||
@AuraEnabled | ||
public List<String> diffFields; | ||
@InvocableVariable | ||
@AuraEnabled | ||
public List<String> changedFields; | ||
|
||
public FlowChangeEventHeader(EventBus.ChangeEventHeader header) { | ||
this.entityName = header.entityName; | ||
this.recordIds = header.recordIds; | ||
this.changeType = header.changeType; | ||
this.changeOrigin = header.changeOrigin; | ||
this.transactionKey = header.transactionKey; | ||
this.sequenceNumber = header.sequenceNumber; | ||
this.commitTimestamp = header.commitTimestamp; | ||
this.commitUser = header.commitUser; | ||
this.commitNumber = header.commitNumber; | ||
this.nulledFields = header.nulledFields; | ||
this.diffFields = header.diffFields; | ||
this.changedFields = header.changedFields; | ||
} | ||
|
||
public Boolean equals(Object obj) { | ||
if (obj != null && obj instanceof FlowChangeEventHeader) { | ||
FlowChangeEventHeader other = (FlowChangeEventHeader) obj; | ||
return this.entityName == other.entityName && | ||
this.recordIds == other.recordIds && | ||
this.changeType == other.changeType && | ||
this.changeOrigin == other.changeOrigin && | ||
this.transactionKey == other.transactionKey && | ||
this.sequenceNumber == other.sequenceNumber && | ||
this.commitTimestamp == other.commitTimestamp && | ||
this.commitUser == other.commitUser && | ||
this.commitNumber == other.commitNumber && | ||
this.nulledFields == other.nulledFields && | ||
this.diffFields == other.diffFields && | ||
this.changedFields == other.changedFields; | ||
} | ||
return false; | ||
} | ||
|
||
public Integer hashCode() { | ||
return JSON.serialize(this).hashCode(); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
trigger-actions-framework/main/default/classes/FlowChangeEventHeader.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>58.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
57 changes: 57 additions & 0 deletions
57
trigger-actions-framework/main/default/classes/FlowChangeEventHeaderTest.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
Copyright 2023 Google LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
https://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
@IsTest(isParallel=true) | ||
@SuppressWarnings('PMD.ApexDoc') | ||
private with sharing class FlowChangeEventHeaderTest { | ||
private static FlowChangeEventHeader header = new FlowChangeEventHeader( | ||
new EventBus.ChangeEventHeader() | ||
); | ||
|
||
@IsTest | ||
private static void shouldBeAbleToConstruct() { | ||
Assert.isNotNull(header, 'Unable to construct a FlowChangeEventHeader'); | ||
} | ||
|
||
@IsTest | ||
private static void shouldBeAbleToGenerateHashCode() { | ||
Assert.isNotNull(header.hashCode(), 'Hash code was not generated'); | ||
} | ||
|
||
@IsTest | ||
private static void shouldBeAbleToCompare() { | ||
FlowChangeEventHeader other = new FlowChangeEventHeader( | ||
new EventBus.ChangeEventHeader() | ||
); | ||
other.changeType = 'CREATE'; | ||
|
||
Assert.areEqual( | ||
new FlowChangeEventHeader(new EventBus.ChangeEventHeader()), | ||
header, | ||
'Unable to detect identical FlowChangeEventHeader objects' | ||
); | ||
Assert.areNotEqual( | ||
header, | ||
other, | ||
'Unable to detect different FlowChangeEventHeader objects' | ||
); | ||
Assert.areNotEqual( | ||
header, | ||
null, | ||
'Unable to detect difference between FlowChangeEventHeader and null' | ||
); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
trigger-actions-framework/main/default/classes/FlowChangeEventHeaderTest.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>58.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
Oops, something went wrong.