From 0870cb2eea8a35296a9f2926d50c2cd14ca6a629 Mon Sep 17 00:00:00 2001 From: Pierce Date: Fri, 6 Oct 2023 17:59:20 -0700 Subject: [PATCH] skip lazyformat option, List get --- src/lib/Client.ts | 3 ++ src/lib/Content.ts | 8 ++-- src/lib/List.ts | 15 ++++++++ src/lib/utility/Global.ts | 78 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 src/lib/List.ts diff --git a/src/lib/Client.ts b/src/lib/Client.ts index 97e3a3b..0d9129a 100644 --- a/src/lib/Client.ts +++ b/src/lib/Client.ts @@ -7,6 +7,7 @@ import { Hierarchy } from "./Hierarchy.js" import { Media } from "./Media.js" import { MediaCategory } from "./MediaCategory.js" import { MediaType } from "./MediaType.js" +import { List } from "./List.js" import { Profile } from "./Profile.js" import { Upload } from "./Upload.js" import { ServerSideLink } from "./ServerSideLink.js" @@ -23,6 +24,7 @@ export class Client { media: Media mediaCategory: MediaCategory mediaType: MediaType + list: List profile: Profile serverSideLink: ServerSideLink upload: Upload @@ -38,6 +40,7 @@ export class Client { this.media = new Media(this) this.mediaCategory = new MediaCategory(this) this.mediaType = new MediaType(this) + this.list = new List(this) this.profile = new Profile(this) this.serverSideLink = new ServerSideLink(this) this.upload = new Upload(this) diff --git a/src/lib/Content.ts b/src/lib/Content.ts index e20d9d1..ae016e4 100644 --- a/src/lib/Content.ts +++ b/src/lib/Content.ts @@ -50,15 +50,17 @@ export class Content { return response?.ok } - async create(sectionId: number, options: contenUploadDTO) { + async create(sectionId: number, options: contenUploadDTO, isFormatted: boolean = false) { const { channels, canPublishNow, canSaveAndApprove, contentType } = await this.prePopulateContentInfo(options.contentTypeID, sectionId) - const formattedElementNames = this.util.getElementNames(contentType.contentTypeElements) - options.elements = this.util.lazyMap(options.elements, formattedElementNames) + if(!isFormatted) { + const formattedElementNames = this.util.getElementNames(contentType.contentTypeElements) + options.elements = this.util.lazyMap(options.elements, formattedElementNames) + } const uploadData = contentUploadData({ channels, canPublishNow, diff --git a/src/lib/List.ts b/src/lib/List.ts new file mode 100644 index 0000000..a748951 --- /dev/null +++ b/src/lib/List.ts @@ -0,0 +1,15 @@ +import { Client } from "./Client.js" +import { PredefinedListDTO } from "./utility/Global.js" + +export const ListEndpoint = 'list' +export class List { + client: Client + constructor(client:Client) { + this.client = client + } + + async get(listId: number, language: string = 'en'): Promise { + const response = await this.client.call('GET', `${ListEndpoint}/${listId}/${language}`, null) + return await response.json() + } +} \ No newline at end of file diff --git a/src/lib/utility/Global.ts b/src/lib/utility/Global.ts index b4d06d9..1fb4c38 100644 --- a/src/lib/utility/Global.ts +++ b/src/lib/utility/Global.ts @@ -669,4 +669,82 @@ export interface ServerSideLinkDTO extends ServerSideLinkData { broken: boolean } +export interface PredefinedListDTO { + id: number + language: string + name: string + description: string + isForcedLanguage: boolean + isDefaultLanguage: boolean + items: ListItem[] + duplicate: boolean + listEntriesWithListSubLists: any[] + cteWithListsAsElements: CteWithListsAsElement[] + formsUsingThisList: FormDTO[] + sortingEnabled: boolean + listOverriddenInAnotherLanguage: boolean + defaultLanguageSetInAnotherLanguage: boolean + sortType: number + editable: boolean + primaryGroup: ListPrimaryGroup + sharedGroups: any[] + sharedGroupCount: number + fullAccess: boolean +} + +export interface ListItem { + name: string + value: string + sequence: number + id: number + isSelected: boolean + sublist: number + listId: number +} + +export interface CteWithListsAsElement { + name: string + description: string + typeID: number + type: ListType + maxSize: number + compulsory: boolean + sequence: number + alias: string + show: boolean + id: number + contentType: number + listId: number +} + +export interface ListType { + id: number + name: string + description: string + storageMethod: number + binary: boolean + elementClass: string + inputClass: string + extensionChecking: boolean + enabled: boolean +} + +export interface ListPrimaryGroup { + group: Group + fullAccess: boolean + id: number + name: string +} + +export interface Group { + id: number + name: string + description: string + emailAddress: string + createDate: number + enabled: boolean + ldap: boolean + defaultChannel: number + deleted: boolean +}