Skip to content

Conversation

@hollyschinsky
Copy link
Collaborator

Description

Reworks addOnUISdk constants reference and adds a new how-to, as a result of general dev confusion and LLM testing. See: https://jira.corp.adobe.com/browse/EXTDEVEX-48

Related Issue

https://jira.corp.adobe.com/browse/EXTDEVEX-48

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Collaborator

@nimithajalal nimithajalal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Left a few comments.


## Why Use Constants?

Constants equal their variable name as a string (e.g., `ButtonType.primary` equals `"primary"`), but using constants provides type safety, IDE autocomplete, and future-proofing against API changes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constants provide named references to string values (e.g., ButtonType.primary represents the string "primary"). Using constants instead of raw strings gives you type safety, IDE autocomplete, and protection against future API changes.


<InlineAlert slots="header,text1" variant="warning"/>

#### Important
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this heading. Warning should be sufficient.


### Event Handling

**Critical:** Event constants must be imported - they're not available in the constants object:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Event constants are named export only — they must be imported and cannot be accessed through the constants object:

```javascript
import addOnUISdk, { AppEvent } from "https://new.express.adobe.com/static/add-on-sdk/sdk.js";

// ✅ Correct - must import AppEvent
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct - AppEvent is imported

updateUITheme(event.theme);
});

// ❌ This will NOT work
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a line saying why this will not work?

❌ This will NOT work - AppEvent is not in constants object

}
```

## Common Pitfalls
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Common Pitfalls & Solutions

## Common Pitfalls

### Environment Confusion

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add the problem here first?

Problem: Trying to use document constants in the wrong environment.

## Related Documentation

- [Document APIs Reference](../../../references/document-sandbox/document-apis/)
- [Document APIs Constants](../../../references/document-sandbox/document-apis/enumerations/ArrowHeadType.md)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is ArrowHead the right link or is it to Constants?


Some constants (like `AppEvent`, `SupportedMimeTypes`) are **only available as named exports** and cannot be accessed through `addOnUISdk.constants.*`. See [Import Patterns](#import-patterns) below.

## Most Common Use Cases
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment as constants file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comments to the previous.

@hollyschinsky hollyschinsky changed the title Reworks all addOnUISdk constants ref and explanation, new how-to Addresses LLM Content Gaps (runtime architecture, project anatomy, terminology, constants rework and usage guides) Oct 7, 2025
@hollyschinsky hollyschinsky deleted the ui-sdk-constants-rework branch October 21, 2025 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants