add fetcher + mocks for packages and packageView

This commit is contained in:
Jacob Overgaard
2022-09-05 10:30:55 +02:00
parent 62c47c26fa
commit e157d7d57f
5 changed files with 86 additions and 0 deletions

View File

@@ -16,6 +16,9 @@ export interface paths {
"/manifests": {
get: operations["Manifests"];
};
"/manifests/packages": {
get: operations["Packages"];
};
"/server/status": {
get: operations["GetStatus"];
};
@@ -119,9 +122,19 @@ export interface components {
elementName?: string;
alias: string;
};
IPrevalueField: {
label?: string;
description?: string;
key: string;
view: string;
};
MetaPropertyEditorUI: {
icon: string;
group: string;
prevalues?: {
fields: components["schemas"]["IPrevalueField"][];
};
defaultConfig?: { [key: string]: unknown };
};
IManifestPropertyEditorUI: {
/** @enum {string} */
@@ -176,6 +189,18 @@ export interface components {
elementName?: string;
alias: string;
};
MetaPackageView: {
packageAlias: string;
};
IManifestPackageView: {
/** @enum {string} */
type: "packageView";
meta: components["schemas"]["MetaPackageView"];
name: string;
js?: string;
elementName?: string;
alias: string;
};
IManifestEntrypoint: {
/** @enum {string} */
type: "entrypoint";
@@ -194,11 +219,20 @@ export interface components {
| components["schemas"]["IManifestDashboard"]
| components["schemas"]["IManifestEditorView"]
| components["schemas"]["IManifestPropertyAction"]
| components["schemas"]["IManifestPackageView"]
| components["schemas"]["IManifestEntrypoint"]
| components["schemas"]["IManifestCustom"];
ManifestsResponse: {
manifests: components["schemas"]["Manifest"][];
};
Package: {
name: string;
alias: string;
version: string;
};
PackagesResponse: {
packages: components["schemas"]["Package"][];
};
/** @enum {string} */
ServerStatus: "running" | "must-install" | "must-upgrade";
StatusResponse: {
@@ -298,6 +332,22 @@ export interface operations {
};
};
};
Packages: {
responses: {
/** 200 response */
200: {
content: {
"application/json": components["schemas"]["PackagesResponse"];
};
};
/** default response */
default: {
content: {
"application/json": components["schemas"]["ProblemDetails"];
};
};
};
};
GetStatus: {
responses: {
/** 200 response */

View File

@@ -20,3 +20,4 @@ export const postInstallSetup = fetcher.path('/install/setup').method('post').cr
export const getUpgradeSettings = fetcher.path('/upgrade/settings').method('get').create();
export const PostUpgradeAuthorize = fetcher.path('/upgrade/authorize').method('post').create();
export const getManifests = fetcher.path('/manifests').method('get').create();
export const getPackages = fetcher.path('/manifests/packages').method('get').create();

View File

@@ -15,6 +15,7 @@ const handlers = [
...userHandlers,
...dataTypeHandlers,
...documentTypeHandlers,
...manifestsHandlers.default,
];
switch (import.meta.env.VITE_UMBRACO_INSTALL_STATUS) {

View File

@@ -37,6 +37,16 @@ export const manifestDevelopmentHandler = rest.get(umbracoPath('/manifests'), (_
alias: 'My.Entrypoint.Custom',
js: '/src/mocks/App_Plugins/custom-entrypoint.js',
},
{
type: 'packageView',
alias: 'My.PackageView.Custom',
name: 'My Custom Package View',
js: '/src/mocks/App_Plugins/package-view.js',
elementName: 'my-package-view-custom',
meta: {
packageAlias: 'my.package',
},
},
],
})
);
@@ -51,3 +61,26 @@ export const manifestEmptyHandler = rest.get(umbracoPath('/manifests'), (_req, r
})
);
});
export default [
rest.get(umbracoPath('/manifests/packages'), (_req, res, ctx) => {
return res(
// Respond with a 200 status code
ctx.status(200),
ctx.json({
packages: [
{
name: 'My very own package',
alias: 'my.package',
version: '1.0.0',
},
{
name: 'Some other community package',
alias: 'our.package',
version: '2.0.1',
},
],
})
);
}),
];

View File

@@ -17,4 +17,5 @@ export const handlers = [
...userHandlers,
...dataTypeHandlers,
...documentTypeHandlers,
...manifestsHandlers.default,
];