From 3df19c3d3f45efcb6007589c0a8c2cb5a8d559ee Mon Sep 17 00:00:00 2001 From: harshithad0703 Date: Wed, 3 Apr 2024 17:53:30 +0530 Subject: [PATCH] feat: get locales types support --- test/typescript/entry.ts | 18 +++++++++++++++++- test/typescript/index.test.ts | 3 ++- types/stack/contentType/entry.d.ts | 10 ++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/test/typescript/entry.ts b/test/typescript/entry.ts index 19c08a0c..57b576b2 100644 --- a/test/typescript/entry.ts +++ b/test/typescript/entry.ts @@ -104,7 +104,7 @@ export function getEntries(stack: Stack) { }) test('Fetch Entry', done => { - stack.contentType(singlepageCT.content_type.uid).entry(entryUTD) + stack.contentType('product').entry('blt7d6fae845bfc55d4') .fetch({include_content_type: true}) .then((response) => { expect(response.uid).to.be.not.equal(null) @@ -132,6 +132,22 @@ export function getEntries(stack: Stack) { }) } +export function getEntryLocales(stack: Stack) { + describe('Entry get', () => { + test('to get locales of an entry', done => { + stack.contentType(singlepageCT.content_type.uid).entry(entryUTD).locales() + .then((locale) => { + expect(locale.locales[0].code).to.be.equal('en-us') + locale.locales.forEach((locales) => { + expect(locales.code).to.be.not.equal(null) + }) + done() + }) + .catch(done) + }) + }) +} + export function publishUnpublishEntry(stack: Stack) { describe('Unpublish/Publish Entry', () => { test('Publish Entry', done => { diff --git a/test/typescript/index.test.ts b/test/typescript/index.test.ts index e6ab2d97..0f59461e 100644 --- a/test/typescript/index.test.ts +++ b/test/typescript/index.test.ts @@ -4,7 +4,7 @@ import { organization, organizations } from './organization'; import * as dotenv from 'dotenv' import { shareStack, stacks, stackTest, unshareStack } from './stack'; import { contentType, createContentType, queryContentType } from './contentType'; -import { createEntry, getEntries, importEntry, publishUnpublishEntry } from './entry'; +import { createEntry, getEntries, importEntry, publishUnpublishEntry, getEntryLocales } from './entry'; import { createAsset, deleteAsset, downloadAsset, getAssets, publishUnpublishAsset, queryOnAsset, replaceAsset } from './asset'; import { createGlobalField, globalField, queryGlobalField } from './globalField'; import { createBranch, deleteBranch, queryBranch } from './branch'; @@ -103,6 +103,7 @@ describe('Typescript API test', () => { createEntry(stack) getEntries(stack) + getEntryLocales(stack) publishUnpublishEntry(stack) importEntry(stack) diff --git a/types/stack/contentType/entry.d.ts b/types/stack/contentType/entry.d.ts index 77e3d4bf..6d3f8149 100644 --- a/types/stack/contentType/entry.d.ts +++ b/types/stack/contentType/entry.d.ts @@ -7,6 +7,7 @@ import { Unpublishable } from "../../utility/unpublish"; export interface Entry extends Publishable, Unpublishable, SystemFields, SystemFunction { setWorkflowStage(data: { workflow_stage: WorkflowStage, locale?:string}): Promise + locales(): Promise } export interface Entries extends Queryable { @@ -25,4 +26,13 @@ export interface WorkflowStage extends AnyProperty { notify?: boolean assign_to?: Array assigned_by_roles?: Array +} + +export interface Locales { + locales: Code[]; +} + +export interface Code extends AnyProperty { + code: string; + localized: boolean; } \ No newline at end of file