storyblok-js-client
Advanced tools
Comparing version 6.10.6 to 6.10.7
@@ -76,2 +76,12 @@ import type { ResponseFn } from './sbFetch'; | ||
} | ||
export interface PreviewToken { | ||
token: string; | ||
timestamp: string; | ||
} | ||
export interface LocalizedPath { | ||
path: string; | ||
name: string | null; | ||
lang: string; | ||
published: boolean; | ||
} | ||
export interface ISbStoryData<Content = ISbComponentType<string> & { | ||
@@ -84,6 +94,8 @@ [index: string]: any; | ||
created_at: string; | ||
default_full_slug?: string; | ||
deleted_at?: string; | ||
default_full_slug?: string | null; | ||
default_root?: string; | ||
disble_fe_editor?: boolean; | ||
first_published_at?: string; | ||
favourite_for_user_ids?: number[] | null; | ||
first_published_at?: string | null; | ||
full_slug: string; | ||
@@ -100,12 +112,16 @@ group_id: string; | ||
}; | ||
last_author_id?: number; | ||
localized_paths?: LocalizedPath[] | null; | ||
meta_data: any; | ||
name: string; | ||
parent?: ISbStoryData; | ||
parent_id: number; | ||
parent_id: number | null; | ||
path?: string; | ||
pinned?: '1' | boolean; | ||
position: number; | ||
preview_token?: PreviewToken; | ||
published?: boolean; | ||
published_at: string | null; | ||
release_id?: number; | ||
release_id?: number | null; | ||
scheduled_date?: string | null; | ||
slug: string; | ||
@@ -118,3 +134,3 @@ sort_by_date: string | null; | ||
lang: ISbStoryData['lang']; | ||
}[]; | ||
}[] | null; | ||
unpublished_changes?: boolean; | ||
@@ -121,0 +137,0 @@ updated_at?: string; |
@@ -54,6 +54,8 @@ import type { AsyncFn, ISbResult, ISbStoriesParams } from './interfaces'; | ||
created_at?: string | undefined; | ||
default_full_slug?: string | undefined; | ||
deleted_at?: string | undefined; | ||
default_full_slug?: string | null | undefined; | ||
default_root?: string | undefined; | ||
disble_fe_editor?: boolean | undefined; | ||
first_published_at?: string | undefined; | ||
favourite_for_user_ids?: number[] | null | undefined; | ||
first_published_at?: string | null | undefined; | ||
full_slug?: string | undefined; | ||
@@ -69,12 +71,16 @@ group_id?: string | undefined; | ||
} | undefined; | ||
last_author_id?: number | undefined; | ||
localized_paths?: import("./interfaces").LocalizedPath[] | null | undefined; | ||
meta_data?: any; | ||
name?: string | undefined; | ||
parent?: import("./interfaces").ISbStoryData | undefined; | ||
parent_id?: number | undefined; | ||
parent_id?: number | null | undefined; | ||
path?: string | undefined; | ||
pinned?: "1" | boolean | undefined; | ||
position?: number | undefined; | ||
preview_token?: import("./interfaces").PreviewToken | undefined; | ||
published?: boolean | undefined; | ||
published_at?: string | null | undefined; | ||
release_id?: number | undefined; | ||
release_id?: number | null | undefined; | ||
scheduled_date?: string | null | undefined; | ||
slug?: string | undefined; | ||
@@ -87,3 +93,3 @@ sort_by_date?: string | null | undefined; | ||
lang: import("./interfaces").ISbStoryData["lang"]; | ||
}[] | undefined; | ||
}[] | null | undefined; | ||
unpublished_changes?: boolean | undefined; | ||
@@ -90,0 +96,0 @@ updated_at?: string | undefined; |
{ | ||
"name": "storyblok-js-client", | ||
"version": "6.10.6", | ||
"version": "6.10.7", | ||
"packageManager": "pnpm@9.15.0", | ||
@@ -5,0 +5,0 @@ "description": "Universal JavaScript SDK for Storyblok's API", |
@@ -304,3 +304,3 @@ <div align="center"> | ||
- `slug` String, _required_. Path (can be `cdn/stories`, `cdn/tags`, `cdn/datasources`, `cdn/links`) | ||
- `params` Object, _optional_. Options can be found in the [API documentation](https://www.storyblok.com/docs/api/content-delivery?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js-client). | ||
- `params` Object, _optional_. Options can be found in the [API documentation](https://www.storyblok.com/docs/api/content-delivery/v2?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js-client). | ||
- `fetchOptions` Object, _optional_, Fetch options can be found in the [Fetch API documentation](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch). **_It's important to note that we extended the `RequestInit` interface omitting the `method` parameter. This is because the method is already defined by the Storyblok client._** | ||
@@ -330,3 +330,3 @@ | ||
- `slug` String, _required_. Path (can be `cdn/stories`, `cdn/tags`, `cdn/datasources`, `cdn/links`) | ||
- `params` Object, _required_. Options can be found in the [API documentation](https://www.storyblok.com/docs/api/content-delivery?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js-client). | ||
- `params` Object, _required_. Options can be found in the [API documentation](https://www.storyblok.com/docs/api/content-delivery/v2?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js-client). | ||
- `entity` String, _optional_. Storyblok entity like stories, links or datasource. It's optional. | ||
@@ -355,3 +355,3 @@ - `fetchOptions` Object, _optional_, Fetch options can be found in the [Fetch API documentation](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch). **_It's important to note that we extended the `RequestInit` interface omitting the `method` parameter. This is because the method is already defined by the Storyblok client._** | ||
- `slug` String, _required_. Path (can be `cdn/stories`, `cdn/tags`, `cdn/datasources`, `cdn/links`) | ||
- `params` Object, _required_. Options can be found in the [API documentation](https://www.storyblok.com/docs/api/content-delivery?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js-client). | ||
- `params` Object, _required_. Options can be found in the [API documentation](https://www.storyblok.com/docs/api/content-delivery/v2?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js-client). | ||
- `fetchOptions` Object, _optional_, Fetch options can be found in the [Fetch API documentation](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch). **_It's important to note that we extended the `RequestInit` interface omitting the `method` parameter. This is because the method is already defined by the Storyblok client._** | ||
@@ -379,3 +379,3 @@ | ||
- `slug` String, _required_. Path (can be `cdn/stories`, `cdn/tags`, `cdn/datasources`, `cdn/links`) | ||
- `params` Object, _required_. Options can be found in the [API documentation](https://www.storyblok.com/docs/api/content-delivery?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js-client). | ||
- `params` Object, _required_. Options can be found in the [API documentation](https://www.storyblok.com/docs/api/content-delivery/v2?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js-client). | ||
- `fetchOptions` Object, _optional_, Fetch options can be found in the [Fetch API documentation](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch). **_It's important to note that we extended the `RequestInit` interface omitting the `method` parameter. This is because the method is already defined by the Storyblok client._** | ||
@@ -403,3 +403,3 @@ | ||
- `slug` String, _required_. Path (can be `cdn/stories`, `cdn/tags`, `cdn/datasources`, `cdn/links`) | ||
- `params` Object, _required_. Options can be found in the [API documentation](https://www.storyblok.com/docs/api/content-delivery?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js-client). | ||
- `params` Object, _required_. Options can be found in the [API documentation](https://www.storyblok.com/docs/api/content-delivery/v2?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js-client). | ||
- `fetchOptions` Object, _optional_, Fetch options can be found in the [Fetch API documentation](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch). **_It's important to note that we extended the `RequestInit` interface omitting the `method` parameter. This is because the method is already defined by the Storyblok client._** | ||
@@ -406,0 +406,0 @@ |
@@ -6,3 +6,3 @@ import StoryblokClient from '.'; | ||
import { SbHelpers } from './sbHelpers'; | ||
import type { ISbLink } from './interfaces'; | ||
import type { ISbLink, ISbStoryData } from './interfaces'; | ||
@@ -1045,2 +1045,89 @@ // Mocking external dependencies | ||
}); | ||
// eslint-disable-next-line test/prefer-lowercase-title | ||
describe('ISbStoryData interface implementation', () => { | ||
it('should validate a complete story object structure', () => { | ||
const storyData: ISbStoryData = { | ||
alternates: [], | ||
content: { | ||
_uid: 'test-uid', | ||
component: 'test', | ||
}, | ||
created_at: '2024-01-01T00:00:00.000Z', | ||
deleted_at: undefined, | ||
full_slug: 'test/story', | ||
group_id: 'test-group', | ||
id: 1, | ||
is_startpage: false, | ||
lang: 'default', | ||
meta_data: {}, | ||
name: 'Test Story', | ||
parent_id: null, | ||
position: 0, | ||
published_at: null, | ||
slug: 'test-story', | ||
sort_by_date: null, | ||
tag_list: [], | ||
uuid: 'test-uuid', | ||
}; | ||
expect(storyData).toBeDefined(); | ||
expect(storyData).toMatchObject({ | ||
alternates: expect.any(Array), | ||
content: expect.objectContaining({ | ||
_uid: expect.any(String), | ||
component: expect.any(String), | ||
}), | ||
created_at: expect.any(String), | ||
full_slug: expect.any(String), | ||
group_id: expect.any(String), | ||
id: expect.any(Number), | ||
lang: expect.any(String), | ||
name: expect.any(String), | ||
position: expect.any(Number), | ||
slug: expect.any(String), | ||
uuid: expect.any(String), | ||
}); | ||
}); | ||
it('should handle optional properties correctly', () => { | ||
const storyData: ISbStoryData = { | ||
alternates: [], | ||
content: { | ||
_uid: 'test-uid', | ||
component: 'test', | ||
}, | ||
created_at: '2024-01-01T00:00:00.000Z', | ||
full_slug: 'test/story', | ||
group_id: 'test-group', | ||
id: 1, | ||
lang: 'default', | ||
meta_data: {}, | ||
name: 'Test Story', | ||
position: 0, | ||
published_at: null, | ||
slug: 'test-story', | ||
sort_by_date: null, | ||
tag_list: [], | ||
uuid: 'test-uuid', | ||
parent_id: null, | ||
// Optional properties | ||
preview_token: { | ||
token: 'test-token', | ||
timestamp: '2024-01-01T00:00:00.000Z', | ||
}, | ||
localized_paths: [ | ||
{ | ||
path: '/en/test', | ||
name: 'Test EN', | ||
lang: 'en', | ||
published: true, | ||
}, | ||
], | ||
}; | ||
expect(storyData.preview_token).toBeDefined(); | ||
expect(storyData.localized_paths).toBeDefined(); | ||
}); | ||
}); | ||
}); |
@@ -85,2 +85,14 @@ import type { ResponseFn } from './sbFetch'; | ||
export interface PreviewToken { | ||
token: string; | ||
timestamp: string; | ||
} | ||
export interface LocalizedPath { | ||
path: string; | ||
name: string | null; | ||
lang: string; | ||
published: boolean; | ||
} | ||
export interface ISbStoryData< | ||
@@ -93,6 +105,8 @@ Content = ISbComponentType<string> & { [index: string]: any }, | ||
created_at: string; | ||
default_full_slug?: string; | ||
deleted_at?: string; | ||
default_full_slug?: string | null; | ||
default_root?: string; | ||
disble_fe_editor?: boolean; | ||
first_published_at?: string; | ||
favourite_for_user_ids?: number[] | null; | ||
first_published_at?: string | null; | ||
full_slug: string; | ||
@@ -109,12 +123,16 @@ group_id: string; | ||
}; | ||
last_author_id?: number; | ||
localized_paths?: LocalizedPath[] | null; | ||
meta_data: any; | ||
name: string; | ||
parent?: ISbStoryData; | ||
parent_id: number; | ||
parent_id: number | null; | ||
path?: string; | ||
pinned?: '1' | boolean; | ||
position: number; | ||
preview_token?: PreviewToken; | ||
published?: boolean; | ||
published_at: string | null; | ||
release_id?: number; | ||
release_id?: number | null; | ||
scheduled_date?: string | null; | ||
slug: string; | ||
@@ -127,3 +145,3 @@ sort_by_date: string | null; | ||
lang: ISbStoryData['lang']; | ||
}[]; | ||
}[] | null; | ||
unpublished_changes?: boolean; | ||
@@ -130,0 +148,0 @@ updated_at?: string; |
240664
6050