Skip to content

Commit

Permalink
Merge pull request DouglasNeuroInformatics#939 from joshunrau/main
Browse files Browse the repository at this point in the history
  • Loading branch information
joshunrau authored Sep 10, 2024
2 parents c17c23a + 4636b4b commit d8b5647
Show file tree
Hide file tree
Showing 115 changed files with 910 additions and 1,299 deletions.
1 change: 0 additions & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"@douglasneuroinformatics/esbuild-plugin-native-modules": "^1.0.0",
"@douglasneuroinformatics/esbuild-plugin-prisma": "^1.0.0",
"@nestjs/testing": "^10.4.1",
"@opendatacapture/esbuild-plugin-runtime": "workspace:*",
"@opendatacapture/instrument-stubs": "workspace:*",
"@types/express": "^4.17.21",
"@types/passport": "^1.0.16",
Expand Down
5 changes: 3 additions & 2 deletions apps/api/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import path from 'path';

import { nativeModulesPlugin } from '@douglasneuroinformatics/esbuild-plugin-native-modules';
import { prismaPlugin } from '@douglasneuroinformatics/esbuild-plugin-prisma';
import { runtimePlugin } from '@opendatacapture/esbuild-plugin-runtime';
import esbuild from 'esbuild';
import type { BuildOptions } from 'esbuild';
import esbuildPluginTsc from 'esbuild-plugin-tsc';
Expand Down Expand Up @@ -35,6 +34,8 @@ const { __dirname, __filename, require } = await (async () => {

const outfile = path.resolve(outdir, 'app.mjs');

const runtimeV1Dir = path.dirname(require.resolve('@opendatacapture/runtime-v1/package.json'));

const options: { external: NonNullable<unknown>; plugins: NonNullable<unknown> } & BuildOptions = {
banner: {
js: cjsShims
Expand All @@ -50,7 +51,6 @@ const options: { external: NonNullable<unknown>; plugins: NonNullable<unknown> }
esbuildPluginTsc({
tsconfigPath: tsconfig
}),
runtimePlugin({ outdir }),
prismaPlugin({ outdir: path.join(outdir, 'api') }),
nativeModulesPlugin()
],
Expand All @@ -72,6 +72,7 @@ async function clean() {
async function build() {
await clean();
await copyEsbuild();
await fs.cp(path.join(runtimeV1Dir, 'dist'), path.join(outdir, 'runtime', 'v1'), { recursive: true });
await esbuild.build(options);
console.log('Done!');
}
Expand Down
4 changes: 0 additions & 4 deletions apps/gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"dependencies": {
"@douglasneuroinformatics/libcrypto": "^0.0.2",
"@douglasneuroinformatics/libui": "catalog:",
"@opendatacapture/i18next": "workspace:*",
"@opendatacapture/instrument-renderer": "workspace:*",
"@opendatacapture/react-core": "workspace:*",
"@opendatacapture/runtime-core": "workspace:*",
Expand All @@ -28,21 +27,18 @@
"axios": "^1.7.7",
"compression": "^1.7.4",
"express": "^4.19.2",
"i18next": "catalog:",
"lodash-es": "workspace:lodash-es__4.x@*",
"pino-http": "^10.3.0",
"pino-pretty": "^11.2.2",
"react": "workspace:react__18.x@*",
"react-dom": "workspace:react-dom__18.x@*",
"react-i18next": "catalog:",
"sirv": "^2.0.4",
"sqlite3": "^5.1.7",
"zod": "workspace:zod__3.23.x@*"
},
"devDependencies": {
"@douglasneuroinformatics/esbuild-plugin-native-modules": "^1.0.0",
"@douglasneuroinformatics/esbuild-plugin-prisma": "^1.0.0",
"@opendatacapture/tailwindcss": "workspace:*",
"@opendatacapture/vite-plugin-runtime": "workspace:*",
"@types/compression": "^1.7.5",
"@types/express": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion apps/gateway/src/entry-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom/client';

import { Root } from './Root';

import '@douglasneuroinformatics/libui/styles/globals.css';
import '@douglasneuroinformatics/libui/tailwind/globals.css';

const ROOT_PROPS = window.__ROOT_PROPS__;

Expand Down
20 changes: 16 additions & 4 deletions apps/gateway/src/services/axios.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { useNotificationsStore } from '@douglasneuroinformatics/libui/hooks';
import { i18n } from '@douglasneuroinformatics/libui/i18n';
import axios, { isAxiosError } from 'axios';
import i18next from 'i18next';

axios.interceptors.request.use((config) => {
config.headers.setAccept('application/json');
config.timeout = 10000; // abort request after 10 seconds
config.timeoutErrorMessage = i18next.t('networkError');
config.timeoutErrorMessage = i18n.t({
en: 'Network Error',
fr: 'Erreur de réseau'
});
return config;
});

Expand All @@ -14,12 +17,21 @@ axios.interceptors.response.use(
(error) => {
const notifications = useNotificationsStore.getState();
if (!isAxiosError(error)) {
notifications.addNotification({ message: i18next.t('unknownError'), type: 'error' });
notifications.addNotification({
message: i18n.t({
en: 'Unknown Error',
fr: 'Erreur inconnue'
}),
type: 'error'
});
console.error(error);
return Promise.reject(error as Error);
}
notifications.addNotification({
message: i18next.t('httpRequestFailed'),
message: i18n.t({
en: 'HTTP Request Failed',
fr: 'Échec de la requête HTTP'
}),
title: error.response?.status.toString(),
type: 'error'
});
Expand Down
6 changes: 2 additions & 4 deletions apps/gateway/src/services/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { i18n } from '@opendatacapture/i18next';
import { i18n } from '@douglasneuroinformatics/libui/i18n';

await i18n.init();

export default i18n;
i18n.init();
6 changes: 2 additions & 4 deletions apps/gateway/tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// @ts-check
const config = require('@douglasneuroinformatics/libui/tailwind/config');

const { createConfig } = require('@opendatacapture/tailwindcss');

module.exports = createConfig({
module.exports = config({
content: ['index.html', './src/**/*.{js,ts,jsx,tsx}'],
include: ['@opendatacapture/instrument-renderer', '@opendatacapture/react-core'],
root: __dirname
Expand Down
2 changes: 1 addition & 1 deletion apps/gateway/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"/runtime/v1/*": ["../../runtime/v1/dist/*"]
}
},
"include": ["scripts/*", "src/**/*", "vite.config.ts"]
"include": ["scripts/*", "src/**/*", "tailwind.config.cjs", "vite.config.ts"]
}
1 change: 0 additions & 1 deletion apps/outreach/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"@astrojs/starlight-tailwind": "^2.0.3",
"@astrojs/tailwind": "^5.1.0",
"@opendatacapture/runtime-core": "workspace:*",
"@opendatacapture/tailwindcss": "workspace:*",
"@tailwindcss/typography": "^0.5.15",
"astro": "^4.15.4",
"github-slugger": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/outreach/src/styles/main.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '@douglasneuroinformatics/libui/styles/globals.css';
@import '@douglasneuroinformatics/libui/tailwind/globals.css';
@import './common.css';

@config "../../tailwind.config.cjs";
5 changes: 2 additions & 3 deletions apps/outreach/tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const { createConfig } = require('@opendatacapture/tailwindcss');
const config = require('@douglasneuroinformatics/libui/tailwind/config');
const typographyPlugin = require('@tailwindcss/typography');

/** @type {import('tailwindcss').Config} */
module.exports = createConfig({
module.exports = config({
content: ['./src/**/*.{astro,html,js,md,mdx,ts}'],
plugins: [typographyPlugin()],
root: __dirname
Expand Down
2 changes: 1 addition & 1 deletion apps/outreach/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"@/*": ["*"]
}
},
"include": ["astro.config.ts", "src/**/*", "*.js", "*.cjs"]
"include": ["astro.config.ts", "src/**/*", "tailwind.config.cjs", "tailwind.starlight.config.js"]
}
3 changes: 1 addition & 2 deletions apps/playground/.storybook/main.cts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ const config: StorybookConfig = {
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-themes',
'storybook-react-i18next'
'@storybook/addon-themes'
],
docs: {
autodocs: 'tag'
Expand Down
9 changes: 4 additions & 5 deletions apps/playground/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { i18n } from '@opendatacapture/i18next';
import { i18n } from '@douglasneuroinformatics/libui/i18n';
import { withThemeByDataAttribute } from '@storybook/addon-themes';
import type { Preview } from '@storybook/react';

import '@douglasneuroinformatics/libui/styles/globals.css';
import '@douglasneuroinformatics/libui/tailwind/globals.css';

await i18n.init();
i18n.init();

const preview: Preview = {
decorators: [
Expand All @@ -31,8 +31,7 @@ const preview: Preview = {
color: /(background|color)$/i,
date: /Date$/
}
},
i18n
}
}
};

Expand Down
3 changes: 0 additions & 3 deletions apps/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"@douglasneuroinformatics/libjs": "^0.6.0",
"@douglasneuroinformatics/libui": "catalog:",
"@monaco-editor/react": "^4.6.0",
"@opendatacapture/i18next": "workspace:*",
"@opendatacapture/instrument-bundler": "workspace:*",
"@opendatacapture/instrument-renderer": "workspace:*",
"@opendatacapture/react-core": "workspace:*",
Expand All @@ -38,15 +37,13 @@
"react-dom": "workspace:react-dom__18.x@*",
"react-dropzone": "^14.2.3",
"react-error-boundary": "^4.0.13",
"react-i18next": "catalog:",
"stacktrace-parser": "^0.1.10",
"ts-pattern": "workspace:ts-pattern__5.x@*",
"zod": "workspace:zod__3.23.x@*",
"zod-validation-error": "^3.3.1",
"zustand": "^4.5.5"
},
"devDependencies": {
"@opendatacapture/tailwindcss": "workspace:*",
"@opendatacapture/vite-plugin-runtime": "workspace:*",
"@vitejs/plugin-react-swc": "^3.7.0",
"autoprefixer": "^10.4.20",
Expand Down
3 changes: 0 additions & 3 deletions apps/playground/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import React from 'react';

import { NotificationHub } from '@douglasneuroinformatics/libui/components';
import { i18n } from '@opendatacapture/i18next';
import { ErrorPage, LoadingPage } from '@opendatacapture/react-core';
import { ErrorBoundary } from 'react-error-boundary';

const IndexPage = React.lazy(() => import('./pages/IndexPage'));

await i18n.init();

export const App = () => {
return (
<React.Suspense
Expand Down
6 changes: 5 additions & 1 deletion apps/playground/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import React from 'react';
import ReactDOM from 'react-dom/client';

import { i18n } from '@douglasneuroinformatics/libui/i18n';

import { App } from './App';

import '@douglasneuroinformatics/libui/styles/globals.css';
import '@douglasneuroinformatics/libui/tailwind/globals.css';

const root = document.getElementById('root')!;

i18n.init();

ReactDOM.createRoot(root).render(
<React.StrictMode>
<App />
Expand Down
2 changes: 1 addition & 1 deletion apps/playground/src/vim/keymap_vim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function attachVimMap(
this: {
attach: (adapter: EditorAdapter, prev?: KeyMapEntry) => void;
call: (key: string, adapter: EditorAdapter) => (() => boolean) | false | undefined;
detach: (adapter: EditorAdapter, next?: KeyMapEntry | undefined) => void;
detach: (adapter: EditorAdapter, next?: KeyMapEntry) => void;
fallthrough?: string[];
keys?: { Backspace: string };
},
Expand Down
6 changes: 2 additions & 4 deletions apps/playground/tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// @ts-check
const config = require('@douglasneuroinformatics/libui/tailwind/config');

const { createConfig } = require('@opendatacapture/tailwindcss');

module.exports = createConfig({
module.exports = config({
content: ['index.html', './src/**/*.{js,ts,jsx,tsx}'],
include: ['@opendatacapture/instrument-renderer', '@opendatacapture/react-core'],
root: __dirname
Expand Down
2 changes: 1 addition & 1 deletion apps/playground/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
},
"types": ["@opendatacapture/runtime-v1/env", "vite/client"]
},
"include": [".storybook/*", "src/**/*", "vite.config.ts"]
"include": [".storybook/*", "src/**/*", "tailwind.config.cjs", "vite.config.ts"]
}
3 changes: 1 addition & 2 deletions apps/web/.storybook/main.cts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ const config: StorybookConfig = {
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-themes',
'storybook-react-i18next'
'@storybook/addon-themes'
],
docs: {
autodocs: 'tag'
Expand Down
8 changes: 3 additions & 5 deletions apps/web/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { withThemeByDataAttribute } from '@storybook/addon-themes';
import esbuild from 'esbuild-wasm';
import esbuildWasmUrl from 'esbuild-wasm/esbuild.wasm?url';

import i18n from '../src/services/i18n';

import '@douglasneuroinformatics/libui/styles/globals.css';
import '@douglasneuroinformatics/libui/tailwind/globals.css';
import '../src/services/i18n';

await esbuild.initialize({
wasmURL: esbuildWasmUrl
Expand Down Expand Up @@ -36,8 +35,7 @@ const preview = {
color: /(background|color)$/i,
date: /Date$/
}
},
i18n
}
}
};

Expand Down
65 changes: 0 additions & 65 deletions apps/web/config/translations.ts

This file was deleted.

Loading

0 comments on commit d8b5647

Please sign in to comment.