Skip to content

Commit

Permalink
fix: typing and inline docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-warner committed Mar 15, 2024
1 parent 5c96bd1 commit 5929914
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 18 deletions.
24 changes: 9 additions & 15 deletions src/lib/components/ContentEditorNavigator.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import { BaseNavigator } from './BaseNavigator';
import { OpenOptions } from '../constants/Navigation';
import { ContentItemModel } from '../models/ContentItemModel';
import { ClientConnection } from 'message-event-channel';

export class ContentEditorApplicationNavigator {
private navigationService: BaseNavigator;

constructor(private readonly connection: ClientConnection, locationHref: string, window: Window) {
this.navigationService = new BaseNavigator(locationHref, window);
}

openContentItem(contentItem: Partial<ContentItemModel>, options: Partial<OpenOptions> = {}) {
return this.navigationService.navigate(
`/authoring/content-item/edit/${contentItem.id}`,
options
);
}
constructor(private readonly connection: ClientConnection) {}

/**
*
* @param contentItemId - content item you're wanting to navigate to
* @param contentTypeUri - content type uri from a schema id
*
* Used to navigate to nested content item
*
*/
editContentItem(contentItemId: string, contentTypeUri: string) {
return this.connection.request<void>('navigate-to-nested', {
uri: contentTypeUri,
Expand Down
39 changes: 37 additions & 2 deletions src/lib/components/ContentType.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,49 @@
import { CONTENT_TYPES } from '../constants/Events';
import { ClientConnection } from 'message-event-channel';
import { ContentTypeModel } from '../models/ContentType';

export class ContentTypes {
constructor(private connection: ClientConnection) {}

async getByUri(uri: string) {
/**
*
* @param uri schema id / content type uri
*
* Used to get content type settings for a schema
*
* @returns [[Promise<ContentTypeModel>]]
*
* ### Example
*
* ```typescript
* const contentType = sdk.contentTypes.getByUri('https://example-schema.com/blog.json')
*
* console.log(contentType)
* ```
* @returns
*/
async getByUri(uri: string): Promise<ContentTypeModel> {
return this.connection.request(CONTENT_TYPES.GET_BY_URI, { uri });
}

async getByUris(uris: string[]) {
/**
*
* @param uri list of schema id / content type uri
*
* Used to get content type settings for a schema
*
* @returns [[Promise<ContentTypeModel[]>]]
*
* ### Example
*
* ```typescript
* const contentTypes = sdk.contentTypes.getByUri(['https://example-schema.com/blog.json', 'https://example-schema.com/user.json'])
*
* console.log(contentTypes)
* ```
* @returns
*/
async getByUris(uris: string[]): Promise<ContentTypeModel[]> {
return this.connection.request(CONTENT_TYPES.GET_BY_URIS, { uris });
}
}
18 changes: 17 additions & 1 deletion src/lib/components/Workflows.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
import { WORKFLOWS } from '../constants/Events';
import { WorkflowModel } from '../models/Workflow';
import { ClientConnection } from 'message-event-channel';

export class Workflows {
constructor(private connection: ClientConnection) {}

async getAll() {
/**
*
* @returns Workflow
*
* Used to fetch all workflows for a given hub. Returns a promise which will resolve to a [[WorkflowModel[]]]
*
* ### Example
*
* ```typescript
* const workflows = await sdk.workflows.getAll()
*
* console.log(workflows)
* ```
*
*/
async getAll(): Promise<WorkflowModel[]> {
return this.connection.request(WORKFLOWS.GET_ALL_WORKFLOWS);
}
}
24 changes: 24 additions & 0 deletions src/lib/models/ContentType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export interface Visualization {
label: string;
templatedUri: string;
default: boolean;
}

export interface ContentTypeCard {
templatedUri: string;
}

export interface ContentTypeIcon {
size: number;
url: string;
}

export interface ContentTypeModel {
id: string;
label: string;
status: string;
contentTypeUri: string;
cards: ContentTypeCard[];
icons: ContentTypeIcon[];
visualizations: Visualization[];
}
7 changes: 7 additions & 0 deletions src/lib/models/Workflow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface WorkflowModel {
id: string;
color: string;
label: string;
lastModifiedBy: string;
lastModifiedDate: string;
}

0 comments on commit 5929914

Please sign in to comment.