feat: extract shared infrastructure from shared_lib

Phase 1-3 of decoupling plan:
- Shared DB, models, infrastructure, browser, config, utils
- Event infrastructure (domain_events outbox, bus, processor)
- Structured logging
- Generic container concept (container_type/container_id)
- Alembic migrations for all schema changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-11 12:45:56 +00:00
commit ef806f8fbb
533 changed files with 276497 additions and 0 deletions

21
editor/node_modules/@tryghost/koenig-lexical/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2013-2026 Ghost Foundation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

130
editor/node_modules/@tryghost/koenig-lexical/README.md generated vendored Normal file
View File

@@ -0,0 +1,130 @@
# Koenig - Lexical edition
Ghost editor, based on the Lexical framework.
## Development
The editor can be run in two modes:
- standalone mode: demo version that runs without a dependency on Ghost
- integrated mode: integrated into Ghost Admin
### Standalone mode
Run `yarn dev` to start the editor in standalone mode for development on http://localhost:5173. This command generates a demo site from the `index.html` file, which renders the demo app in `demo/demo.jsx`.
### Integrated mode
In order to run the editor inside Ghost Admin, follow the 3 steps below:
1. Link Koenig server-side dependencies inside Ghost
- Run `yarn link` inside `Koenig/packages/kg-default-nodes` and `Koenig/packages/kg-lexical-html-renderer`
- Paste the output at the root of the Ghost monorepo:
- `yarn link @tryghost/kg-default-nodes`
- `yarn link @tryghost/kg-lexical-html-renderer`
2. Start Ghost in dev mode: inside the Ghost monorepo, run `yarn dev --lexical`.
3. Start the editor in dev mode: inside the Koenig monorepo, run `yarn dev`.
Now, if you navigate to Ghost Admin at http://localhost:2368/ghost and open a post, it will use your local version of the editor. Changes to the editor will be reflected inside Ghost Admin after a few seconds - the time for the editor to get rebuilt.
### Specific card setup
#### Gif card
To see this card locally, you need to create `.env.local` file in `koenig-lexical` root package with the next data:
```
VITE_TENOR_API_KEY=xxx
```
How to get the tenor key is described here https://ghost.org/docs/config/#tenor
#### Bookmark & Embed cards
These cards make external web requests. Since the demo doesn't have a server to process these requests, we must fetch these resources on the front end. To do this we need to enable CORS, which is most easily done with a browser extension like 'Test CORS' for Chrome. Otherwise you will see blocked requests logging errors in the console. This can also be avoided by using test data directly without fetching via `fetchEmbed.js`.
## Additional notes
### Project structure
**`/src`**
The main module source. `/src/index.js` is the entry point for the exposed module and should export everything needed to use the module from an external app.
**`/demo`**
Used for developing/demoing the editor. Renders a blank editor with all features enabled.
### Styling
**CSS**
Styling should be done using Tailwind classes where possible.
All styles are scoped under `.koenig-lexical` class to avoid clashes and keep styling as isolated as possible. PostCSS nesting support is present to make this easier.
- Styles located in `src/styles/` are included in the final built module.
- Styles located in `demo/*.css` are only used in the demo and will not be included in the built module.
When packaging the module, styles are included inside the JS file rather than being separate to allow for a single import of the module in the consuming app.
**SVGs**
SVGs can be imported as React components in the [same way as create-react-app](https://create-react-app.dev/docs/adding-images-fonts-and-files/#adding-svgs). Typically files are stored in `src/assets/`.
All imported files are processed/optimised via SVGO (see `svgo.config.js` for optimisation config) and included in the built JS file.
## Testing
We use [Vitest](https://vitest.dev) for unit tests and [Playwright](https://playwright.dev) for e2e testing.
- `yarn test` runs all tests and exits
- `yarn test:unit` runs unit tests
- `yarn test:unit:watch` runs unit tests and starts a test watcher that re-runs tests on file changes
- `yarn test:unit:watch --ui` runs unit tests and opens a browser UI for exploring and re-running tests
- `yarn test:e2e` runs e2e tests
- `yarn test:e2e --headed` runs tests in browser so you can watch the tests execute
- `yarn test:slowmo` same as `yarn test:e2e --headed` but adds 100ms delay between instructions to make it easier to see what's happening (note that some tests may fail or timeout due to the added delays)
- `yarn test:e2e --ui` opens a [browser UI](https://playwright.dev/docs/test-ui-mode) in watch mode for exploring and re-running tests
- `yarn test:e2e --ui --headed` same as `yarn test:e2e --ui` but also runs tests in browser so you can watch the tests execute
Before tests are started we build a version of the demo app that is used for the unit tests.
When developing it can be useful to limit unit tests to specific keywords (taken from `describe` or `it/test` names). That's possible using the `-t` param and works with any of the above test commands, e.g.:
- `yarn test:unit:watch -t "buildCardMenu"`
### How to debug e2e tests on CI
You can download the report in case of tests were failed. It can be found in the actions `Summary` in the `Artifacts` section.
To check traces, run command `npx playwright show-trace trace.zip`.
More information about traces can be found here https://playwright.dev/docs/trace-viewer
### ESM in e2e tests
Node enables ECMAScript modules if `type: 'module'` in package.json file. It leads to some restrictions:
- [No require, exports, module.exports, __filename, __dirname](https://github.com/GrosSacASac/node/blob/master/doc/api/esm.md#no-require-exports-moduleexports-__filename-__dirname)
- [Mandatory file extensions](https://github.com/GrosSacASac/node/blob/master/doc/api/esm.md#mandatory-file-extensions)
- [No require.extensions](https://github.com/GrosSacASac/node/blob/master/doc/api/esm.md#no-requireextensions). It means we don't have control over the extensions list. Further will be a description of why this is important.
We can make file extension optional with [--experimental-specifier-resolution](https://nodejs.org/api/cli.html#--experimental-specifier-resolutionmode)
flag, which we use. But node is not recognized `jsx` extension.
It can be solved with [node loaders](https://github.com/nodejs/loaders-test/tree/main/commonjs-extension-resolution-loader), whereas
as they're still in [experimental mode](https://nodejs.org/api/esm.html#esm_experimental_loaders), there is no appropriate
implementation for this use case.
The same issue was raised in the babel repo, but the loader won't be added while node loaders are
in [experimental mode](https://github.com/babel/babel/issues/11934).
We can add our loader implementation to solve the issue. Still, in reality, we shouldn't need real
JSX components in e2e tests. It can be a situation when some constants locate in the `jsx` file. In this case,
we can move them to js file. If it is a problem in the future, we can add our implementation of the loader or
add an extension to all imports in the project.
### Editor integration
There's a [vitest vscode extension](https://marketplace.visualstudio.com/items?itemName=ZixuanChen.vitest-explorer) that
lets you run and debug individual unit tests/groups directly inside vscode.
## Deployment
Koenig packages are shipped via Lerna at the monorepo level. Please refer to the monorepo's [README](../../README.md) for deployment instructions.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,135 @@
{
"name": "@tryghost/koenig-lexical",
"version": "1.7.10",
"repository": "https://github.com/TryGhost/Koenig/tree/master/packages/koenig-lexical",
"author": "Ghost Foundation",
"license": "MIT",
"type": "module",
"files": [
"LICENSE",
"README.md",
"dist/"
],
"main": "./dist/koenig-lexical.umd.js",
"module": "./dist/koenig-lexical.js",
"exports": {
".": {
"import": "./dist/koenig-lexical.js",
"require": "./dist/koenig-lexical.umd.js"
}
},
"scripts": {
"dev": "concurrently \"vite --host --force\" \"yarn build --watch\" \"yarn preview -l silent --host\" \"yarn workspace @tryghost/kg-default-nodes dev\" \"yarn workspace @tryghost/kg-default-transforms dev\"",
"dev:multiplayer": "concurrently \"vite\" \"yarn multiplayer\"",
"dev:test": "concurrently \"vite --port 5174\" \"yarn multiplayer\"",
"multiplayer": "HOST=localhost PORT=1234 npx y-websocket-server",
"build": "vite build",
"build:demo": "vite build --config vite.config.demo.js",
"preview": "vite preview",
"pretest": "VITE_TEST=true yarn build --config vite.config.demo.js",
"test": "yarn test:unit && yarn test:e2e",
"test:unit": "vitest run",
"test:unit:watch": "vitest",
"test:e2e": "NODE_ENV=test NODE_OPTIONS='--experimental-specifier-resolution=node --no-warnings' VITE_TEST=true playwright test",
"test:e2e:headed": "PLAYWRIGHT_HEADED=true yarn test:e2e",
"test:e2e:report": "PLAYWRIGHT_HTML_REPORT=true yarn test:e2e",
"test:e2e:quiet": "yarn test:e2e --reporter=line",
"test:slowmo": "TIMEOUT=100000 PLAYWRIGHT_SLOWMO=100 yarn test:e2e:headed",
"test:storybook": "test-storybook",
"pretest:watch": "yarn pretest",
"posttest": "yarn lint",
"coverage": "vitest run --coverage",
"lint": "yarn run lint:js && yarn run lint:css",
"lint:css": "stylelint \"src/**/*.css\"",
"lint:js": "eslint --ext .js,.cjs,.jsx --cache demo src test",
"prepare": "NODE_ENV=production yarn build",
"storybook": "NODE_OPTIONS=--openssl-legacy-provider storybook dev -p 6006 -h 127.0.0.1",
"build-storybook": "storybook build"
},
"devDependencies": {
"@babel/core": "7.29.0",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@codemirror/lang-css": "6.3.1",
"@codemirror/lang-html": "6.4.11",
"@codemirror/lang-javascript": "6.2.4",
"@emoji-mart/data": "^1.1.2",
"@emoji-mart/react": "^1.1.1",
"@etchteam/storybook-addon-status": "^8.0.0",
"@lexical/clipboard": "0.13.1",
"@lexical/list": "0.13.1",
"@lexical/react": "0.13.1",
"@lexical/selection": "0.13.1",
"@lexical/text": "0.13.1",
"@lexical/utils": "0.13.1",
"@lezer/highlight": "^1.2.2",
"@mdx-js/rollup": "^3.1.0",
"@playwright/test": "^1.50.1",
"@prettier/sync": "^0.6.0",
"@sentry/vite-plugin": "4.8.0",
"@storybook/addon-actions": "^9.0.0",
"@storybook/addon-essentials": "^8.5.0",
"@storybook/addon-interactions": "^8.5.0",
"@storybook/addon-links": "^10.2.1",
"@storybook/addon-mdx-gfm": "^8.5.0",
"@storybook/builder-vite": "10.2.3",
"@storybook/react": "^10.2.1",
"@storybook/react-vite": "10.2.3",
"@storybook/test-runner": "^0.24.1",
"@testing-library/dom": "10.4.1",
"@testing-library/jest-dom": "6.9.1",
"@testing-library/react": "16.3.2",
"@tryghost/color-utils": "0.2.13",
"@tryghost/helpers": "1.1.100",
"@tryghost/kg-clean-basic-html": "4.2.14",
"@tryghost/kg-converters": "1.1.14",
"@tryghost/kg-default-nodes": "2.0.9",
"@tryghost/kg-default-transforms": "1.2.32",
"@tryghost/kg-markdown-html-renderer": "7.1.9",
"@tryghost/kg-simplemde": "3.0.8",
"@tryghost/kg-unsplash-selector": "0.3.13",
"@types/react": "18.3.27",
"@types/react-dom": "18.3.7",
"@uiw/react-codemirror": "^4.23.0",
"@vitejs/plugin-react": "4.7.0",
"@vitest/coverage-c8": "0.33.0",
"@vitest/ui": "4.0.18",
"autoprefixer": "10.4.24",
"babel-loader": "10.0.0",
"clsx": "^2.0.0",
"codemirror": "^6.0.1",
"concurrently": "^9.2.0",
"cross-fetch": "^4.0.0",
"dompurify": "^3.3.0",
"dotenv": "^17.0.0",
"emoji-mart": "^5.5.2",
"eslint-config-react-app": "7.0.1",
"eslint-plugin-jest": "29.12.1",
"eslint-plugin-react": "7.37.5",
"eslint-plugin-storybook": "^10.2.1",
"eslint-plugin-tailwindcss": "3.18.2",
"eventemitter3": "^5.0.1",
"fast-average-color": "^9.4.0",
"jsdom": "24.1.3",
"lexical": "0.13.1",
"pluralize": "^8.0.0",
"postcss": "8.5.6",
"postcss-import": "16.1.1",
"prettier": "3.6.2",
"react": "^18.2.0",
"react-colorful": "^5.6.1",
"react-dom": "^18.2.0",
"react-highlight": "^0.15.0",
"react-router-dom": "7.13.0",
"react-slider": "^2.0.6",
"storybook": "^10.2.1",
"stylelint": "17.1.0",
"tailwindcss": "3.4.19",
"typescript": "5.9.3",
"vite": "5.4.21",
"vite-plugin-svgr": "4.5.0",
"vitest": "4.0.18",
"y-websocket": "^3.0.0",
"yjs": "^13.6.28"
},
"gitHead": "1106e818f8acbf1e81da5ac80c3e46b317f1efde"
}