-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
So we can have loot-core be the source of truth for some types that get passed through - Improves downstream development with API by including types - Use path aliases for dist vs dev tsconfigs - Convert api index to typescript as example - Permit ts-ignore for issues with our version of typescript
- Loading branch information
Showing
19 changed files
with
197 additions
and
63 deletions.
There are no files selected for viewing
This file contains 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,5 +1,6 @@ | ||
packages/api/app/bundle.api.js | ||
packages/api/dist | ||
packages/api/@types | ||
packages/api/migrations | ||
|
||
packages/crdt/dist | ||
|
This file contains 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 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 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,55 @@ | ||
// @ts-ignore: false-positive commonjs module error on build until typescript 5.3 | ||
import type { | ||
RequestInfo as FetchRequestInfo, | ||
RequestInit as FetchRequestInit, | ||
} from 'node-fetch'; // with { 'resolution-mode': 'import' }; | ||
|
||
// loot-core types | ||
import type { initConfig } from 'loot-core/server/main'; | ||
|
||
// eslint-disable-next-line import/extensions | ||
import * as bundle from './app/bundle.api.js'; | ||
import * as injected from './injected'; | ||
import { validateNodeVersion } from './validateNodeVersion'; | ||
|
||
let actualApp: null | typeof bundle.lib; | ||
export const internal = bundle.lib; | ||
|
||
// DEPRECATED: remove the next line in @actual-app/api v7 | ||
export * as methods from './methods'; | ||
|
||
export * from './methods'; | ||
export * as utils from './utils'; | ||
|
||
export async function init(config: initConfig = {}) { | ||
if (actualApp) { | ||
return; | ||
} | ||
|
||
validateNodeVersion(); | ||
|
||
if (!globalThis.fetch) { | ||
globalThis.fetch = (url: URL | RequestInfo, init?: RequestInit) => { | ||
return import('node-fetch').then(({ default: fetch }) => | ||
fetch( | ||
url as unknown as FetchRequestInfo, | ||
init as unknown as FetchRequestInit, | ||
), | ||
) as unknown as Promise<Response>; | ||
}; | ||
} | ||
|
||
await bundle.init(config); | ||
actualApp = bundle.lib; | ||
|
||
injected.override(bundle.lib.send); | ||
return bundle.lib; | ||
} | ||
|
||
export async function shutdown() { | ||
if (actualApp) { | ||
await actualApp.send('sync'); | ||
await actualApp.send('close-budget'); | ||
actualApp = null; | ||
} | ||
} |
This file contains 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 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 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 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,21 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
cd "$(dirname "$0")/.." || exit 1 | ||
ROOT="$(pwd -P)" | ||
|
||
yarn tsc -p tsconfig.api.json --outDir ../api/@types/loot-core/ | ||
# Copy existing handwritten .d.ts files, as tsc doesn't move them for us | ||
dest="../../api/@types/loot-core" | ||
cd src | ||
find . -type f -name "*.d.ts" | while read -r f | ||
do | ||
d=$(dirname "${f}") | ||
d="${dest}/${d}" | ||
mkdir -p "${d}" | ||
cp "${f}" "${d}" | ||
done | ||
cd "$ROOT" | ||
yarn webpack --config ./webpack/webpack.api.config.js; | ||
./bin/copy-migrations ../api |
This file contains 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 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 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 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 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 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 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,12 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"declaration": true, | ||
"emitDeclarationOnly": true, | ||
"allowJs": false, | ||
"noEmit": false, | ||
}, | ||
"include": ["./typings", "./src/server/*"], | ||
"exclude": ["**/node_modules/*", "**/build/*", "**/lib-dist/*", "./src/server/bench.ts"], | ||
} |
This file contains 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 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,6 @@ | ||
--- | ||
category: Maintenance | ||
authors: [twk3] | ||
--- | ||
|
||
Bundle loot-core types into the API |
Oops, something went wrong.