This repository was archived by the owner on Oct 14, 2026. It is now read-only.
Repository navigation
Commit 0acce60
feat(utils): add semantic lookup source/entity type registries (LLMO-7445) (#1959)
<!-- mysticat-pr-skill -->
## 1. Abstract
Adds the semantic lookup type lists to `@adobe/spacecat-shared-utils`
constants: `OPPORTUNITY_SEMANTIC_SOURCE_TYPES` /
`OPPORTUNITY_SEMANTIC_ENTITY_TYPES`, which today live in data-access,
and the upcoming `SUGGESTION_SEMANTIC_SOURCE_TYPES` /
`SUGGESTION_SEMANTIC_ENTITY_TYPES`. They're exported from both the main
entry and the `/constants` subpath.
## 2. Reasoning
The allowed `sourceTypes` / `entityTypes` for the semantic lookup (`POST
/sites/:siteId/opportunities/by-topics`, and later the suggestion
endpoints) are defined in `spacecat-shared-data-access`. The UI
(project-elmo-ui) needs the same values for its SDK types, but it can't
import data-access in a browser bundle: that package has no browser
entry, and its entry point pulls in the S3, PostgREST, `@adobe/fetch`
and X-Ray clients plus Node's `crypto`. The utils `/constants` subpath
is dependency-free and already consumed by the UI, so moving the lists
here gives the writer, the reader and the UI one source instead of
hand-copied lists.
## 3. High-level overview of the changes
- Four frozen lists in `constants.js`:
- opportunity source types: `topic`;
- opportunity entity types: `cited-analysis`, `reddit-analysis`,
`youtube-analysis`, built from `OPPORTUNITY_TYPES`;
- suggestion source types: `topic`, `title`;
- suggestion entity types: the same three opportunity types.
- They're exported from `@adobe/spacecat-shared-utils` and
`@adobe/spacecat-shared-utils/constants`, with explicit literal types in
`constants.d.ts`, so TypeScript consumers can derive exact unions (e.g.
`typeof X[keyof typeof X]`).
- The suggestion lists are added now, with the values settled in the
suggestion lookup plan, so the upcoming suggestion work doesn't need
another utils release.
- Additive only; no existing export changes. data-access keeps its own
copies until a follow-up PR imports and re-exports these (no API change
for its consumers).
- Found while doing this: the existing `OPPORTUNITY_TYPES` typing
resolves to `any`, because `index.d.ts` and `constants.d.ts` re-export
it from each other. That's why the new lists spell out their literal
types instead of referring to `OPPORTUNITY_TYPES`. The existing typing
is left as is here, since giving it real types could break consumers
that rely on `any`.
## 4. Required information
- Jira / issue:
[LLMO-7445](https://jira.corp.adobe.com/browse/LLMO-7445)
- ADR(s): [ADR 0002 — embedding client and semantic index
utils](https://github.com/adobe/spacecat-shared/blob/main/docs/adr/0002-embedding-client-and-semantic-index-utils.md)
- Other: the lists currently live in
`packages/spacecat-shared-data-access/src/util/semantic-index.utils.js`,
added in #1950
## 6. Affected / used mysticat-workspace projects
- `spacecat-shared-data-access` (consumed): the follow-up PR bumps its
utils version (currently fixed at 1.105.0), imports these lists, and
re-exports them under the same names.
- `project-elmo-ui` (consumed): the by-topics SDK derives its
`sourceTypes` / `entityTypes` types from
`@adobe/spacecat-shared-utils/constants`.
- `spacecat-api-service`, `spacecat-audit-worker` (unchanged): they keep
importing the lists from data-access, which re-exports the same values.
## 7. Additional information outside the code
- Type check in a scratch TypeScript project (`moduleResolution:
bundler`, `strict`) against this branch:
`OPPORTUNITY_SEMANTIC_ENTITY_TYPES` derives the exact `'cited-analysis'
| 'reddit-analysis' | 'youtube-analysis'` union through both the main
entry and the `/constants` subpath, and assigning `'wikipedia-analysis'`
to it is a type error. The same probe against `OPPORTUNITY_TYPES`
accepted any value, which confirmed its typing is `any`.
## 8. Test plan
- (a) Local: the scratch TypeScript check above.
- (b) After release: in project-elmo-ui, bump
`@adobe/spacecat-shared-utils`, import the entity/source lists from
`@adobe/spacecat-shared-utils/constants`, and confirm `npm run build`
succeeds (browser bundle) with the derived types. In data-access,
confirm its unit and integration tests pass after switching to the
imported lists.
## 9. Deployment & merge order
- This PR merges and releases first (utils minor version).
- Then a data-access PR (depends on this release): bump the utils
version, import and re-export the lists.
- Then project-elmo-ui (depends on this release only): replace the
hand-written unions in the by-topics SDK with types derived from utils.
Order: this PR → data-access PR → project-elmo-ui PR (the last two can
go in parallel once this is released).
🤖 Generated with
[review-kit](https://github.com/adobe/experience-success-skills)
---------
Co-authored-by: Tanase Butcaru <tbutcaru@adobe.com>1 parent fc75b50 commit 0acce60
7 files changed
Lines changed: 158 additions & 1 deletion
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
20 | 31 | | |
21 | 32 | | |
22 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
96 | 103 | | |
97 | 104 | | |
98 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
113 | 115 | | |
114 | 116 | | |
115 | 117 | | |
| |||
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
| 135 | + | |
| 136 | + | |
133 | 137 | | |
134 | 138 | | |
135 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| |||
0 commit comments