Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

###

- Support for Point Address V3 element type

## [8.9.0] - 2025-10-26

### Added
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 85 additions & 39 deletions src/conditionalLogicService/evaluateConditionalPredicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,53 +174,99 @@ export default function evaluateConditionalPredicate({
}
return
case 'ADDRESS_PROPERTY': {
// Only element that should work as predicate element should be Point or Geoscape.
// Only element types that should work as predicate element should be Point, Point V3 or Geoscape.
if (
!(
predicateElement.type === 'pointAddress' ||
predicateElement.type === 'geoscapeAddress'
)
predicateElement.type === 'pointAddress' ||
predicateElement.type === 'geoscapeAddress' ||
predicateElement.type === 'pointAddressV3'
) {
return
}
if (predicateValue && typeof predicateValue === 'object') {
if (predicate.definition.property === 'STATE_EQUALITY') {
// Validate that it has the properties we want, in case submission data
// is incorrect but has the right element reference.
if (
'addressDetails' in predicateValue &&
predicateValue.addressDetails &&
typeof predicateValue.addressDetails === 'object' &&
'stateTerritory' in predicateValue.addressDetails &&
typeof predicateValue.addressDetails.stateTerritory === 'string'
) {
const result =
predicateValue.addressDetails.stateTerritory ===
predicate.definition.value
if (result) {
return predicateElement
if (predicateValue && typeof predicateValue === 'object') {
if (predicate.definition.property === 'STATE_EQUALITY') {
switch (predicateElement.type) {
case 'pointAddressV3': {
if (
'properties' in predicateValue &&
predicateValue.properties &&
typeof predicateValue.properties === 'object' &&
'stateTerritory' in predicateValue.properties &&
typeof predicateValue.properties.stateTerritory === 'string'
) {
// Validate that it has the properties we want, in case submission data
// is incorrect but has the right element reference.
const result =
predicateValue.properties.stateTerritory ===
predicate.definition.value
if (result) {
return predicateElement
}
return
}
break
}
case 'geoscapeAddress':
case 'pointAddress': {
// Validate that it has the properties we want, in case submission data
// is incorrect but has the right element reference.
if (
'addressDetails' in predicateValue &&
predicateValue.addressDetails &&
typeof predicateValue.addressDetails === 'object' &&
'stateTerritory' in predicateValue.addressDetails &&
typeof predicateValue.addressDetails.stateTerritory ===
'string'
) {
const result =
predicateValue.addressDetails.stateTerritory ===
predicate.definition.value
if (result) {
return predicateElement
}
return
}
}
}
}
return
}
// If the property isn't State Equality, we are checking Physical addresses. This only exists for Point.
if (predicateElement.type === 'pointAddress') {
// If the value is true, we only want to return the element for PO Boxes. If it's false, then we only want
// to return element for non mail address addresses.
if (
'dataset' in predicateValue &&
typeof predicateValue.dataset === 'string'
) {
const result = predicate.definition.value
? predicateValue.dataset === 'mailAddress'
: predicateValue.dataset === 'GNAF'
if (result) {
return predicateElement
// If the property isn't State Equality, we are checking Physical addresses. This only exists for Point and Point V3.
switch (predicateElement.type) {
case 'pointAddressV3': {
// If the value is true, we only want to return the element for PO Boxes. If it's false, then we only want
// to return element for non mail address addresses.
if (
'properties' in predicateValue &&
predicateValue.properties &&
typeof predicateValue.properties === 'object' &&
'dataset' in predicateValue.properties &&
typeof predicateValue.properties.dataset === 'string'
) {
const result = predicate.definition.value
? predicateValue.properties.dataset.startsWith('mailAddress')
: predicateValue.properties.dataset.startsWith('gnaf')
if (result) {
return predicateElement
}
}
break
}
case 'pointAddress': {
// If the value is true, we only want to return the element for PO Boxes. If it's false, then we only want
// to return element for non mail address addresses.
if (
'dataset' in predicateValue &&
typeof predicateValue.dataset === 'string'
) {
const result = predicate.definition.value
? predicateValue.dataset === 'mailAddress'
: predicateValue.dataset === 'GNAF'
if (result) {
return predicateElement
}
}
break
}
}
}
}
return
break
}
case 'OPTIONS':
default: {
Expand Down
9 changes: 9 additions & 0 deletions src/replaceCustomValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,15 @@ function formatValue({
value: value?.addressDetails?.formattedAddress || value?.addressId,
}
}
case 'pointAddressV3': {
const value =
unknownValue as PointTypes.PointAddressV3GetAddressDetailsResponse
return {
element: element,
value:
value.properties?.formattedAddress || value.properties?.addressId,
}
}
case 'googleAddress': {
const value = unknownValue as GoogleTypes.GoogleMapsAddress
return {
Expand Down
2 changes: 2 additions & 0 deletions src/typeCastService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const toLookupElement = (
case 'telephone':
case 'pointCadastralParcel':
case 'pointAddress':
case 'pointAddressV3':
case 'geoscapeAddress':
case 'civicaStreetName':
case 'bsb':
Expand Down Expand Up @@ -198,6 +199,7 @@ const toAutoLookupElement = (e: FormTypes.FormElement) => {
case 'pointCadastralParcel':
case 'geoscapeAddress':
case 'pointAddress':
case 'pointAddressV3':
case 'compliance':
case 'civicaStreetName':
case 'autocomplete':
Expand Down
113 changes: 113 additions & 0 deletions tests/conditionalLogicService/evaluateConditionalPredicate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ describe('evaluateConditionalPredicate', () => {
definition: { property: 'IS_PO_BOX_ADDRESS', value: true },
}

const conditionalPredicatePointV3: ConditionTypes.ConditionalPredicate = {
elementId: 'predicatePointV3',
type: 'ADDRESS_PROPERTY',
definition: { property: 'IS_PO_BOX_ADDRESS', value: true },
}

const conditionalPredicateGeoscape: ConditionTypes.ConditionalPredicate = {
elementId: 'predicateGeoscape',
type: 'ADDRESS_PROPERTY',
Expand All @@ -267,6 +273,17 @@ describe('evaluateConditionalPredicate', () => {
isElementLookup: false,
}

const predicatePointV3: FormTypes.PointAddressV3Element = {
id: 'predicatePointV3',
name: 'predicatePointV3',
label: 'predicatePointV3',
type: 'pointAddressV3',
required: false,
conditionallyShow: false,
isDataLookup: false,
isElementLookup: false,
}

const predicateGeoscape: FormTypes.GeoscapeAddressElement = {
id: 'predicateGeoscape',
name: 'predicateGeoscape',
Expand Down Expand Up @@ -304,6 +321,34 @@ describe('evaluateConditionalPredicate', () => {
})
expect(isShown).toBe(predicatePoint)
})
test('should show element using NSW Point V3 PO Box', () => {
const shownElement: FormTypes.FormElement = {
id: 'shownNumber',
name: 'shownNumber',
label: 'shownNumber',
type: 'number',
required: false,
isSlider: false,
conditionallyShow: true,
conditionallyShowPredicates: [conditionalPredicatePointV3],
isDataLookup: false,
isElementLookup: false,
}
const isShown = evaluateConditionalPredicate({
predicate: conditionalPredicatePointV3,
formElementsCtrl: {
flattenedElements: [predicatePointV3, shownElement],
model: {
predicatePointV3: {
properties: {
dataset: 'mailAddress',
},
},
},
},
})
expect(isShown).toBe(predicatePointV3)
})
test('should show element using NSW Point physical address', () => {
const conditionalPredicatePointNoPO: ConditionTypes.ConditionalPredicate =
{
Expand Down Expand Up @@ -337,6 +382,39 @@ describe('evaluateConditionalPredicate', () => {
})
expect(isShown).toBe(predicatePoint)
})
test('should show element using NSW Point V3 physical address', () => {
const conditionalPredicatePointNoPO: ConditionTypes.ConditionalPredicate =
{
elementId: 'predicatePointV3',
type: 'ADDRESS_PROPERTY',
definition: { property: 'IS_PO_BOX_ADDRESS', value: false },
}

const shownElement: FormTypes.FormElement = {
id: 'shownNumber',
name: 'shownNumber',
label: 'shownNumber',
type: 'number',
required: false,
isSlider: false,
conditionallyShow: true,
conditionallyShowPredicates: [conditionalPredicatePointNoPO],
isDataLookup: false,
isElementLookup: false,
}
const isShown = evaluateConditionalPredicate({
predicate: conditionalPredicatePointNoPO,
formElementsCtrl: {
flattenedElements: [predicatePointV3, shownElement],
model: {
predicatePointV3: {
properties: { dataset: 'gnaf,mailingAddress' },
},
},
},
})
expect(isShown).toBe(predicatePointV3)
})
test('should show element using NSW Point with states', () => {
const conditionalPredicatePointStates: ConditionTypes.ConditionalPredicate =
{
Expand Down Expand Up @@ -372,6 +450,41 @@ describe('evaluateConditionalPredicate', () => {
})
expect(isShown).toBe(predicatePoint)
})
test('should show element using NSW Point V3 with states', () => {
const conditionalPredicatePointStates: ConditionTypes.ConditionalPredicate =
{
elementId: 'predicatePointV3',
type: 'ADDRESS_PROPERTY',
definition: { property: 'STATE_EQUALITY', value: 'NSW' },
}

const shownElement: FormTypes.FormElement = {
id: 'shownNumber',
name: 'shownNumber',
label: 'shownNumber',
type: 'number',
required: false,
isSlider: false,
conditionallyShow: true,
conditionallyShowPredicates: [conditionalPredicatePointStates],
isDataLookup: false,
isElementLookup: false,
}
const isShown = evaluateConditionalPredicate({
predicate: conditionalPredicatePointStates,
formElementsCtrl: {
flattenedElements: [predicatePointV3, shownElement],
model: {
predicatePointV3: {
properties: {
stateTerritory: 'NSW',
},
},
},
},
})
expect(isShown).toBe(predicatePointV3)
})
test('should show element using Geoscape with States', () => {
const shownElement: FormTypes.FormElement = {
id: 'shownNumber',
Expand Down