From a5cde02ee68012afbd898e442f65ca6a4f1e9410 Mon Sep 17 00:00:00 2001 From: Julius Friedrich <113022073+jfctfl@users.noreply.github.com> Date: Mon, 6 Feb 2023 10:07:37 +0100 Subject: [PATCH] feat: expose automation tags on entry.sys [] (#1468) feat: expose automation tags on entry.sys --- lib/entry.ts | 6 +++--- lib/types/api.types.ts | 4 ++-- lib/types/entry.types.ts | 6 +++--- lib/types/index.ts | 1 + lib/types/utils.ts | 7 ++++++- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/entry.ts b/lib/entry.ts index 9052adaaea..3448d2ea36 100644 --- a/lib/entry.ts +++ b/lib/entry.ts @@ -1,6 +1,6 @@ import { Channel } from './channel' import { MemoizedSignal } from './signal' -import { ContentEntitySys, EntryAPI, EntryFieldInfo, Metadata, TaskAPI } from './types' +import { EntryAPI, EntryFieldInfo, EntrySys, Metadata, TaskAPI } from './types' const taskMethods: Array = [ 'getTask', @@ -17,7 +17,7 @@ export default function createEntry( createEntryField: Function ): EntryAPI { let sys = entryData.sys - const sysChanged = new MemoizedSignal<[ContentEntitySys]>(sys) + const sysChanged = new MemoizedSignal<[EntrySys]>(sys) let metadata = entryData.metadata const metadataChanged = new MemoizedSignal<[Metadata | undefined]>(metadata) @@ -52,7 +52,7 @@ export default function createEntry( save() { return channel.call('callEntryMethod', 'save') }, - onSysChanged(handler: (sys: ContentEntitySys) => void) { + onSysChanged(handler: (sys: EntrySys) => void) { return sysChanged.attach(handler) }, fields: fieldInfo.reduce((acc: any, info: EntryFieldInfo) => { diff --git a/lib/types/api.types.ts b/lib/types/api.types.ts index c5c8112fbf..caec3f0c2b 100644 --- a/lib/types/api.types.ts +++ b/lib/types/api.types.ts @@ -13,7 +13,7 @@ import { import { EntryAPI } from './entry.types' import { SpaceAPI } from './space.types' import { WindowAPI } from './window.types' -import { ContentEntitySys, Link, SerializedJSONValue } from './utils' +import { EntrySys, Link, SerializedJSONValue } from './utils' import { FieldAPI } from './field-locale.types' import { DialogsAPI } from './dialogs.types' import { AppConfigAPI } from './app.types' @@ -275,7 +275,7 @@ export interface ConnectMessage { contentType: ContentTypeAPI editorInterface?: EditorInterface entry: { - sys: ContentEntitySys + sys: EntrySys metadata?: Metadata } fieldInfo: EntryFieldInfo[] diff --git a/lib/types/entry.types.ts b/lib/types/entry.types.ts index 3e20dba908..16930c6f6c 100644 --- a/lib/types/entry.types.ts +++ b/lib/types/entry.types.ts @@ -1,6 +1,6 @@ import { Metadata, Task } from './entities' import { EntryFieldAPI } from './field.types' -import { CollectionResponse, ContentEntitySys, SearchQuery } from './utils' +import { CollectionResponse, EntrySys, SearchQuery } from './utils' type TaskState = 'active' | 'resolved' @@ -27,7 +27,7 @@ export interface TaskAPI { export interface EntryAPI extends TaskAPI { /** Returns sys for an entry. */ - getSys: () => ContentEntitySys + getSys: () => EntrySys /** Publish the entry */ publish: (options?: { skipUiValidation?: boolean }) => Promise /** Unpublish the entry */ @@ -35,7 +35,7 @@ export interface EntryAPI extends TaskAPI { /** Saves the current changes of the entry */ save: () => Promise /** Calls the callback with sys every time that sys changes. */ - onSysChanged: (callback: (sys: ContentEntitySys) => void) => () => void + onSysChanged: (callback: (sys: EntrySys) => void) => () => void /** Allows to control the values of all other fields in the current entry. */ fields: { [key: string]: EntryFieldAPI } /** diff --git a/lib/types/index.ts b/lib/types/index.ts index c936765fcd..b3214855f0 100644 --- a/lib/types/index.ts +++ b/lib/types/index.ts @@ -81,6 +81,7 @@ export type { SpaceAPI } from './space.types' export type { SearchQuery, CollectionResponse, + EntrySys, ContentEntitySys, ContentEntityType, Items, diff --git a/lib/types/utils.ts b/lib/types/utils.ts index 2cc314f04e..dd1e5e45b8 100644 --- a/lib/types/utils.ts +++ b/lib/types/utils.ts @@ -35,7 +35,7 @@ export interface CollectionResponse { export type ContentEntityType = 'Entry' | 'Asset' -export interface ContentEntitySys { +export type ContentEntitySys = { space: Link id: string type: ContentEntityType @@ -55,6 +55,11 @@ export interface ContentEntitySys { contentType: Link } +export interface EntrySys extends ContentEntitySys { + type: 'Entry' + automationTags: Link<'Tag'>[] +} + export interface Items { type: string linkType?: string