adobe / acc-js-sdk

A JavaScript SDK for Adobe Campaign Classic
Apache License 2.0
21 stars 20 forks source link

NEO-63455: allow duplicated enum values #90

Closed obriard closed 1 year ago

obriard commented 1 year ago

Allow duplicated enum values in schemas

Description

Fix issue in temp schema generated in the workflow with an enrichement activity An example of a schema taht contents a duplicated enum value e029d4880:

<extension xmlns="urn:xtk:queryDef" label="Enrichment : get last 2 products bought" mappingType="sql" name="enrich" namespace="temp">
    <enumeration basetype="string" name="e029d4880">
        <value desc="Computer" label="Computer" name="computer" value="computer"/>
        <value desc="Watch" label="Watch" name="watch" value="watch"/>
    </enumeration>
    <enumeration basetype="string" name="e029d4880">
        <value desc="Computer" label="Computer" name="computer" value="computer"/>
        <value desc="Watch" label="Watch" name="watch" value="watch"/>
    </enumeration>
    <element advanced="false" label="Enrichment : get last 2 products bought" name="enrich" pkSequence="" sqltable="grp5170" unbound="false">
        <compute-string expr=""/>
        <key internal="true" name="internal">
            <keyfield xpath="@id"/>
        </key>
        <attribute advanced="false" belongsTo="@id" label="Primary key" length="0" name="id" notNull="false" sql="true" sqlname="iId" type="long" xml="false"/>
        <element advanced="false" belongsTo="purchase1" label="Retail - Purchases" length="0" name="purchase1" notNull="false" type="" unbound="false">
            <attribute advanced="false" belongsTo="purchase1/product/brand/@name" label="Name (Product/Brand)" length="255" name="name" notNull="false" sql="true" sqlname="sPurchase1Name" type="string" xml="false"/>
            <attribute advanced="false" belongsTo="purchase1/product/@category" enum="temp:enrich:e029d4880" label="Category (Product)" length="255" name="category" notNull="false" sql="true" sqlname="sPurchase1Category" type="string" xml="false"/>
        </element>
        <element advanced="false" belongsTo="purchase2" label="Retail - Purchases" length="0" name="purchase2" notNull="false" type="" unbound="false">
            <attribute advanced="false" belongsTo="purchase2/product/brand/@name" label="Name (Product/Brand)" length="255" name="name" notNull="false" sql="true" sqlname="sPurchase2Name" type="string" xml="false"/>
            <attribute advanced="false" belongsTo="purchase2/product/@category" enum="temp:enrich:e029d4880" label="Category (Product)" length="255" name="category" notNull="false" sql="true" sqlname="sPurchase2Category" type="string" xml="false"/>
        </element>
        <element advanced="false" externalJoin="false" label="Targeting dimension" name="target" revLink="" target="nms:recipient" type="link" unbound="false">
            <join xpath-dst="@id" xpath-src="@id"/>
        </element>
    </element>
</extension>

Related Issue

Issue found while testing web ui https://jira.corp.adobe.com/browse/NEO-63455 The issue causes the display of audience properties to fail. this fix is temporary and it will be reverted when the issue on backend side will be fixed. The ticket opened to fix the duplicated values on acc backend side is https://jira.corp.adobe.com/browse/NEO-63689

Motivation and Context

Able to create the schema object in the sdk even with duplicated enumerations values to able to see schema in Acc web ui. For information in the client console the duplication does not caused any issue.

How Has This Been Tested?

a unit test tested in acc web ui

Screenshots (if appropriate):

error in console.log:

Error: Failed to add element 'e029d4880' to ArrayMap. There's already an item with the same name
    at ArrayMap._push (util.js:205:1)
    at new XtkSchema (application.js:1227:1)
    at newSchema (application.js:52:1)
    at Application._getSchema (application.js:1414:1)
    at async SchemaCache.getSchema (application.js:96:1)
    at async edit.tsx:418:1

Types of changes

Checklist: