Entities for RESTful API for managing application instances
parent
d5901a160b
commit
360afd6bdb
|
|
@ -8,6 +8,7 @@ import {
|
|||
assertProperties,
|
||||
} from "@libreccm/ccm-apiclient-commons";
|
||||
import { CcmObjectId } from "./core";
|
||||
import { CcmApplicationId } from "./web";
|
||||
|
||||
/**
|
||||
* Data required to identify a category.
|
||||
|
|
@ -75,7 +76,7 @@ export interface Category {
|
|||
*/
|
||||
abstractCategory: boolean;
|
||||
/**
|
||||
* The parent category of the category. Is null if the category is a root
|
||||
* The parent category of the category. Is null if the category is a root
|
||||
* category.
|
||||
*/
|
||||
parentCategory: AssociatedCategory | null;
|
||||
|
|
@ -120,9 +121,17 @@ export interface Categorization {
|
|||
type: string;
|
||||
}
|
||||
|
||||
export interface DomainOwnership {
|
||||
ownershipId: number;
|
||||
uuid: string;
|
||||
context: string;
|
||||
owner: CcmApplicationId;
|
||||
ownerOrder: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a {@link Category} object from a `Record`.
|
||||
*
|
||||
*
|
||||
* @param record The record used as datasource.
|
||||
*/
|
||||
export function buildCategoryFromRecord(
|
||||
|
|
@ -160,9 +169,9 @@ export function buildCategoryFromRecord(
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function for building a {@link Categorization} object from
|
||||
* Helper function for building a {@link Categorization} object from
|
||||
* a record.
|
||||
*
|
||||
*
|
||||
* @param record The record to use as datasource.
|
||||
*/
|
||||
export function buildCategorizationFromRecord(
|
||||
|
|
@ -188,3 +197,23 @@ export function buildCategorizationFromRecord(
|
|||
type: record.type as string,
|
||||
};
|
||||
}
|
||||
|
||||
export function buildDomainOwnershipFromRecord(
|
||||
record: Record<string, unknown>
|
||||
): DomainOwnership {
|
||||
assertProperties(record, [
|
||||
"ownershipId",
|
||||
"uuid",
|
||||
"context",
|
||||
"owner",
|
||||
"ownerOrder",
|
||||
]);
|
||||
|
||||
return {
|
||||
ownershipId: record.ownershipId as number,
|
||||
uuid: record.uuid as string,
|
||||
context: record.context as string,
|
||||
owner: record.owner as CcmApplicationId,
|
||||
ownerOrder: record.ownerOrder as number,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,71 @@ import {
|
|||
LocalizedString,
|
||||
assertProperties,
|
||||
} from "@libreccm/ccm-apiclient-commons";
|
||||
import {
|
||||
DomainOwnership,
|
||||
buildDomainOwnershipFromRecord,
|
||||
} from "./categorization";
|
||||
import { SiteId } from "./site";
|
||||
|
||||
export interface CcmApplication {
|
||||
applicationId: number;
|
||||
uuid: string;
|
||||
title: LocalizedString;
|
||||
description: LocalizedString;
|
||||
created: string;
|
||||
applicationClassName: string;
|
||||
applicationType: string;
|
||||
primaryUrl: string;
|
||||
domains: DomainOwnership[];
|
||||
siteAware: boolean;
|
||||
site: SiteId;
|
||||
}
|
||||
|
||||
export interface CcmApplicationId {
|
||||
applicationType: string;
|
||||
primaryUrl: string;
|
||||
}
|
||||
|
||||
export function buildCcmApplicationFromRecord(
|
||||
record: Record<string, unknown>
|
||||
): CcmApplication {
|
||||
assertProperties(record, [
|
||||
"applicationId",
|
||||
"uuid",
|
||||
"title",
|
||||
"description",
|
||||
"created",
|
||||
"applicationClassName",
|
||||
"applicationType",
|
||||
"primaryUrl",
|
||||
"domains",
|
||||
"siteAware",
|
||||
"site",
|
||||
]);
|
||||
|
||||
const domainRecords: Record<string, unknown>[] = record.domains as Record<
|
||||
string,
|
||||
unknown
|
||||
>[];
|
||||
const domains = domainRecords.map((record) =>
|
||||
buildDomainOwnershipFromRecord(record)
|
||||
);
|
||||
|
||||
return {
|
||||
applicationId: record.applicationId as number,
|
||||
uuid: record.uuid as string,
|
||||
title: record.title as LocalizedString,
|
||||
description: record.description as LocalizedString,
|
||||
created: record.created as string,
|
||||
applicationClassName: record.applicationClassName as string,
|
||||
applicationType: record.applicationType as string,
|
||||
primaryUrl: record.primaryUrl as string,
|
||||
domains,
|
||||
siteAware: record.siteAware as boolean,
|
||||
site: record.site as SiteId,
|
||||
};
|
||||
}
|
||||
|
||||
export function buildCcmApplicationIdFromRecord(
|
||||
record: Record<string, unknown>
|
||||
): CcmApplicationId {
|
||||
|
|
|
|||
Loading…
Reference in New Issue