@happyvertical/smrt-content 0.37.2 → 0.37.3

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.
@@ -1,390 +1,308 @@
1
+ //#region src/mock-smrt-client.ts
1
2
  function getListData(payload) {
2
- if (Array.isArray(payload)) {
3
- return payload;
4
- }
5
- if (payload && typeof payload === "object" && Array.isArray(payload.result)) {
6
- return payload.result;
7
- }
8
- if (payload && typeof payload === "object" && payload.result && typeof payload.result === "object" && Array.isArray(
9
- payload.result?.data
10
- )) {
11
- return payload.result.data;
12
- }
13
- if (payload && typeof payload === "object" && Array.isArray(payload.data)) {
14
- return payload.data;
15
- }
16
- if (payload && typeof payload === "object" && Array.isArray(payload.items)) {
17
- return payload.items;
18
- }
19
- return [];
3
+ if (Array.isArray(payload)) return payload;
4
+ if (payload && typeof payload === "object" && Array.isArray(payload.result)) return payload.result;
5
+ if (payload && typeof payload === "object" && payload.result && typeof payload.result === "object" && Array.isArray(payload.result?.data)) return payload.result.data;
6
+ if (payload && typeof payload === "object" && Array.isArray(payload.data)) return payload.data;
7
+ if (payload && typeof payload === "object" && Array.isArray(payload.items)) return payload.items;
8
+ return [];
20
9
  }
21
10
  function getItemData(payload) {
22
- if (payload && typeof payload === "object" && !Array.isArray(payload) && "result" in payload) {
23
- return payload.result;
24
- }
25
- if (payload && typeof payload === "object" && !Array.isArray(payload) && "data" in payload) {
26
- return payload.data;
27
- }
28
- return payload;
11
+ if (payload && typeof payload === "object" && !Array.isArray(payload) && "result" in payload) return payload.result;
12
+ if (payload && typeof payload === "object" && !Array.isArray(payload) && "data" in payload) return payload.data;
13
+ return payload;
29
14
  }
30
15
  function toQueryString(params) {
31
- const searchParams = new URLSearchParams();
32
- for (const [key, value] of Object.entries(params)) {
33
- if (value === void 0 || value === null || value === "") {
34
- continue;
35
- }
36
- searchParams.set(key, String(value));
37
- }
38
- const query = searchParams.toString();
39
- return query ? `?${query}` : "";
40
- }
41
- class ApiClient {
42
- constructor(baseUrl) {
43
- this.baseUrl = baseUrl;
44
- }
45
- baseUrl;
46
- async request(path, options) {
47
- const res = await fetch(`${this.baseUrl}${path}`, options);
48
- if (!res.ok) throw new Error(await res.text());
49
- const payload = await res.json();
50
- return { data: getItemData(payload), success: true };
51
- }
52
- async requestList(path, options) {
53
- const res = await fetch(`${this.baseUrl}${path}`, options);
54
- if (!res.ok) throw new Error(await res.text());
55
- const payload = await res.json();
56
- return { data: getListData(payload), success: true };
57
- }
58
- contents = {
59
- list: async () => this.requestList("/contents"),
60
- getBySlug: async (slug, options = {}) => this.request(
61
- `/contents/by-slug${toQueryString({
62
- slug,
63
- context: options.context,
64
- status: options.status
65
- })}`
66
- ),
67
- get: async (id) => this.request(`/contents/${id}`),
68
- create: async (contentData) => this.request("/contents", {
69
- method: "POST",
70
- headers: { "Content-Type": "application/json" },
71
- body: JSON.stringify(contentData)
72
- }),
73
- update: async (id, updates) => this.request(`/contents/${id}`, {
74
- method: "PUT",
75
- headers: { "Content-Type": "application/json" },
76
- body: JSON.stringify(updates)
77
- }),
78
- delete: async (id) => {
79
- const res = await fetch(`${this.baseUrl}/contents/${id}`, {
80
- method: "DELETE"
81
- });
82
- if (!res.ok) throw new Error(await res.text());
83
- return { data: void 0, success: true };
84
- },
85
- browseFacts: async (query = "", options = {}) => this.requestList(
86
- `/contents/facts${toQueryString({
87
- q: query,
88
- limit: options.limit,
89
- offset: options.offset,
90
- minSimilarity: options.minSimilarity,
91
- includeSuperseded: options.includeSuperseded,
92
- latestOnly: options.latestOnly
93
- })}`
94
- ),
95
- getFacts: async (id, relationship) => this.request(`/contents/${id}/facts${toQueryString({ relationship })}`),
96
- getFactAudit: async (id) => this.request(`/contents/${id}/fact-audit`),
97
- repairFactAudit: async (id, data = {}) => this.request(`/contents/${id}/fact-audit/repair`, {
98
- method: "POST",
99
- headers: { "Content-Type": "application/json" },
100
- body: JSON.stringify(data)
101
- }),
102
- repairFactEvidence: async (id, data = {}) => this.request(
103
- `/contents/${id}/fact-audit/evidence/repair`,
104
- {
105
- method: "POST",
106
- headers: { "Content-Type": "application/json" },
107
- body: JSON.stringify(data)
108
- }
109
- ),
110
- recheckFactClaims: async (id, data = {}) => this.request(
111
- `/contents/${id}/fact-audit/claims/recheck`,
112
- {
113
- method: "POST",
114
- headers: { "Content-Type": "application/json" },
115
- body: JSON.stringify(data)
116
- }
117
- ),
118
- updateFactEvidenceStatus: async (id, data = {}) => this.request(
119
- `/contents/${id}/fact-audit/evidence/status`,
120
- {
121
- method: "PUT",
122
- headers: { "Content-Type": "application/json" },
123
- body: JSON.stringify(data)
124
- }
125
- ),
126
- syncFacts: async (id, data) => this.request(`/contents/${id}/facts`, {
127
- method: "PUT",
128
- headers: { "Content-Type": "application/json" },
129
- body: JSON.stringify(data)
130
- }),
131
- getReviews: async (id, kind) => this.requestList(
132
- `/contents/${id}/reviews${toQueryString({ kind })}`
133
- ),
134
- getGovernanceState: async (id) => this.request(`/contents/${id}/governance`),
135
- getGovernanceDefinitions: async () => this.request("/contents/governance"),
136
- resolveGovernance: async (options) => this.request(
137
- `/contents/governance/resolve${toQueryString({
138
- type: options.type,
139
- variant: options.variant
140
- })}`
141
- ),
142
- getPublishedTransparency: async (id) => this.request(
143
- `/contents/${id}/transparency`
144
- ),
145
- getTransparencyPreview: async (id) => this.request(
146
- `/contents/${id}/transparency/preview`
147
- ),
148
- getReviewProfiles: async (id) => this.requestList(
149
- `/contents/${id}/review-profiles`
150
- ),
151
- getReviewProfile: async (id, profileKey) => this.request(
152
- `/contents/${id}/review-profiles/${encodeURIComponent(profileKey)}`
153
- ),
154
- runReview: async (id, data) => this.request(`/contents/${id}/reviews`, {
155
- method: "POST",
156
- headers: { "Content-Type": "application/json" },
157
- body: JSON.stringify(data)
158
- }),
159
- getCorrections: async (id) => this.requestList(`/contents/${id}/corrections`),
160
- issueCorrection: async (id, data) => this.request(`/contents/${id}/corrections`, {
161
- method: "POST",
162
- headers: { "Content-Type": "application/json" },
163
- body: JSON.stringify(data)
164
- }),
165
- getVersions: async (id) => this.requestList(`/contents/${id}/versions`),
166
- createVersion: async (id, data) => this.request(`/contents/${id}/versions`, {
167
- method: "POST",
168
- headers: { "Content-Type": "application/json" },
169
- body: JSON.stringify(data)
170
- }),
171
- restoreVersion: async (id, versionNumber) => this.request(`/contents/${id}/versions`, {
172
- method: "POST",
173
- headers: { "Content-Type": "application/json" },
174
- body: JSON.stringify({
175
- action: "restore",
176
- versionNumber
177
- })
178
- })
179
- };
180
- contentGovernancePolicies = {
181
- list: async () => this.requestList("/contentgovernancepolicies"),
182
- get: async (id) => this.request(`/contentgovernancepolicies/${id}`),
183
- create: async (data) => this.request("/contentgovernancepolicies", {
184
- method: "POST",
185
- headers: { "Content-Type": "application/json" },
186
- body: JSON.stringify(data)
187
- }),
188
- update: async (id, data) => this.request(
189
- `/contentgovernancepolicies/${id}`,
190
- {
191
- method: "PUT",
192
- headers: { "Content-Type": "application/json" },
193
- body: JSON.stringify(data)
194
- }
195
- ),
196
- delete: async (id) => {
197
- const res = await fetch(
198
- `${this.baseUrl}/contentgovernancepolicies/${id}`,
199
- {
200
- method: "DELETE"
201
- }
202
- );
203
- if (!res.ok) throw new Error(await res.text());
204
- return { data: void 0, success: true };
205
- }
206
- };
207
- contentGovernanceProfiles = {
208
- list: async () => this.requestList(
209
- "/contentgovernanceprofiles"
210
- ),
211
- get: async (id) => this.request(
212
- `/contentgovernanceprofiles/${id}`
213
- ),
214
- create: async (data) => this.request("/contentgovernanceprofiles", {
215
- method: "POST",
216
- headers: { "Content-Type": "application/json" },
217
- body: JSON.stringify(data)
218
- }),
219
- update: async (id, data) => this.request(
220
- `/contentgovernanceprofiles/${id}`,
221
- {
222
- method: "PUT",
223
- headers: { "Content-Type": "application/json" },
224
- body: JSON.stringify(data)
225
- }
226
- ),
227
- delete: async (id) => {
228
- const res = await fetch(
229
- `${this.baseUrl}/contentgovernanceprofiles/${id}`,
230
- {
231
- method: "DELETE"
232
- }
233
- );
234
- if (!res.ok) throw new Error(await res.text());
235
- return { data: void 0, success: true };
236
- }
237
- };
238
- contentGovernanceAssignments = {
239
- list: async () => this.requestList(
240
- "/contentgovernanceassignments"
241
- ),
242
- get: async (id) => this.request(
243
- `/contentgovernanceassignments/${id}`
244
- ),
245
- create: async (data) => this.request(
246
- "/contentgovernanceassignments",
247
- {
248
- method: "POST",
249
- headers: { "Content-Type": "application/json" },
250
- body: JSON.stringify(data)
251
- }
252
- ),
253
- update: async (id, data) => this.request(
254
- `/contentgovernanceassignments/${id}`,
255
- {
256
- method: "PUT",
257
- headers: { "Content-Type": "application/json" },
258
- body: JSON.stringify(data)
259
- }
260
- ),
261
- delete: async (id) => {
262
- const res = await fetch(
263
- `${this.baseUrl}/contentgovernanceassignments/${id}`,
264
- {
265
- method: "DELETE"
266
- }
267
- );
268
- if (!res.ok) throw new Error(await res.text());
269
- return { data: void 0, success: true };
270
- }
271
- };
272
- contentContributions = {
273
- list: async () => this.requestList("/contentcontributions"),
274
- get: async (id) => this.request(`/contentcontributions/${id}`),
275
- submitWebContribution: async (payload) => this.request("/contentcontributions/submit", {
276
- method: "POST",
277
- headers: { "Content-Type": "application/json" },
278
- body: JSON.stringify(payload)
279
- }),
280
- ingestEmailContribution: async (payload) => this.request("/contentcontributions/ingest-email", {
281
- method: "POST",
282
- headers: { "Content-Type": "application/json" },
283
- body: JSON.stringify(payload)
284
- }),
285
- appendRevision: async (id, payload) => this.request(`/contentcontributions/${id}/revisions`, {
286
- method: "POST",
287
- headers: { "Content-Type": "application/json" },
288
- body: JSON.stringify(payload)
289
- }),
290
- requestChanges: async (id, payload) => this.request(`/contentcontributions/${id}/request-changes`, {
291
- method: "POST",
292
- headers: { "Content-Type": "application/json" },
293
- body: JSON.stringify(payload)
294
- }),
295
- approve: async (id, payload = {}) => this.request(`/contentcontributions/${id}/approve`, {
296
- method: "POST",
297
- headers: { "Content-Type": "application/json" },
298
- body: JSON.stringify(payload)
299
- }),
300
- reject: async (id, payload = {}) => this.request(`/contentcontributions/${id}/reject`, {
301
- method: "POST",
302
- headers: { "Content-Type": "application/json" },
303
- body: JSON.stringify(payload)
304
- }),
305
- withdraw: async (id, payload = {}) => this.request(`/contentcontributions/${id}/withdraw`, {
306
- method: "POST",
307
- headers: { "Content-Type": "application/json" },
308
- body: JSON.stringify(payload)
309
- }),
310
- promote: async (id, payload = {}) => this.request(`/contentcontributions/${id}/promote`, {
311
- method: "POST",
312
- headers: { "Content-Type": "application/json" },
313
- body: JSON.stringify(payload)
314
- }),
315
- listForContributor: async (options = {}) => this.requestList(
316
- `/contentcontributions/by-contributor${toQueryString(options)}`
317
- ),
318
- listInbox: async (options = {}) => this.requestList(
319
- `/contentcontributions/inbox${toQueryString({
320
- statuses: Array.isArray(options.statuses) ? options.statuses.join(",") : options.statuses
321
- })}`
322
- ),
323
- getContributionTypes: async () => this.request("/contentcontributions/types")
324
- };
325
- contentContributionTypes = {
326
- list: async () => this.requestList(
327
- "/contentcontributiontypes"
328
- ),
329
- get: async (id) => this.request(
330
- `/contentcontributiontypes/${id}`
331
- ),
332
- create: async (data) => this.request("/contentcontributiontypes", {
333
- method: "POST",
334
- headers: { "Content-Type": "application/json" },
335
- body: JSON.stringify(data)
336
- }),
337
- update: async (id, data) => this.request(
338
- `/contentcontributiontypes/${id}`,
339
- {
340
- method: "PUT",
341
- headers: { "Content-Type": "application/json" },
342
- body: JSON.stringify(data)
343
- }
344
- ),
345
- delete: async (id) => {
346
- const res = await fetch(
347
- `${this.baseUrl}/contentcontributiontypes/${id}`,
348
- {
349
- method: "DELETE"
350
- }
351
- );
352
- if (!res.ok) throw new Error(await res.text());
353
- return { data: void 0, success: true };
354
- }
355
- };
356
- contentContributors = {
357
- list: async () => this.requestList("/contentcontributors"),
358
- get: async (id) => this.request(`/contentcontributors/${id}`),
359
- create: async (data) => this.request("/contentcontributors", {
360
- method: "POST",
361
- headers: { "Content-Type": "application/json" },
362
- body: JSON.stringify(data)
363
- }),
364
- update: async (id, data) => this.request(`/contentcontributors/${id}`, {
365
- method: "PUT",
366
- headers: { "Content-Type": "application/json" },
367
- body: JSON.stringify(data)
368
- }),
369
- delete: async (id) => {
370
- const res = await fetch(`${this.baseUrl}/contentcontributors/${id}`, {
371
- method: "DELETE"
372
- });
373
- if (!res.ok) throw new Error(await res.text());
374
- return { data: void 0, success: true };
375
- }
376
- };
377
- contentVersions = {
378
- getTransparency: async (id) => this.request(
379
- `/contentversions/${id}/transparency`
380
- )
381
- };
16
+ const searchParams = new URLSearchParams();
17
+ for (const [key, value] of Object.entries(params)) {
18
+ if (value === void 0 || value === null || value === "") continue;
19
+ searchParams.set(key, String(value));
20
+ }
21
+ const query = searchParams.toString();
22
+ return query ? `?${query}` : "";
382
23
  }
24
+ var ApiClient = class {
25
+ constructor(baseUrl) {
26
+ this.baseUrl = baseUrl;
27
+ }
28
+ baseUrl;
29
+ async request(path, options) {
30
+ const res = await fetch(`${this.baseUrl}${path}`, options);
31
+ if (!res.ok) throw new Error(await res.text());
32
+ return {
33
+ data: getItemData(await res.json()),
34
+ success: true
35
+ };
36
+ }
37
+ async requestList(path, options) {
38
+ const res = await fetch(`${this.baseUrl}${path}`, options);
39
+ if (!res.ok) throw new Error(await res.text());
40
+ return {
41
+ data: getListData(await res.json()),
42
+ success: true
43
+ };
44
+ }
45
+ contents = {
46
+ list: async () => this.requestList("/contents"),
47
+ getBySlug: async (slug, options = {}) => this.request(`/contents/by-slug${toQueryString({
48
+ slug,
49
+ context: options.context,
50
+ status: options.status
51
+ })}`),
52
+ get: async (id) => this.request(`/contents/${id}`),
53
+ create: async (contentData) => this.request("/contents", {
54
+ method: "POST",
55
+ headers: { "Content-Type": "application/json" },
56
+ body: JSON.stringify(contentData)
57
+ }),
58
+ update: async (id, updates) => this.request(`/contents/${id}`, {
59
+ method: "PUT",
60
+ headers: { "Content-Type": "application/json" },
61
+ body: JSON.stringify(updates)
62
+ }),
63
+ delete: async (id) => {
64
+ const res = await fetch(`${this.baseUrl}/contents/${id}`, { method: "DELETE" });
65
+ if (!res.ok) throw new Error(await res.text());
66
+ return {
67
+ data: void 0,
68
+ success: true
69
+ };
70
+ },
71
+ browseFacts: async (query = "", options = {}) => this.requestList(`/contents/facts${toQueryString({
72
+ q: query,
73
+ limit: options.limit,
74
+ offset: options.offset,
75
+ minSimilarity: options.minSimilarity,
76
+ includeSuperseded: options.includeSuperseded,
77
+ latestOnly: options.latestOnly
78
+ })}`),
79
+ getFacts: async (id, relationship) => this.request(`/contents/${id}/facts${toQueryString({ relationship })}`),
80
+ getFactAudit: async (id) => this.request(`/contents/${id}/fact-audit`),
81
+ repairFactAudit: async (id, data = {}) => this.request(`/contents/${id}/fact-audit/repair`, {
82
+ method: "POST",
83
+ headers: { "Content-Type": "application/json" },
84
+ body: JSON.stringify(data)
85
+ }),
86
+ repairFactEvidence: async (id, data = {}) => this.request(`/contents/${id}/fact-audit/evidence/repair`, {
87
+ method: "POST",
88
+ headers: { "Content-Type": "application/json" },
89
+ body: JSON.stringify(data)
90
+ }),
91
+ recheckFactClaims: async (id, data = {}) => this.request(`/contents/${id}/fact-audit/claims/recheck`, {
92
+ method: "POST",
93
+ headers: { "Content-Type": "application/json" },
94
+ body: JSON.stringify(data)
95
+ }),
96
+ updateFactEvidenceStatus: async (id, data = {}) => this.request(`/contents/${id}/fact-audit/evidence/status`, {
97
+ method: "PUT",
98
+ headers: { "Content-Type": "application/json" },
99
+ body: JSON.stringify(data)
100
+ }),
101
+ syncFacts: async (id, data) => this.request(`/contents/${id}/facts`, {
102
+ method: "PUT",
103
+ headers: { "Content-Type": "application/json" },
104
+ body: JSON.stringify(data)
105
+ }),
106
+ getReviews: async (id, kind) => this.requestList(`/contents/${id}/reviews${toQueryString({ kind })}`),
107
+ getGovernanceState: async (id) => this.request(`/contents/${id}/governance`),
108
+ getGovernanceDefinitions: async () => this.request("/contents/governance"),
109
+ resolveGovernance: async (options) => this.request(`/contents/governance/resolve${toQueryString({
110
+ type: options.type,
111
+ variant: options.variant
112
+ })}`),
113
+ getPublishedTransparency: async (id) => this.request(`/contents/${id}/transparency`),
114
+ getTransparencyPreview: async (id) => this.request(`/contents/${id}/transparency/preview`),
115
+ getReviewProfiles: async (id) => this.requestList(`/contents/${id}/review-profiles`),
116
+ getReviewProfile: async (id, profileKey) => this.request(`/contents/${id}/review-profiles/${encodeURIComponent(profileKey)}`),
117
+ runReview: async (id, data) => this.request(`/contents/${id}/reviews`, {
118
+ method: "POST",
119
+ headers: { "Content-Type": "application/json" },
120
+ body: JSON.stringify(data)
121
+ }),
122
+ getCorrections: async (id) => this.requestList(`/contents/${id}/corrections`),
123
+ issueCorrection: async (id, data) => this.request(`/contents/${id}/corrections`, {
124
+ method: "POST",
125
+ headers: { "Content-Type": "application/json" },
126
+ body: JSON.stringify(data)
127
+ }),
128
+ getVersions: async (id) => this.requestList(`/contents/${id}/versions`),
129
+ createVersion: async (id, data) => this.request(`/contents/${id}/versions`, {
130
+ method: "POST",
131
+ headers: { "Content-Type": "application/json" },
132
+ body: JSON.stringify(data)
133
+ }),
134
+ restoreVersion: async (id, versionNumber) => this.request(`/contents/${id}/versions`, {
135
+ method: "POST",
136
+ headers: { "Content-Type": "application/json" },
137
+ body: JSON.stringify({
138
+ action: "restore",
139
+ versionNumber
140
+ })
141
+ })
142
+ };
143
+ contentGovernancePolicies = {
144
+ list: async () => this.requestList("/contentgovernancepolicies"),
145
+ get: async (id) => this.request(`/contentgovernancepolicies/${id}`),
146
+ create: async (data) => this.request("/contentgovernancepolicies", {
147
+ method: "POST",
148
+ headers: { "Content-Type": "application/json" },
149
+ body: JSON.stringify(data)
150
+ }),
151
+ update: async (id, data) => this.request(`/contentgovernancepolicies/${id}`, {
152
+ method: "PUT",
153
+ headers: { "Content-Type": "application/json" },
154
+ body: JSON.stringify(data)
155
+ }),
156
+ delete: async (id) => {
157
+ const res = await fetch(`${this.baseUrl}/contentgovernancepolicies/${id}`, { method: "DELETE" });
158
+ if (!res.ok) throw new Error(await res.text());
159
+ return {
160
+ data: void 0,
161
+ success: true
162
+ };
163
+ }
164
+ };
165
+ contentGovernanceProfiles = {
166
+ list: async () => this.requestList("/contentgovernanceprofiles"),
167
+ get: async (id) => this.request(`/contentgovernanceprofiles/${id}`),
168
+ create: async (data) => this.request("/contentgovernanceprofiles", {
169
+ method: "POST",
170
+ headers: { "Content-Type": "application/json" },
171
+ body: JSON.stringify(data)
172
+ }),
173
+ update: async (id, data) => this.request(`/contentgovernanceprofiles/${id}`, {
174
+ method: "PUT",
175
+ headers: { "Content-Type": "application/json" },
176
+ body: JSON.stringify(data)
177
+ }),
178
+ delete: async (id) => {
179
+ const res = await fetch(`${this.baseUrl}/contentgovernanceprofiles/${id}`, { method: "DELETE" });
180
+ if (!res.ok) throw new Error(await res.text());
181
+ return {
182
+ data: void 0,
183
+ success: true
184
+ };
185
+ }
186
+ };
187
+ contentGovernanceAssignments = {
188
+ list: async () => this.requestList("/contentgovernanceassignments"),
189
+ get: async (id) => this.request(`/contentgovernanceassignments/${id}`),
190
+ create: async (data) => this.request("/contentgovernanceassignments", {
191
+ method: "POST",
192
+ headers: { "Content-Type": "application/json" },
193
+ body: JSON.stringify(data)
194
+ }),
195
+ update: async (id, data) => this.request(`/contentgovernanceassignments/${id}`, {
196
+ method: "PUT",
197
+ headers: { "Content-Type": "application/json" },
198
+ body: JSON.stringify(data)
199
+ }),
200
+ delete: async (id) => {
201
+ const res = await fetch(`${this.baseUrl}/contentgovernanceassignments/${id}`, { method: "DELETE" });
202
+ if (!res.ok) throw new Error(await res.text());
203
+ return {
204
+ data: void 0,
205
+ success: true
206
+ };
207
+ }
208
+ };
209
+ contentContributions = {
210
+ list: async () => this.requestList("/contentcontributions"),
211
+ get: async (id) => this.request(`/contentcontributions/${id}`),
212
+ submitWebContribution: async (payload) => this.request("/contentcontributions/submit", {
213
+ method: "POST",
214
+ headers: { "Content-Type": "application/json" },
215
+ body: JSON.stringify(payload)
216
+ }),
217
+ ingestEmailContribution: async (payload) => this.request("/contentcontributions/ingest-email", {
218
+ method: "POST",
219
+ headers: { "Content-Type": "application/json" },
220
+ body: JSON.stringify(payload)
221
+ }),
222
+ appendRevision: async (id, payload) => this.request(`/contentcontributions/${id}/revisions`, {
223
+ method: "POST",
224
+ headers: { "Content-Type": "application/json" },
225
+ body: JSON.stringify(payload)
226
+ }),
227
+ requestChanges: async (id, payload) => this.request(`/contentcontributions/${id}/request-changes`, {
228
+ method: "POST",
229
+ headers: { "Content-Type": "application/json" },
230
+ body: JSON.stringify(payload)
231
+ }),
232
+ approve: async (id, payload = {}) => this.request(`/contentcontributions/${id}/approve`, {
233
+ method: "POST",
234
+ headers: { "Content-Type": "application/json" },
235
+ body: JSON.stringify(payload)
236
+ }),
237
+ reject: async (id, payload = {}) => this.request(`/contentcontributions/${id}/reject`, {
238
+ method: "POST",
239
+ headers: { "Content-Type": "application/json" },
240
+ body: JSON.stringify(payload)
241
+ }),
242
+ withdraw: async (id, payload = {}) => this.request(`/contentcontributions/${id}/withdraw`, {
243
+ method: "POST",
244
+ headers: { "Content-Type": "application/json" },
245
+ body: JSON.stringify(payload)
246
+ }),
247
+ promote: async (id, payload = {}) => this.request(`/contentcontributions/${id}/promote`, {
248
+ method: "POST",
249
+ headers: { "Content-Type": "application/json" },
250
+ body: JSON.stringify(payload)
251
+ }),
252
+ listForContributor: async (options = {}) => this.requestList(`/contentcontributions/by-contributor${toQueryString(options)}`),
253
+ listInbox: async (options = {}) => this.requestList(`/contentcontributions/inbox${toQueryString({ statuses: Array.isArray(options.statuses) ? options.statuses.join(",") : options.statuses })}`),
254
+ getContributionTypes: async () => this.request("/contentcontributions/types")
255
+ };
256
+ contentContributionTypes = {
257
+ list: async () => this.requestList("/contentcontributiontypes"),
258
+ get: async (id) => this.request(`/contentcontributiontypes/${id}`),
259
+ create: async (data) => this.request("/contentcontributiontypes", {
260
+ method: "POST",
261
+ headers: { "Content-Type": "application/json" },
262
+ body: JSON.stringify(data)
263
+ }),
264
+ update: async (id, data) => this.request(`/contentcontributiontypes/${id}`, {
265
+ method: "PUT",
266
+ headers: { "Content-Type": "application/json" },
267
+ body: JSON.stringify(data)
268
+ }),
269
+ delete: async (id) => {
270
+ const res = await fetch(`${this.baseUrl}/contentcontributiontypes/${id}`, { method: "DELETE" });
271
+ if (!res.ok) throw new Error(await res.text());
272
+ return {
273
+ data: void 0,
274
+ success: true
275
+ };
276
+ }
277
+ };
278
+ contentContributors = {
279
+ list: async () => this.requestList("/contentcontributors"),
280
+ get: async (id) => this.request(`/contentcontributors/${id}`),
281
+ create: async (data) => this.request("/contentcontributors", {
282
+ method: "POST",
283
+ headers: { "Content-Type": "application/json" },
284
+ body: JSON.stringify(data)
285
+ }),
286
+ update: async (id, data) => this.request(`/contentcontributors/${id}`, {
287
+ method: "PUT",
288
+ headers: { "Content-Type": "application/json" },
289
+ body: JSON.stringify(data)
290
+ }),
291
+ delete: async (id) => {
292
+ const res = await fetch(`${this.baseUrl}/contentcontributors/${id}`, { method: "DELETE" });
293
+ if (!res.ok) throw new Error(await res.text());
294
+ return {
295
+ data: void 0,
296
+ success: true
297
+ };
298
+ }
299
+ };
300
+ contentVersions = { getTransparency: async (id) => this.request(`/contentversions/${id}/transparency`) };
301
+ };
383
302
  function createClient(baseUrl = "/api/v1") {
384
- return new ApiClient(baseUrl);
303
+ return new ApiClient(baseUrl);
385
304
  }
386
- export {
387
- createClient,
388
- createClient as default
389
- };
390
- //# sourceMappingURL=mock-smrt-client.js.map
305
+ //#endregion
306
+ export { createClient, createClient as default };
307
+
308
+ //# sourceMappingURL=mock-smrt-client.js.map