@isardsat/editorial-client 6.13.2 → 6.15.0
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/CHANGELOG.md +27 -0
- package/dist/client.js +3 -0
- package/dist/types.d.ts +2 -0
- package/package.json +2 -2
- package/src/client.ts +17 -13
- package/src/types.ts +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @isardsat/editorial-client
|
|
2
2
|
|
|
3
|
+
## 6.15.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7ff5f4d: - Adds a new /api/v1/meta-schema endpoint that returns the JSON Schema for the Editorial configuration.
|
|
8
|
+
- Includes optional `allowedExtraFields` parameter to allow additional fields not defined in the meta-schema.
|
|
9
|
+
- - Updated the CLI `init` command to automatically add the line `# yaml-language-server: $schema=http://localhost:3001/api/v1/meta-schema` to schema.yml
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [7ff5f4d]
|
|
14
|
+
- @isardsat/editorial-common@6.15.0
|
|
15
|
+
|
|
16
|
+
## 6.14.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- 61cb350: This PR adds:
|
|
21
|
+
- select and multiselect (with maxSelectedItems and 'minSelectedItems` optional fields) field types.
|
|
22
|
+
- Support for dynamic options via $field_name references to populate from other data types.
|
|
23
|
+
- resolve param to /api/v1/data /api/v1/data/{itemType} /api/v1/data/{itemType}/{id} GET endpoints which resolve referenced fields to full objects.
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [61cb350]
|
|
28
|
+
- @isardsat/editorial-common@6.14.0
|
|
29
|
+
|
|
3
30
|
## 6.13.2
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/dist/client.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export interface GetContentOptions {
|
|
|
10
10
|
locale?: string;
|
|
11
11
|
/** Include preview/draft content in the response */
|
|
12
12
|
preview?: boolean;
|
|
13
|
+
/** Resolve references to other content items in the response */
|
|
14
|
+
resolve?: boolean;
|
|
13
15
|
}
|
|
14
16
|
export interface EditorialClientInterface {
|
|
15
17
|
getSchema(): Promise<EditorialSchema>;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isardsat/editorial-client",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.15.0",
|
|
4
4
|
"description": "JavaScript client for the Editorial CMS API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@isardsat/editorial-common": "6.
|
|
9
|
+
"@isardsat/editorial-common": "6.15.0"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@tsconfig/node22": "^22.0.0",
|
package/src/client.ts
CHANGED
|
@@ -19,7 +19,7 @@ import type {
|
|
|
19
19
|
|
|
20
20
|
export function createEditorialClient(
|
|
21
21
|
baseURL: string,
|
|
22
|
-
options: ClientOptions = {}
|
|
22
|
+
options: ClientOptions = {},
|
|
23
23
|
): EditorialClientInterface {
|
|
24
24
|
const apiBaseURL = new URL("/api/v1/", baseURL);
|
|
25
25
|
const defaultLocale = options.defaultLocale || "en";
|
|
@@ -32,7 +32,7 @@ export function createEditorialClient(
|
|
|
32
32
|
|
|
33
33
|
async function request<T>(
|
|
34
34
|
endpoint: string,
|
|
35
|
-
requestOptions: RequestInit = {}
|
|
35
|
+
requestOptions: RequestInit = {},
|
|
36
36
|
): Promise<T> {
|
|
37
37
|
const url = new URL(endpoint, apiBaseURL);
|
|
38
38
|
|
|
@@ -67,7 +67,7 @@ export function createEditorialClient(
|
|
|
67
67
|
throw new EditorialError(
|
|
68
68
|
errorMessage || `HTTP ${response.status} ${response.statusText}`,
|
|
69
69
|
response.status,
|
|
70
|
-
response.statusText
|
|
70
|
+
response.statusText,
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -87,7 +87,7 @@ export function createEditorialClient(
|
|
|
87
87
|
`Network error: ${
|
|
88
88
|
error instanceof Error ? error.message : "Unknown error"
|
|
89
89
|
}`,
|
|
90
|
-
error instanceof Error ? error : undefined
|
|
90
|
+
error instanceof Error ? error : undefined,
|
|
91
91
|
);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -103,6 +103,10 @@ export function createEditorialClient(
|
|
|
103
103
|
params.append("preview", "true");
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
if (options.resolve) {
|
|
107
|
+
params.append("resolve", "true");
|
|
108
|
+
}
|
|
109
|
+
|
|
106
110
|
return params;
|
|
107
111
|
}
|
|
108
112
|
|
|
@@ -116,7 +120,7 @@ export function createEditorialClient(
|
|
|
116
120
|
},
|
|
117
121
|
|
|
118
122
|
async getContent<T = EditorialData>(
|
|
119
|
-
options: GetContentOptions = {}
|
|
123
|
+
options: GetContentOptions = {},
|
|
120
124
|
): Promise<T> {
|
|
121
125
|
const params = buildQueryParams(options);
|
|
122
126
|
const endpoint = params.toString() ? `data?${params}` : "data";
|
|
@@ -126,7 +130,7 @@ export function createEditorialClient(
|
|
|
126
130
|
|
|
127
131
|
async getContentByType<T = EditorialDataType>(
|
|
128
132
|
type: string,
|
|
129
|
-
options: GetContentOptions = {}
|
|
133
|
+
options: GetContentOptions = {},
|
|
130
134
|
): Promise<T[]> {
|
|
131
135
|
const params = buildQueryParams(options);
|
|
132
136
|
const endpoint = params.toString()
|
|
@@ -139,7 +143,7 @@ export function createEditorialClient(
|
|
|
139
143
|
|
|
140
144
|
async getContentIds(
|
|
141
145
|
type: string,
|
|
142
|
-
options: GetContentOptions = {}
|
|
146
|
+
options: GetContentOptions = {},
|
|
143
147
|
): Promise<string[]> {
|
|
144
148
|
const params = new URLSearchParams();
|
|
145
149
|
if (options.preview) {
|
|
@@ -156,7 +160,7 @@ export function createEditorialClient(
|
|
|
156
160
|
async getContentById<T = EditorialDataItem>(
|
|
157
161
|
type: string,
|
|
158
162
|
id: string,
|
|
159
|
-
options: GetContentOptions = {}
|
|
163
|
+
options: GetContentOptions = {},
|
|
160
164
|
): Promise<T> {
|
|
161
165
|
const params = buildQueryParams(options);
|
|
162
166
|
const endpoint = params.toString()
|
|
@@ -169,28 +173,28 @@ export function createEditorialClient(
|
|
|
169
173
|
async createContent<T = EditorialDataItem>(
|
|
170
174
|
type: string,
|
|
171
175
|
id: string,
|
|
172
|
-
data: T
|
|
176
|
+
data: T,
|
|
173
177
|
): Promise<T> {
|
|
174
178
|
return request<T>(
|
|
175
179
|
`data/${encodeURIComponent(type)}/${encodeURIComponent(id)}`,
|
|
176
180
|
{
|
|
177
181
|
method: "PUT",
|
|
178
182
|
body: JSON.stringify(data),
|
|
179
|
-
}
|
|
183
|
+
},
|
|
180
184
|
);
|
|
181
185
|
},
|
|
182
186
|
|
|
183
187
|
async updateContent<T = EditorialDataItem>(
|
|
184
188
|
type: string,
|
|
185
189
|
id: string,
|
|
186
|
-
data: Partial<T
|
|
190
|
+
data: Partial<T>,
|
|
187
191
|
): Promise<T> {
|
|
188
192
|
return request<T>(
|
|
189
193
|
`data/${encodeURIComponent(type)}/${encodeURIComponent(id)}`,
|
|
190
194
|
{
|
|
191
195
|
method: "PATCH",
|
|
192
196
|
body: JSON.stringify(data),
|
|
193
|
-
}
|
|
197
|
+
},
|
|
194
198
|
);
|
|
195
199
|
},
|
|
196
200
|
|
|
@@ -199,7 +203,7 @@ export function createEditorialClient(
|
|
|
199
203
|
`data/${encodeURIComponent(type)}/${encodeURIComponent(id)}`,
|
|
200
204
|
{
|
|
201
205
|
method: "DELETE",
|
|
202
|
-
}
|
|
206
|
+
},
|
|
203
207
|
);
|
|
204
208
|
},
|
|
205
209
|
};
|
package/src/types.ts
CHANGED
|
@@ -18,6 +18,8 @@ export interface GetContentOptions {
|
|
|
18
18
|
locale?: string;
|
|
19
19
|
/** Include preview/draft content in the response */
|
|
20
20
|
preview?: boolean;
|
|
21
|
+
/** Resolve references to other content items in the response */
|
|
22
|
+
resolve?: boolean;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export interface EditorialClientInterface {
|
|
@@ -26,23 +28,23 @@ export interface EditorialClientInterface {
|
|
|
26
28
|
getContent<T = EditorialData>(options?: GetContentOptions): Promise<T>;
|
|
27
29
|
getContentByType<T = EditorialDataType>(
|
|
28
30
|
type: string,
|
|
29
|
-
options?: GetContentOptions
|
|
31
|
+
options?: GetContentOptions,
|
|
30
32
|
): Promise<T[]>;
|
|
31
33
|
getContentIds(type: string, options?: GetContentOptions): Promise<string[]>;
|
|
32
34
|
getContentById<T = EditorialDataItem>(
|
|
33
35
|
type: string,
|
|
34
36
|
id: string,
|
|
35
|
-
options?: GetContentOptions
|
|
37
|
+
options?: GetContentOptions,
|
|
36
38
|
): Promise<T>;
|
|
37
39
|
createContent<T = EditorialDataItem>(
|
|
38
40
|
type: string,
|
|
39
41
|
id: string,
|
|
40
|
-
data: T
|
|
42
|
+
data: T,
|
|
41
43
|
): Promise<T>;
|
|
42
44
|
updateContent<T = EditorialDataItem>(
|
|
43
45
|
type: string,
|
|
44
46
|
id: string,
|
|
45
|
-
data: Partial<T
|
|
47
|
+
data: Partial<T>,
|
|
46
48
|
): Promise<T>;
|
|
47
49
|
deleteContent(type: string, id: string): Promise<boolean>;
|
|
48
50
|
}
|