@openmrs/esm-metadataexport-app 4.4.1-pre.684
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +6 -0
- package/README.md +15 -0
- package/dist/105.js +1 -0
- package/dist/105.js.map +1 -0
- package/dist/117.js +1 -0
- package/dist/117.js.map +1 -0
- package/dist/121.js +1 -0
- package/dist/121.js.map +1 -0
- package/dist/192.js +1 -0
- package/dist/192.js.map +1 -0
- package/dist/309.js +1 -0
- package/dist/309.js.map +1 -0
- package/dist/339.js +1 -0
- package/dist/339.js.map +1 -0
- package/dist/359.js +11 -0
- package/dist/359.js.map +1 -0
- package/dist/425.js +32 -0
- package/dist/425.js.map +1 -0
- package/dist/466.js +1 -0
- package/dist/466.js.map +1 -0
- package/dist/529.js +1 -0
- package/dist/529.js.map +1 -0
- package/dist/572.js +1 -0
- package/dist/572.js.map +1 -0
- package/dist/61.js +1 -0
- package/dist/61.js.map +1 -0
- package/dist/689.js +1 -0
- package/dist/689.js.map +1 -0
- package/dist/697.js +1 -0
- package/dist/697.js.map +1 -0
- package/dist/712.js +1 -0
- package/dist/712.js.map +1 -0
- package/dist/720.js +1 -0
- package/dist/720.js.map +1 -0
- package/dist/771.js +1 -0
- package/dist/771.js.map +1 -0
- package/dist/789.js +1 -0
- package/dist/789.js.map +1 -0
- package/dist/913.js +1 -0
- package/dist/913.js.map +1 -0
- package/dist/989.js +1 -0
- package/dist/989.js.map +1 -0
- package/dist/main.js +6 -0
- package/dist/main.js.map +1 -0
- package/dist/openmrs-esm-metadataexport-app.js +6 -0
- package/dist/openmrs-esm-metadataexport-app.js.buildmanifest.json +677 -0
- package/dist/openmrs-esm-metadataexport-app.js.map +1 -0
- package/dist/routes.json +1 -0
- package/package.json +56 -0
- package/rspack.config.js +1 -0
- package/src/admin-card-link.component.tsx +34 -0
- package/src/components/dashboard/dashboard-view.component.tsx +16 -0
- package/src/components/dashboard/home-dashboard.component.tsx +17 -0
- package/src/components/dashboard/home-dashboard.scss +18 -0
- package/src/components/metadata-export-header/metadata-export-header.component.tsx +16 -0
- package/src/components/metadata-export-header/metadata-export-header.scss +21 -0
- package/src/components/metadata-export-header/metadata-export-header.test.tsx +18 -0
- package/src/components/new-package/add-package-action-button/add-package-action-button.component.tsx +34 -0
- package/src/components/new-package/add-package-action-button/add-package-action-button.test.tsx +57 -0
- package/src/components/new-package/new-package-utils.ts +8 -0
- package/src/components/new-package/new-package.workspace.scss +58 -0
- package/src/components/new-package/new-package.workspace.test.tsx +206 -0
- package/src/components/new-package/new-package.workspace.tsx +197 -0
- package/src/components/packages-table/packages-table.component.tsx +122 -0
- package/src/components/packages-table/packages-table.scss +5 -0
- package/src/components/packages-table/packages-table.test.tsx +56 -0
- package/src/config-schema.ts +3 -0
- package/src/constants.ts +1 -0
- package/src/declarations.d.ts +23 -0
- package/src/domain-lookups/domain-lookups.resource.ts +33 -0
- package/src/index.ts +28 -0
- package/src/packages/packages.resource.ts +31 -0
- package/src/root.component.tsx +13 -0
- package/src/root.scss +5 -0
- package/src/root.test.tsx +12 -0
- package/src/routes.json +31 -0
- package/src/types/index.ts +41 -0
- package/translations/en.json +22 -0
- package/tsconfig.json +4 -0
- package/vitest.config.ts +4 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import useSWR from 'swr';
|
|
2
|
+
import { type FetchResponse, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
3
|
+
import { type MetadataDomain } from '../types';
|
|
4
|
+
|
|
5
|
+
export function useDomains() {
|
|
6
|
+
const apiUrl = `${restBaseUrl}/metadataexport/domains`;
|
|
7
|
+
const { data, error, isLoading, isValidating, mutate } = useSWR<FetchResponse<Array<MetadataDomain>>, Error>(
|
|
8
|
+
apiUrl,
|
|
9
|
+
openmrsFetch,
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
domains: data?.data ?? [],
|
|
14
|
+
isLoading,
|
|
15
|
+
isValidating,
|
|
16
|
+
error,
|
|
17
|
+
mutate,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function getDomains(): Promise<FetchResponse<Array<MetadataDomain>>> {
|
|
22
|
+
const apiUrl = `${restBaseUrl}/metadataexport/domains`;
|
|
23
|
+
return openmrsFetch(apiUrl);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Converts a domain identifier such as `ENCOUNTER_TYPES` into a human readable
|
|
28
|
+
* label such as `Encounter types`.
|
|
29
|
+
*/
|
|
30
|
+
export function formatDomainLabel(domain: MetadataDomain): string {
|
|
31
|
+
const text = domain.replace(/_/g, ' ').trim().toLowerCase();
|
|
32
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
33
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getAsyncLifecycle, defineConfigSchema } from '@openmrs/esm-framework';
|
|
2
|
+
import { configSchema } from './config-schema';
|
|
3
|
+
import { moduleName } from './constants';
|
|
4
|
+
|
|
5
|
+
const options = {
|
|
6
|
+
featureName: 'metadataexport',
|
|
7
|
+
moduleName,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');
|
|
11
|
+
|
|
12
|
+
export function startupApp() {
|
|
13
|
+
defineConfigSchema(moduleName, configSchema);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Root component
|
|
17
|
+
export const root = getAsyncLifecycle(() => import('./root.component'), options);
|
|
18
|
+
|
|
19
|
+
// Extensions
|
|
20
|
+
export const metadataExportCardLink = getAsyncLifecycle(() => import('./admin-card-link.component'), options);
|
|
21
|
+
|
|
22
|
+
// Modals
|
|
23
|
+
|
|
24
|
+
// Workspaces
|
|
25
|
+
export const newPackageWorkspace = getAsyncLifecycle(
|
|
26
|
+
() => import('./components/new-package/new-package.workspace'),
|
|
27
|
+
options,
|
|
28
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import useSWR from 'swr';
|
|
2
|
+
import { type FetchResponse, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
3
|
+
import { type ExportPackage, type ExportPackageRequest } from '../types/index';
|
|
4
|
+
|
|
5
|
+
export function useAllPackages(includeRetired = false) {
|
|
6
|
+
const apiUrl = `${restBaseUrl}/metadataexport/packages?includeRetired=${includeRetired}`;
|
|
7
|
+
const { data, error, isLoading, isValidating, mutate } = useSWR<FetchResponse<Array<ExportPackage>>, Error>(
|
|
8
|
+
apiUrl,
|
|
9
|
+
openmrsFetch,
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
packages: data?.data ?? [],
|
|
14
|
+
isLoading,
|
|
15
|
+
isValidating,
|
|
16
|
+
error,
|
|
17
|
+
mutate,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function createPackage(
|
|
22
|
+
payload: ExportPackageRequest,
|
|
23
|
+
abortController?: AbortController,
|
|
24
|
+
): Promise<FetchResponse<ExportPackage>> {
|
|
25
|
+
return openmrsFetch<ExportPackage>(`${restBaseUrl}/metadataexport/packages`, {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
headers: { 'Content-Type': 'application/json' },
|
|
28
|
+
body: payload,
|
|
29
|
+
signal: abortController?.signal,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
|
3
|
+
import Dashboard from './components/dashboard/home-dashboard.component';
|
|
4
|
+
|
|
5
|
+
const Root: React.FC = () => (
|
|
6
|
+
<BrowserRouter basename={window.getOpenmrsSpaBase()}>
|
|
7
|
+
<Routes>
|
|
8
|
+
<Route path="metadataexport" element={<Dashboard />} />
|
|
9
|
+
</Routes>
|
|
10
|
+
</BrowserRouter>
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export default Root;
|
package/src/root.scss
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { describe, it, expect } from 'vitest';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import Root from './root.component';
|
|
5
|
+
|
|
6
|
+
describe('Root', () => {
|
|
7
|
+
it('mounts the route shell without crashing', () => {
|
|
8
|
+
// No route matches the default jsdom URL, so the shell mounts but renders
|
|
9
|
+
// no route content; this asserts the wiring (BrowserRouter + Routes) works.
|
|
10
|
+
expect(() => render(<Root />)).not.toThrow();
|
|
11
|
+
});
|
|
12
|
+
});
|
package/src/routes.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.openmrs.org/routes.schema.json",
|
|
3
|
+
"backendDependencies": {
|
|
4
|
+
"metadataexport": ">=1.0.0-SNAPSHOT"
|
|
5
|
+
},
|
|
6
|
+
"pages": [
|
|
7
|
+
{
|
|
8
|
+
"route": "metadataexport",
|
|
9
|
+
"component": "root",
|
|
10
|
+
"online": true
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"extensions": [
|
|
14
|
+
{
|
|
15
|
+
"name": "metadata-export-card-link",
|
|
16
|
+
"slot": "system-admin-page-card-link-slot",
|
|
17
|
+
"component": "metadataExportCardLink",
|
|
18
|
+
"privileges": ["Get Metadata Export Packages"]
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"workspaces": [
|
|
22
|
+
{
|
|
23
|
+
"name": "new-package-workspace",
|
|
24
|
+
"component": "newPackageWorkspace",
|
|
25
|
+
"title": "New package",
|
|
26
|
+
"type": "form",
|
|
27
|
+
"canMaximize": true,
|
|
28
|
+
"width": "narrow"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type MetadataDomain = string;
|
|
2
|
+
|
|
3
|
+
export interface ExportPackageEntryDto {
|
|
4
|
+
domain: MetadataDomain;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface ExportPackageRequest {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
entries: Array<ExportPackageEntryDto>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ExportPackageEntry {
|
|
14
|
+
domain: MetadataDomain;
|
|
15
|
+
itemUuids: Array<string>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type ExportBuildStatus = 'QUEUED' | 'RUNNING' | 'COMPLETED' | 'FAILED';
|
|
19
|
+
|
|
20
|
+
export interface ExportPackageBuild {
|
|
21
|
+
uuid: string;
|
|
22
|
+
packageUuid: string;
|
|
23
|
+
version: number;
|
|
24
|
+
status: ExportBuildStatus;
|
|
25
|
+
dateCreated: number;
|
|
26
|
+
dateStarted: number | null;
|
|
27
|
+
dateCompleted: number | null;
|
|
28
|
+
errorMessage: string | null;
|
|
29
|
+
downloadUrl: string | null;
|
|
30
|
+
manifest: unknown | null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface ExportPackage {
|
|
34
|
+
uuid: string;
|
|
35
|
+
name: string;
|
|
36
|
+
description: string;
|
|
37
|
+
retired: boolean;
|
|
38
|
+
dateCreated: number;
|
|
39
|
+
entries: Array<ExportPackageEntry>;
|
|
40
|
+
latestBuild: ExportPackageBuild | null;
|
|
41
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"allDomains": "All domains",
|
|
3
|
+
"cancel": "Cancel",
|
|
4
|
+
"createPackage": "Create package",
|
|
5
|
+
"creating": "Creating",
|
|
6
|
+
"description": "Description",
|
|
7
|
+
"descriptionPlaceholder": "Briefly describe what this package contains",
|
|
8
|
+
"domains": "Domains",
|
|
9
|
+
"errorLoadingDomains": "Error loading domains",
|
|
10
|
+
"managePackages": "Manage packages",
|
|
11
|
+
"metadataexport": "Metadata Export",
|
|
12
|
+
"newpackage": "New Package",
|
|
13
|
+
"packageCreated": "Package created",
|
|
14
|
+
"packageCreatedSubtitle": "{{name}} was created successfully",
|
|
15
|
+
"packageCreationFailed": "Failed to create package",
|
|
16
|
+
"packageName": "Package name",
|
|
17
|
+
"packageNamePlaceholder": "e.g. Core reference data",
|
|
18
|
+
"packages": "Packages",
|
|
19
|
+
"packages__lower": "packages",
|
|
20
|
+
"selectAll": "Select all",
|
|
21
|
+
"unexpectedError": "An unexpected error occurred"
|
|
22
|
+
}
|
package/tsconfig.json
ADDED
package/vitest.config.ts
ADDED