@prezly/sdk 18.2.0 → 18.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api/constants.cjs
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DEFAULT_USER_AGENT = void 0;
|
|
7
|
-
const VERSION = "18.
|
|
7
|
+
const VERSION = "18.2.0";
|
|
8
8
|
const URL = 'https://github.com/prezly/javascript-sdk';
|
|
9
9
|
const DEFAULT_USER_AGENT = `prezly-javascript-sdk/${VERSION} (+${URL})`;
|
|
10
10
|
exports.DEFAULT_USER_AGENT = DEFAULT_USER_AGENT;
|
package/dist/api/constants.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.Client = void 0;
|
|
|
7
7
|
var _index = require("../../http/index.cjs");
|
|
8
8
|
var _routing = require("../../routing.cjs");
|
|
9
9
|
var _index2 = require("../../types/index.cjs");
|
|
10
|
+
var _types = require("./types.cjs");
|
|
10
11
|
class Client {
|
|
11
12
|
constructor(apiClient) {
|
|
12
13
|
this.apiClient = apiClient;
|
|
@@ -81,7 +82,7 @@ class Client {
|
|
|
81
82
|
$in: arg
|
|
82
83
|
}
|
|
83
84
|
},
|
|
84
|
-
include,
|
|
85
|
+
include: [..._types.EXTENDED_STORY_INCLUDED_EXTRA_FIELDS, ...(include ?? [])],
|
|
85
86
|
formats
|
|
86
87
|
});
|
|
87
88
|
return stories;
|
|
@@ -96,7 +97,7 @@ class Client {
|
|
|
96
97
|
$in: arg
|
|
97
98
|
}
|
|
98
99
|
},
|
|
99
|
-
include,
|
|
100
|
+
include: [..._types.EXTENDED_STORY_INCLUDED_EXTRA_FIELDS, ...(include ?? [])],
|
|
100
101
|
formats
|
|
101
102
|
});
|
|
102
103
|
return stories;
|
|
@@ -106,7 +107,7 @@ class Client {
|
|
|
106
107
|
} = await this.apiClient.get(`${_routing.routing.storiesUrl}/${arg}`, {
|
|
107
108
|
headers: acceptedFormatsHeader(formats),
|
|
108
109
|
query: {
|
|
109
|
-
include
|
|
110
|
+
include
|
|
110
111
|
}
|
|
111
112
|
});
|
|
112
113
|
return story;
|
|
@@ -122,7 +123,7 @@ class Client {
|
|
|
122
123
|
headers: acceptedFormatsHeader(formats),
|
|
123
124
|
payload,
|
|
124
125
|
query: {
|
|
125
|
-
include
|
|
126
|
+
include
|
|
126
127
|
}
|
|
127
128
|
});
|
|
128
129
|
return story;
|
|
@@ -138,7 +139,7 @@ class Client {
|
|
|
138
139
|
} = await this.apiClient.post(url, {
|
|
139
140
|
headers: acceptedFormatsHeader(formats),
|
|
140
141
|
query: {
|
|
141
|
-
include
|
|
142
|
+
include
|
|
142
143
|
}
|
|
143
144
|
});
|
|
144
145
|
return story;
|
|
@@ -157,7 +158,7 @@ class Client {
|
|
|
157
158
|
} = await this.apiClient.post(url, {
|
|
158
159
|
headers: acceptedFormatsHeader(formats),
|
|
159
160
|
query: {
|
|
160
|
-
include
|
|
161
|
+
include
|
|
161
162
|
},
|
|
162
163
|
payload: {
|
|
163
164
|
culture
|
|
@@ -10,85 +10,122 @@ declare type Formats = Story.FormatVersion[];
|
|
|
10
10
|
* Utility type to forbid arbitrary ad-hoc extensions of generic parameters.
|
|
11
11
|
* @see https://stackoverflow.com/a/69666350
|
|
12
12
|
*/
|
|
13
|
-
declare type Exactly<
|
|
13
|
+
declare type Exactly<Concrete, Abstract> = Concrete & Record<Exclude<keyof Concrete, keyof Abstract>, never>;
|
|
14
|
+
declare type InferExtraFields<T> = T extends Required<IncludeOptions<infer I>> ? Pick<Story.ExtraFields, I> : unknown;
|
|
14
15
|
export declare class Client {
|
|
15
16
|
private readonly apiClient;
|
|
16
17
|
constructor(apiClient: DeferredJobsApiClient);
|
|
17
|
-
list<
|
|
18
|
-
search<
|
|
18
|
+
list<Options extends ListOptions>(options?: Exactly<Options, ListOptions>): Promise<ListResponse<Story & InferExtraFields<Options>>>;
|
|
19
|
+
search<Options extends SearchOptions>(options?: Exactly<Options, SearchOptions>): Promise<ListResponse<Story & InferExtraFields<Options>>>;
|
|
19
20
|
/**
|
|
20
21
|
* Get story by UUID.
|
|
21
22
|
*/
|
|
22
|
-
get<
|
|
23
|
+
get<Options extends IncludeOptions & {
|
|
23
24
|
formats?: Formats;
|
|
24
|
-
}
|
|
25
|
+
}>(id: Story['uuid'], options?: Exactly<Options, IncludeOptions & {
|
|
26
|
+
formats?: Formats;
|
|
27
|
+
}>): Promise<ExtendedStory & InferExtraFields<Options>>;
|
|
25
28
|
/**
|
|
26
29
|
* Get multiple stories by UUIDs.
|
|
27
30
|
*/
|
|
28
|
-
get<
|
|
31
|
+
get<Options extends IncludeOptions & {
|
|
32
|
+
formats?: Formats;
|
|
33
|
+
}>(ids: Story['uuid'][], options?: Exactly<Options, IncludeOptions & {
|
|
29
34
|
formats?: Formats;
|
|
30
|
-
}): Promise<
|
|
35
|
+
}>): Promise<(ExtendedStory & InferExtraFields<Options>)[]>;
|
|
31
36
|
/**
|
|
32
37
|
* Get story by deprecated numeric ID, or UUID.
|
|
33
38
|
* @deprecated Please use UUID instead.
|
|
34
39
|
*/
|
|
35
|
-
get<
|
|
40
|
+
get<Options extends IncludeOptions & {
|
|
41
|
+
formats?: Formats;
|
|
42
|
+
}>(id: Story['id'] | Story['uuid'], options?: Exactly<Options, IncludeOptions & {
|
|
36
43
|
formats?: Formats;
|
|
37
|
-
}): Promise<
|
|
44
|
+
}>): Promise<ExtendedStory & InferExtraFields<Options>>;
|
|
38
45
|
/**
|
|
39
46
|
* Get multiple stories by numeric IDs.
|
|
40
47
|
* @deprecated Please use UUID instead.
|
|
41
48
|
*/
|
|
42
|
-
get<
|
|
49
|
+
get<Options extends IncludeOptions & {
|
|
50
|
+
formats?: Formats;
|
|
51
|
+
}>(ids: Story['id'][], options?: Exactly<Options, IncludeOptions & {
|
|
52
|
+
formats?: Formats;
|
|
53
|
+
}>): Promise<(ExtendedStory & InferExtraFields<Options>)[]>;
|
|
54
|
+
create<Options extends IncludeOptions & {
|
|
43
55
|
formats?: Formats;
|
|
44
|
-
}
|
|
45
|
-
create<Include extends readonly (keyof Story.ExtraFields)[], Options extends IncludeOptions<Include>, StoryRecord extends ExtendedStory = Options['include'] extends Include ? ExtendedStory & Pick<Story.ExtraFields, Options['include'][number]> : ExtendedStory>(payload: CreateRequest, options?: Exactly<IncludeOptions<Include>, Options> & {
|
|
56
|
+
}>(payload: CreateRequest, options?: Exactly<Options, IncludeOptions & {
|
|
46
57
|
formats?: Formats;
|
|
47
|
-
}): Promise<
|
|
48
|
-
duplicate<
|
|
58
|
+
}>): Promise<ExtendedStory & InferExtraFields<Options>>;
|
|
59
|
+
duplicate<Options extends IncludeOptions & {
|
|
49
60
|
formats?: Formats;
|
|
50
|
-
}
|
|
51
|
-
translate<Include extends readonly (keyof Story.ExtraFields)[], Options extends IncludeOptions<Include>, StoryRecord extends ExtendedStory = Options['include'] extends Include ? ExtendedStory & Pick<Story.ExtraFields, Options['include'][number]> : ExtendedStory>(id: StoryId, payload?: TranslateRequest, options?: Exactly<IncludeOptions<Include>, Options> & {
|
|
61
|
+
}>(id: StoryId, options?: Exactly<Options, IncludeOptions & {
|
|
52
62
|
formats?: Formats;
|
|
53
|
-
}): Promise<
|
|
54
|
-
|
|
63
|
+
}>): Promise<ExtendedStory & InferExtraFields<Options>>;
|
|
64
|
+
translate<Options extends IncludeOptions & {
|
|
65
|
+
formats?: Formats;
|
|
66
|
+
}>(id: StoryId, payload?: TranslateRequest, options?: Exactly<Options, IncludeOptions & {
|
|
67
|
+
formats?: Formats;
|
|
68
|
+
}>): Promise<ExtendedStory & InferExtraFields<Options>>;
|
|
69
|
+
move<Options extends IncludeOptions & {
|
|
55
70
|
force?: true;
|
|
56
71
|
formats?: Formats;
|
|
57
|
-
}
|
|
58
|
-
|
|
72
|
+
}>(id: StoryId, payload: MoveRequest, options?: Exactly<Options, IncludeOptions & {
|
|
73
|
+
force?: true;
|
|
74
|
+
formats?: Formats;
|
|
75
|
+
}>): Promise<ChangeNewsroomSuccessResponse<ExtendedStory & InferExtraFields<Options>> | ChangeNewsroomUnsafeResponse>;
|
|
76
|
+
update<Options extends IncludeOptions & {
|
|
77
|
+
formats?: Formats;
|
|
78
|
+
}>(id: StoryId, payload: UpdateRequest, options?: Exactly<Options, IncludeOptions & {
|
|
59
79
|
formats?: Formats;
|
|
60
|
-
}): Promise<
|
|
80
|
+
}>): Promise<ExtendedStory & InferExtraFields<Options>>;
|
|
61
81
|
/**
|
|
62
82
|
* This operation is only allowed for V3 stories
|
|
63
83
|
*/
|
|
64
|
-
autosave<
|
|
84
|
+
autosave<Options extends IncludeOptions & {
|
|
65
85
|
formats?: Formats;
|
|
66
|
-
}
|
|
86
|
+
}>(id: StoryId, payload: AutosaveRequest, options?: Exactly<Options, IncludeOptions & {
|
|
87
|
+
formats?: Formats;
|
|
88
|
+
}>): Promise<ExtendedStory & InferExtraFields<Options>>;
|
|
67
89
|
/**
|
|
68
90
|
* This operation is only allowed for V3 stories
|
|
69
91
|
*/
|
|
70
|
-
revert<
|
|
92
|
+
revert<Options extends IncludeOptions & {
|
|
93
|
+
formats?: Formats;
|
|
94
|
+
}>(id: StoryId, payload?: RevertRequest, options?: Exactly<Options, IncludeOptions & {
|
|
95
|
+
formats?: Formats;
|
|
96
|
+
}>): Promise<ExtendedStory & InferExtraFields<Options>>;
|
|
97
|
+
publish<Options extends IncludeOptions & {
|
|
98
|
+
formats?: Formats;
|
|
99
|
+
}>(id: StoryId, payload?: PublishRequest, options?: Exactly<Options, IncludeOptions & {
|
|
100
|
+
formats?: Formats;
|
|
101
|
+
}>): Promise<ExtendedStory & InferExtraFields<Options>>;
|
|
102
|
+
unpublish<Options extends IncludeOptions & {
|
|
71
103
|
formats?: Formats;
|
|
72
|
-
}
|
|
73
|
-
publish<Include extends readonly (keyof Story.ExtraFields)[], Options extends IncludeOptions<Include>, StoryRecord extends ExtendedStory = Options['include'] extends Include ? ExtendedStory & Pick<Story.ExtraFields, Options['include'][number]> : ExtendedStory>(id: StoryId, payload?: PublishRequest, options?: Exactly<IncludeOptions<Include>, Options> & {
|
|
104
|
+
}>(id: StoryId, payload?: UnpublishRequest, options?: Exactly<Options, IncludeOptions & {
|
|
74
105
|
formats?: Formats;
|
|
75
|
-
}): Promise<
|
|
76
|
-
|
|
106
|
+
}>): Promise<ExtendedStory & InferExtraFields<Options>>;
|
|
107
|
+
schedule<Options extends IncludeOptions & {
|
|
77
108
|
formats?: Formats;
|
|
78
|
-
}
|
|
79
|
-
schedule<Include extends readonly (keyof Story.ExtraFields)[], Options extends IncludeOptions<Include>, StoryRecord extends ExtendedStory = Options['include'] extends Include ? ExtendedStory & Pick<Story.ExtraFields, Options['include'][number]> : ExtendedStory>(id: StoryId, payload?: ScheduleRequest, options?: Exactly<IncludeOptions<Include>, Options> & {
|
|
109
|
+
}>(id: StoryId, payload?: ScheduleRequest, options?: Exactly<Options, IncludeOptions & {
|
|
80
110
|
formats?: Formats;
|
|
81
|
-
}): Promise<
|
|
82
|
-
unschedule<
|
|
111
|
+
}>): Promise<ExtendedStory & InferExtraFields<Options>>;
|
|
112
|
+
unschedule<Options extends IncludeOptions & {
|
|
83
113
|
formats?: Formats;
|
|
84
|
-
}
|
|
85
|
-
|
|
114
|
+
}>(id: StoryId, payload?: UnscheduleRequest, options?: Exactly<Options, IncludeOptions & {
|
|
115
|
+
formats?: Formats;
|
|
116
|
+
}>): Promise<ExtendedStory & InferExtraFields<Options>>;
|
|
117
|
+
pin<Options extends IncludeOptions & {
|
|
118
|
+
force?: boolean;
|
|
119
|
+
formats?: Formats;
|
|
120
|
+
}>(id: StoryId, options?: Exactly<Options, IncludeOptions & {
|
|
86
121
|
force?: boolean;
|
|
87
122
|
formats?: Formats;
|
|
88
|
-
}): Promise<
|
|
89
|
-
unpin<
|
|
123
|
+
}>): Promise<ExtendedStory & InferExtraFields<Options>>;
|
|
124
|
+
unpin<Options extends IncludeOptions & {
|
|
125
|
+
formats?: Formats;
|
|
126
|
+
}>(id: StoryId, options?: Exactly<Options, IncludeOptions & {
|
|
90
127
|
formats?: Formats;
|
|
91
|
-
}): Promise<
|
|
128
|
+
}>): Promise<ExtendedStory & InferExtraFields<Options>>;
|
|
92
129
|
delete(id: StoryId): Promise<void>;
|
|
93
130
|
preview(id: StoryId, options?: PreviewOptions): Promise<PreviewResponse>;
|
|
94
131
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ApiError, HttpCodes } from "../../http/index.js";
|
|
2
2
|
import { routing } from "../../routing.js";
|
|
3
3
|
import { SortOrder } from "../../types/index.js";
|
|
4
|
+
import { EXTENDED_STORY_INCLUDED_EXTRA_FIELDS } from "./types.js"; /**
|
|
5
|
+
* `uuid` is the preferred way of targeting a Story. Numeric `id` is considered deprecated.
|
|
6
|
+
*/
|
|
4
7
|
export class Client {
|
|
5
8
|
constructor(apiClient) {
|
|
6
9
|
this.apiClient = apiClient;
|
|
@@ -75,7 +78,7 @@ export class Client {
|
|
|
75
78
|
$in: arg
|
|
76
79
|
}
|
|
77
80
|
},
|
|
78
|
-
include,
|
|
81
|
+
include: [...EXTENDED_STORY_INCLUDED_EXTRA_FIELDS, ...(include ?? [])],
|
|
79
82
|
formats
|
|
80
83
|
});
|
|
81
84
|
return stories;
|
|
@@ -90,7 +93,7 @@ export class Client {
|
|
|
90
93
|
$in: arg
|
|
91
94
|
}
|
|
92
95
|
},
|
|
93
|
-
include,
|
|
96
|
+
include: [...EXTENDED_STORY_INCLUDED_EXTRA_FIELDS, ...(include ?? [])],
|
|
94
97
|
formats
|
|
95
98
|
});
|
|
96
99
|
return stories;
|
|
@@ -100,7 +103,7 @@ export class Client {
|
|
|
100
103
|
} = await this.apiClient.get(`${routing.storiesUrl}/${arg}`, {
|
|
101
104
|
headers: acceptedFormatsHeader(formats),
|
|
102
105
|
query: {
|
|
103
|
-
include
|
|
106
|
+
include
|
|
104
107
|
}
|
|
105
108
|
});
|
|
106
109
|
return story;
|
|
@@ -116,7 +119,7 @@ export class Client {
|
|
|
116
119
|
headers: acceptedFormatsHeader(formats),
|
|
117
120
|
payload,
|
|
118
121
|
query: {
|
|
119
|
-
include
|
|
122
|
+
include
|
|
120
123
|
}
|
|
121
124
|
});
|
|
122
125
|
return story;
|
|
@@ -132,7 +135,7 @@ export class Client {
|
|
|
132
135
|
} = await this.apiClient.post(url, {
|
|
133
136
|
headers: acceptedFormatsHeader(formats),
|
|
134
137
|
query: {
|
|
135
|
-
include
|
|
138
|
+
include
|
|
136
139
|
}
|
|
137
140
|
});
|
|
138
141
|
return story;
|
|
@@ -151,7 +154,7 @@ export class Client {
|
|
|
151
154
|
} = await this.apiClient.post(url, {
|
|
152
155
|
headers: acceptedFormatsHeader(formats),
|
|
153
156
|
query: {
|
|
154
|
-
include
|
|
157
|
+
include
|
|
155
158
|
},
|
|
156
159
|
payload: {
|
|
157
160
|
culture
|
|
@@ -49,18 +49,18 @@ interface StoryEmbeddedContactsWillBeRemovedWarning extends BaseWarning {
|
|
|
49
49
|
value: NewsroomContactRef[];
|
|
50
50
|
}
|
|
51
51
|
export declare type ChangeNewsroomWarning = ChangingNewsroomUnsafeOperationWarning | DestinationNewsroomMissingCategoriesWarning | DestinationNewsroomMissingCulturesWarning | StoryEmbeddedContactsWillBeRemovedWarning | StoryTranslationsWillMoveWarning;
|
|
52
|
-
export interface IncludeOptions<Include extends
|
|
53
|
-
include?: Include;
|
|
52
|
+
export interface IncludeOptions<Include extends keyof Story.ExtraFields = keyof Story.ExtraFields> {
|
|
53
|
+
include?: Include[];
|
|
54
54
|
}
|
|
55
|
-
export interface ListOptions<Include extends
|
|
55
|
+
export interface ListOptions<Include extends keyof Story.ExtraFields = keyof Story.ExtraFields> {
|
|
56
56
|
search?: string;
|
|
57
57
|
limit?: number;
|
|
58
58
|
offset?: number;
|
|
59
59
|
sortOrder?: SortOrder | string;
|
|
60
|
-
include?: Include;
|
|
60
|
+
include?: Include[];
|
|
61
61
|
formats?: Story.FormatVersion[];
|
|
62
62
|
}
|
|
63
|
-
export interface SearchOptions<Include extends
|
|
63
|
+
export interface SearchOptions<Include extends keyof Story.ExtraFields = keyof Story.ExtraFields> extends ListOptions<Include> {
|
|
64
64
|
query?: Query;
|
|
65
65
|
scope?: Query;
|
|
66
66
|
}
|