Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1be71cc
introducing Tuple
codefriar Oct 3, 2023
c00518b
Feat(Tuple): Introducing Tuple
codefriar Oct 18, 2023
96372af
fix(Tuple.cls): Adding doc blocks
codefriar Oct 18, 2023
03a26b7
refactor(Tuple): accepting CodeRabit review suggestions
codefriar Oct 18, 2023
83a3a29
refactor(Tuple): accepting CodeRabit review suggestions
codefriar Oct 18, 2023
b62047d
fix(ci-pr.yml): formatting
codefriar Oct 18, 2023
8207b77
Update ci-pr.yml
codefriar Oct 6, 2023
940717f
build(npm): bump @cparra/apexdocs from 2.17.0 to 2.17.1 (#115)
dependabot[bot] Oct 6, 2023
93e2031
build(npm): bump eslint from 8.50.0 to 8.51.0 (#116)
dependabot[bot] Oct 9, 2023
805c0bb
build(npm): bump @cparra/apexdocs from 2.17.1 to 2.17.2 (#117)
dependabot[bot] Oct 11, 2023
dfed13f
build(npm): bump marked from 9.1.0 to 9.1.1 (#118)
dependabot[bot] Oct 12, 2023
b4a5956
build(npm): bump marked from 9.1.1 to 9.1.2 (#120)
dependabot[bot] Oct 16, 2023
fecbea5
build(npm): bump lint-staged from 14.0.1 to 15.0.1 (#119)
dependabot[bot] Oct 16, 2023
d19e20e
build(npm): bump @babel/traverse from 7.23.0 to 7.23.2 (#121)
dependabot[bot] Oct 16, 2023
4cce47c
Update ci-pr.yml
codefriar Oct 16, 2023
ee3f6df
refactor(ci-pr.yml): fixing this branches' ci-pr yml
codefriar Oct 19, 2023
9ff506b
Update project-scratch-def.json
codefriar Oct 19, 2023
0efb55e
fix(project-scratch-def): removing pre-release
codefriar Oct 19, 2023
b8486d1
fix(project-scratch-def): removing pre-release
codefriar Oct 20, 2023
56bec3a
fix(project-scratch-def): removing pre-release check from create scra…
codefriar Oct 20, 2023
e0115b6
rename directory, update exclusions
dschach Oct 28, 2023
b8a13cd
Merge branch 'main' into feat/AddTupple
codefriar Dec 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
# openai_engine: "text-davinci-002" #optional
openai_temperature: 0.5 #optional
openai_max_tokens: 2048 #optional
mode: file # file or patch
mode: file # file or patch

# Formatting only runs on human-submitted and Dependabot PRs
format-and-linting:
Expand Down Expand Up @@ -145,13 +145,13 @@ jobs:
run: sf org login sfdx-url -f ./DEVHUB_SFDX_URL.txt -a devhub -d

# Create prerelease scratch org
- name: 'Create prerelease scratch org'
if: ${{ env.IS_PRERELEASE }}
run: sf org create scratch -f config/project-scratch-def.json -a scratch-org -d -y 1 --release=preview
# - name: 'Create prerelease scratch org'
# if: ${{ env.IS_PRERELEASE }}
# run: sf org create scratch -f config/project-scratch-def.json -a scratch-org -d -y 1 --release=preview

# Create scratch org
- name: 'Create scratch org'
if: ${{ !env.IS_PRERELEASE }}
# if: ${{ !env.IS_PRERELEASE }}
run: sf org create scratch -f config/project-scratch-def.json -a scratch-org -d -y 1

# Deploy source to scratch org
Expand Down
162 changes: 162 additions & 0 deletions docs/Tuple.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
`APIVERSION: 58`

`STATUS: ACTIVE`

Tuple represents a key-value pair. Kinda. Don't come at me math nerds.
You may be asking why this exists, given the existence of Map. Unfortuately Map isn't available everywhere.
Notably, it's not available in Apex-defined Data Types used by Flow/Invocable actions.
Additionally, `Object` is not a valid data type in Apex-defined Data Types, so we can't use a list of objects
that have a string key, and Object value. This is the next best thing. A kind of polyfill for Map<String,Object>
for use in Apex-defined Data Types.
See also: https://help.salesforce.com/s/articleView?id=sf.flow_considerations_apex_data_type.htm&type=5
Available primitive datatypes available for use in tuple:
Boolean, Integer, Long, Decimal, Double, Date, DateTime, and String. Single values and lists are supported for each data type.

## Constructors

### `public Tuple()`

`SUPPRESSWARNINGS`

In order to create a Tuple instance from within a flow, you need a no-arg constructor.

### `public Tuple(String key, Object value)`

standard constructor accepting a key and value

#### Parameters

| Param | Description |
| ------- | ----------------------------------- |
| `key` | String the name of the Tuple's Key. |
| `value` | Object the Tuple's Value. |

---

## Fields

### `public booleanValue``Boolean`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public booleans``Boolean`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public dateTimeValue``Datetime`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public dateValue``Date`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public dates``Date`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public datetimes``Datetime`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public decimalValue``Decimal`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public decimals``Decimal`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public doubleValue``Double`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public doubles``Double`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public integerValue``Integer`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public integers``Integer`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public key``String`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public longValue``Long`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public longs``Long`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public sobjectValue``SObject`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public sobjects``SObject`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public stringValue``String`

`AURAENABLED`
`INVOCABLEVARIABLE`

### `public strings``String`

`AURAENABLED`
`INVOCABLEVARIABLE`

---

## Methods

### `private void determineTypeAndSetCastedValue(Object value)`

`SUPPRESSWARNINGS`

Method is responsible for determining the type of the value and setting the appropriate field.

#### Parameters

| Param | Description |
| ------- | ------------------------- |
| `value` | Object the Tuple's Value. |

---

## Classes

### TupleException

A custom Exception type thrown when the incoming Object is not a recognized Apex-defined-type safe
type.

**Inheritance**

TupleException

---
8 changes: 8 additions & 0 deletions docs/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,14 @@ inner class for managing the loop count per handler
### [TriggerFrameworkTests](https://github.com/codefriar/ApexKit/wiki/Miscellaneous/TriggerFrameworkTests)


### [Tuple](https://github.com/codefriar/ApexKit/wiki/Miscellaneous/Tuple)

Tuple represents a key-value pair. Kinda. Don't come at me math nerds.
You may be asking why this exists, given the existence of Map. Unfortuately Map isn't available everywhere.
Notably, it's not available in Apex-defined Data Types used by Flow/Invocable actions.
Additionally, `Object` is not a v…


### [UFInvocable](https://github.com/codefriar/ApexKit/wiki/Miscellaneous/UFInvocable)

This provides a common interface for classes & methods developers want to expose to flow.
Expand Down
152 changes: 152 additions & 0 deletions force-app/main/default/classes/Data Structures/Tuple.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/**
* @description Tuple represents a key-value pair. Kinda. Don't come at me math nerds.
*
* You may be asking why this exists, given the existence of Map. Unfortuately Map isn't available everywhere.
* Notably, it's not available in Apex-defined Data Types used by Flow/Invocable actions.
*
* Additionally, `Object` is not a valid data type in Apex-defined Data Types, so we can't use a list of objects
* that have a string key, and Object value. This is the next best thing. A kind of polyfill for Map<String,Object>
* for use in Apex-defined Data Types.
*
* See also: https://help.salesforce.com/s/articleView?id=sf.flow_considerations_apex_data_type.htm&type=5
* Available primitive datatypes available for use in tuple:
* Boolean, Integer, Long, Decimal, Double, Date, DateTime, and String. Single values and lists are supported for each data type.
*/
@SuppressWarnings('PMD.StdCyclomaticComplexity')
public with sharing class Tuple {
@AuraEnabled
@InvocableVariable
public String key;

@AuraEnabled
@InvocableVariable
public Boolean[] booleans;
@AuraEnabled
@InvocableVariable
public Boolean booleanValue;
@AuraEnabled
@InvocableVariable
public Date dateValue;
@AuraEnabled
@InvocableVariable
public Date[] dates;
@AuraEnabled
@InvocableVariable
public Datetime[] datetimes;
@AuraEnabled
@InvocableVariable
public Datetime dateTimeValue;
@AuraEnabled
@InvocableVariable
public Double doubleValue;
@AuraEnabled
@InvocableVariable
public Double[] doubles;
@AuraEnabled
@InvocableVariable
public Decimal decimalValue;
@AuraEnabled
@InvocableVariable
public Decimal[] decimals;
@AuraEnabled
@InvocableVariable
public Integer integerValue;
@AuraEnabled
@InvocableVariable
public Integer[] integers;
@AuraEnabled
@InvocableVariable
public Long longValue;
@AuraEnabled
@InvocableVariable
public Long[] longs;
@AuraEnabled
@InvocableVariable
public String stringValue;
@AuraEnabled
@InvocableVariable
public String[] strings;
@AuraEnabled
@InvocableVariable
public SObject sobjectValue;
@AuraEnabled
@InvocableVariable
public SObject[] sobjects;

/**
* @description In order to create a Tuple instance from within a flow, you need a no-arg constructor.
*/
@SuppressWarnings('PMD.EmptyStatementBlock')
public Tuple() {
}

/**
* @description standard constructor accepting a key and value
* @param key String the name of the Tuple's Key.
* @param value Object the Tuple's Value.
*/
public Tuple(String key, Object value) {
if (key == null) {
throw new TupleException('Key cannot be null');
}
if (value == null) {
throw new TupleException('Value cannot be null');
}
this.key = key;
determineTypeAndSetCastedValue(value);
}

/**
* @description Method is responsible for determining the type of the value and setting the appropriate field.
* @param value Object the Tuple's Value.
*/
@SuppressWarnings('PMD.CyclomaticComplexity, PMD.StdCyclomaticComplexity')
private void determineTypeAndSetCastedValue(Object value) {
if (value instanceof Boolean) {
this.booleanValue = (Boolean) value;
} else if (value instanceof List<Boolean>) {
this.booleans = (List<Boolean>) value;
} else if (value instanceof Datetime) {
this.dateTimeValue = (Datetime) value;
} else if (value instanceof List<Datetime>) {
this.datetimes = (List<Datetime>) value;
} else if (value instanceof Date) {
this.dateValue = (Date) value;
} else if (value instanceof List<Date>) {
this.dates = (List<Date>) value;
} else if (value instanceof Long) {
this.longValue = (Long) value;
} else if (value instanceof List<Long>) {
this.longs = (List<Long>) value;
} else if (value instanceof Integer) {
this.integerValue = (Integer) value;
} else if (value instanceof List<Integer>) {
this.integers = (List<Integer>) value;
} else if (value instanceof Decimal) {
this.decimalValue = (Decimal) value;
} else if (value instanceof List<Decimal>) {
this.decimals = (List<Decimal>) value;
} else if (value instanceof Double) {
this.doubleValue = (Double) value;
} else if (value instanceof List<Double>) {
this.doubles = (List<Double>) value;
} else if (value instanceof String) {
this.stringValue = (String) value;
} else if (value instanceof List<String>) {
this.strings = (List<String>) value;
} else if (value instanceof List<SObject>) {
this.sobjects = (List<SObject>) value;
} else if (value instanceof SObject) {
this.sobjectValue = (SObject) value;
} else {
throw new TupleException('Unsupported data type: ' + value);
}
}

/**
* @description A custom Exception type thrown when the incoming Object is not a recognized Apex-defined-type safe
* type.
*/
public class TupleException extends Exception {
}
}
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>