-
Notifications
You must be signed in to change notification settings - Fork 472
RI-8216 [PoC] Shared UI/API code location (ri-shared) #6058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
VaskoAtanasovRedis
wants to merge
1
commit into
main
Choose a base branch
from
feature/RI-8216/shared-utils-poc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| export * from './array-index.helper'; | ||
| export * from '../../ri-shared/utils/array-index'; | ||
| export * from './certificate-import.util'; | ||
| export * from './errors.util'; | ||
| export * from './merge.util'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # ri-shared — code shared across the RedisInsight apps (API + UI) | ||
|
|
||
| Modules here are consumed by **both** the API (relative imports, e.g. | ||
| `src/ri-shared/utils/array-index`) and the UI (the `riShared/*` path alias). They live | ||
| inside `api/src` because the api's production build (`nest build` → `node dist/src/main`) | ||
| compiles with `api/src` as the tsc rootDir — sources outside it restructure `dist/` and | ||
| break the packaged app. The UI/Storybook/jest aliases simply point into this folder, so | ||
| shared code ships with zero extra packaging surface (desktop bundles it like any api file). | ||
|
|
||
| ## What belongs here | ||
|
|
||
| - Cross-boundary **contracts**: value formats both sides must agree on (e.g. the | ||
| BigInt-as-string array index format), stable message formats, shared constants. | ||
| - Small **dependency-free** utilities needed verbatim on both sides. | ||
|
|
||
| ## Rules | ||
|
|
||
| - **No imports** from Nest, React, ioredis, lodash or anything else — dependency-free | ||
| TypeScript only (the UI and API have separate node_modules; nothing here may assume | ||
| either). | ||
| - **es2019-compatible**: the api compiles this folder with `target: es2019` — no BigInt | ||
| literals (`1n` is TS2737; use `BigInt('...')`), no newer syntax. | ||
| - API code style (semicolons) — this folder is linted by `yarn lint:api`. | ||
| - Tests live next to the module (`*.spec.ts`, runs under the api jest config) and define | ||
| the shared behavior once — UI consumers exercise it through their barrel imports. | ||
|
|
||
| ## Alias wiring (when adding the alias to a new consumer) | ||
|
|
||
| `redisinsight/ui/tsconfig.json` + `redisinsight/ui/vite.config.mjs` + | ||
| `redisinsight/ui/src/packages/vite.config.mjs` (Workbench plugin builds reach | ||
| the `uiSrc/utils` barrel) + `jest.config.cjs` (root, UI tests) + | ||
| `.storybook/vite.config.ts` + `redisinsight/desktop/tsconfig.json` all map | ||
| `riShared/*` → `redisinsight/api/src/ri-shared/*`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 11 additions & 5 deletions
16
...pi/src/common/utils/array-index.helper.ts → ...ht/api/src/ri-shared/utils/array-index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a shared package/dir should not be inside api folder, it would be in redisinsight/ri-shared
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good instinct, and I went down that path — but there's a build constraint that makes a true top-level
redisinsight/ri-sharedmuch more involved than a relocation, so I've kept it atapi/src/ri-sharedfor now. Reasoning:The API actually consumes this util (the array-index validator imports it), so it has to be compiled into the api's
dist. The api's tsconfig has no explicitrootDir, so tsc infers it from the common ancestor of all compiled files — today that'ssrc, giving usdist/src/.... The moment a file from../ri-sharedenters the compile, the common ancestor becomesredisinsight/and tsc emitsdist/api/src/main.js+dist/ri-shared/...instead.That breaks two things that hard-depend on the current layout:
node dist/src/main(thestart:prod/start:stageboot path)api/dist/src/...imports —desktop/src/lib/server/server.tsdoesimport server from '../../../../api/dist/src/main', plus the azure / cloud-auth / window-auth modulesapi-clientgets to live top-level only because it's UI-consumed and never goes throughnest build— ri-shared can't follow that pattern since the API compiles it.To put it genuinely top-level we'd need to make
ri-sharedits own independently-built TS unit (project reference + own dist) and wire it into both api runtime resolution and desktop packaging — a real chunk of work + new CI surface for what's currently one small shared util. Theapi/src/ri-sharedfolder keeps the "shared, dependency-free, both-sides" boundary explicit (see its README) with zero packaging risk. If we accumulate enough shared code to justify the standalone package later, happy to revisit — flag it if you'd rather take that on now.