@prismicio/e2e-tests-utils 1.18.0 → 1.19.0-pr.37.21fc0dd
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/README.md +24 -27
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/clients/apiClient.cjs +38 -38
- package/dist/clients/apiClient.cjs.map +1 -1
- package/dist/clients/apiClient.d.cts +30 -0
- package/dist/clients/apiClient.d.cts.map +1 -0
- package/dist/clients/apiClient.d.ts +23 -23
- package/dist/clients/apiClient.d.ts.map +1 -0
- package/dist/clients/apiClient.js +38 -38
- package/dist/clients/apiClient.js.map +1 -1
- package/dist/clients/assetApi.cjs +81 -93
- package/dist/clients/assetApi.cjs.map +1 -1
- package/dist/clients/assetApi.d.cts +105 -0
- package/dist/clients/assetApi.d.cts.map +1 -0
- package/dist/clients/assetApi.d.ts +96 -97
- package/dist/clients/assetApi.d.ts.map +1 -0
- package/dist/clients/assetApi.js +79 -91
- package/dist/clients/assetApi.js.map +1 -1
- package/dist/clients/authenticationApi.cjs +66 -73
- package/dist/clients/authenticationApi.cjs.map +1 -1
- package/dist/clients/authenticationApi.d.cts +20 -0
- package/dist/clients/authenticationApi.d.cts.map +1 -0
- package/dist/clients/authenticationApi.d.ts +18 -13
- package/dist/clients/authenticationApi.d.ts.map +1 -0
- package/dist/clients/authenticationApi.js +65 -72
- package/dist/clients/authenticationApi.js.map +1 -1
- package/dist/clients/contentApi.cjs +94 -103
- package/dist/clients/contentApi.cjs.map +1 -1
- package/dist/clients/contentApi.d.cts +116 -0
- package/dist/clients/contentApi.d.cts.map +1 -0
- package/dist/clients/contentApi.d.ts +102 -98
- package/dist/clients/contentApi.d.ts.map +1 -0
- package/dist/clients/contentApi.js +94 -103
- package/dist/clients/contentApi.js.map +1 -1
- package/dist/clients/coreApi.cjs +154 -145
- package/dist/clients/coreApi.cjs.map +1 -1
- package/dist/clients/coreApi.d.cts +142 -0
- package/dist/clients/coreApi.d.cts.map +1 -0
- package/dist/clients/coreApi.d.ts +131 -109
- package/dist/clients/coreApi.d.ts.map +1 -0
- package/dist/clients/coreApi.js +153 -144
- package/dist/clients/coreApi.js.map +1 -1
- package/dist/clients/customTypesApi.cjs +90 -99
- package/dist/clients/customTypesApi.cjs.map +1 -1
- package/dist/clients/customTypesApi.d.cts +46 -0
- package/dist/clients/customTypesApi.d.cts.map +1 -0
- package/dist/clients/customTypesApi.d.ts +45 -45
- package/dist/clients/customTypesApi.d.ts.map +1 -0
- package/dist/clients/customTypesApi.js +87 -98
- package/dist/clients/customTypesApi.js.map +1 -1
- package/dist/clients/integrationFields.cjs +96 -87
- package/dist/clients/integrationFields.cjs.map +1 -1
- package/dist/clients/integrationFields.d.cts +30 -0
- package/dist/clients/integrationFields.d.cts.map +1 -0
- package/dist/clients/integrationFields.d.ts +27 -22
- package/dist/clients/integrationFields.d.ts.map +1 -0
- package/dist/clients/integrationFields.js +93 -86
- package/dist/clients/integrationFields.js.map +1 -1
- package/dist/clients/manageV2.cjs +154 -171
- package/dist/clients/manageV2.cjs.map +1 -1
- package/dist/clients/manageV2.d.cts +105 -0
- package/dist/clients/manageV2.d.cts.map +1 -0
- package/dist/clients/manageV2.d.ts +103 -111
- package/dist/clients/manageV2.d.ts.map +1 -0
- package/dist/clients/manageV2.js +149 -169
- package/dist/clients/manageV2.js.map +1 -1
- package/dist/clients/migrationApi.cjs +37 -36
- package/dist/clients/migrationApi.cjs.map +1 -1
- package/dist/clients/migrationApi.d.cts +48 -0
- package/dist/clients/migrationApi.d.cts.map +1 -0
- package/dist/clients/migrationApi.d.ts +45 -39
- package/dist/clients/migrationApi.d.ts.map +1 -0
- package/dist/clients/migrationApi.js +35 -34
- package/dist/clients/migrationApi.js.map +1 -1
- package/dist/clients/wroom.cjs +101 -122
- package/dist/clients/wroom.cjs.map +1 -1
- package/dist/clients/wroom.d.cts +48 -0
- package/dist/clients/wroom.d.cts.map +1 -0
- package/dist/clients/wroom.d.ts +46 -47
- package/dist/clients/wroom.d.ts.map +1 -0
- package/dist/clients/wroom.js +99 -122
- package/dist/clients/wroom.js.map +1 -1
- package/dist/index.cjs +13 -15
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -7
- package/dist/index.js +5 -14
- package/dist/managers/repositories.cjs +159 -169
- package/dist/managers/repositories.cjs.map +1 -1
- package/dist/managers/repositories.d.cts +67 -0
- package/dist/managers/repositories.d.cts.map +1 -0
- package/dist/managers/repositories.d.ts +56 -63
- package/dist/managers/repositories.d.ts.map +1 -0
- package/dist/managers/repositories.js +148 -159
- package/dist/managers/repositories.js.map +1 -1
- package/dist/managers/repository.cjs +592 -616
- package/dist/managers/repository.cjs.map +1 -1
- package/dist/managers/repository.d.cts +339 -0
- package/dist/managers/repository.d.cts.map +1 -0
- package/dist/managers/repository.d.ts +334 -307
- package/dist/managers/repository.d.ts.map +1 -0
- package/dist/managers/repository.js +592 -616
- package/dist/managers/repository.js.map +1 -1
- package/dist/types.d.cts +41 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +35 -37
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/cookies.cjs +19 -17
- package/dist/utils/cookies.cjs.map +1 -1
- package/dist/utils/cookies.js +20 -18
- package/dist/utils/cookies.js.map +1 -1
- package/dist/utils/envVariableManager.cjs +33 -34
- package/dist/utils/envVariableManager.cjs.map +1 -1
- package/dist/utils/envVariableManager.js +34 -35
- package/dist/utils/envVariableManager.js.map +1 -1
- package/dist/utils/log.cjs +18 -19
- package/dist/utils/log.cjs.map +1 -1
- package/dist/utils/log.js +18 -21
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/random.cjs +13 -6
- package/dist/utils/random.cjs.map +1 -1
- package/dist/utils/random.js +13 -6
- package/dist/utils/random.js.map +1 -1
- package/dist/utils/strings.cjs +13 -7
- package/dist/utils/strings.cjs.map +1 -1
- package/dist/utils/strings.js +14 -8
- package/dist/utils/strings.js.map +1 -1
- package/dist/utils/urls.cjs +21 -10
- package/dist/utils/urls.cjs.map +1 -1
- package/dist/utils/urls.js +22 -12
- package/dist/utils/urls.js.map +1 -1
- package/package.json +42 -67
- package/src/clients/apiClient.ts +16 -21
- package/src/clients/assetApi.ts +75 -82
- package/src/clients/authenticationApi.ts +54 -27
- package/src/clients/contentApi.ts +111 -129
- package/src/clients/coreApi.ts +165 -117
- package/src/clients/customTypesApi.ts +54 -74
- package/src/clients/integrationFields.ts +59 -74
- package/src/clients/manageV2.ts +72 -96
- package/src/clients/migrationApi.ts +35 -39
- package/src/clients/wroom.ts +42 -56
- package/src/index.ts +7 -7
- package/src/managers/repositories.ts +85 -108
- package/src/managers/repository.ts +394 -368
- package/src/types.ts +31 -31
- package/src/utils/cookies.ts +8 -8
- package/src/utils/envVariableManager.ts +15 -15
- package/src/utils/log.ts +17 -21
- package/src/utils/random.ts +5 -6
- package/src/utils/strings.ts +7 -9
- package/src/utils/urls.ts +10 -12
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/utils/cookies.d.ts +0 -8
- package/dist/utils/envVariableManager.d.ts +0 -16
- package/dist/utils/log.d.ts +0 -5
- package/dist/utils/random.d.ts +0 -8
- package/dist/utils/strings.d.ts +0 -11
- package/dist/utils/urls.d.ts +0 -16
|
@@ -1,129 +1,126 @@
|
|
|
1
|
-
import { APIResponse } from "@playwright/test"
|
|
1
|
+
import type { APIResponse } from "@playwright/test"
|
|
2
2
|
|
|
3
|
-
import { AuthenticatedApiClient } from "./apiClient"
|
|
3
|
+
import { AuthenticatedApiClient } from "./apiClient"
|
|
4
4
|
|
|
5
5
|
export interface ContentApiError {
|
|
6
|
-
type: string
|
|
7
|
-
message: string
|
|
6
|
+
type: string
|
|
7
|
+
message: string
|
|
8
8
|
}
|
|
9
9
|
export interface ContentApiSearchResponse {
|
|
10
|
-
page: number
|
|
11
|
-
results_per_page: number
|
|
12
|
-
results_size: number
|
|
13
|
-
total_results_size: number
|
|
14
|
-
total_pages: number
|
|
15
|
-
next_page: string | null
|
|
16
|
-
prev_page: string | null
|
|
17
|
-
results: ContentApiDocument[]
|
|
10
|
+
page: number
|
|
11
|
+
results_per_page: number
|
|
12
|
+
results_size: number
|
|
13
|
+
total_results_size: number
|
|
14
|
+
total_pages: number
|
|
15
|
+
next_page: string | null
|
|
16
|
+
prev_page: string | null
|
|
17
|
+
results: ContentApiDocument[]
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export interface ContentApiDocument {
|
|
21
|
-
id: string
|
|
22
|
-
uid: string | null
|
|
23
|
-
url: string | null
|
|
24
|
-
type: string
|
|
25
|
-
href: string
|
|
26
|
-
tags: string[]
|
|
27
|
-
first_publication_date: string
|
|
28
|
-
last_publication_date: string
|
|
29
|
-
slugs: string[]
|
|
30
|
-
linked_documents: unknown[]
|
|
31
|
-
lang: string
|
|
32
|
-
alternate_languages: ContentApiAlternateLanguage[]
|
|
21
|
+
id: string
|
|
22
|
+
uid: string | null
|
|
23
|
+
url: string | null
|
|
24
|
+
type: string
|
|
25
|
+
href: string
|
|
26
|
+
tags: string[]
|
|
27
|
+
first_publication_date: string
|
|
28
|
+
last_publication_date: string
|
|
29
|
+
slugs: string[]
|
|
30
|
+
linked_documents: unknown[]
|
|
31
|
+
lang: string
|
|
32
|
+
alternate_languages: ContentApiAlternateLanguage[]
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
-
data: Record<string, any
|
|
34
|
+
data: Record<string, any>
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export interface ContentApiGraphQLResponse {
|
|
38
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
-
data: Record<string, any
|
|
39
|
+
data: Record<string, any>
|
|
40
40
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
-
errors?: { message: string; locations: any }[]
|
|
41
|
+
errors?: { message: string; locations: any }[]
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export interface ContentApiRef {
|
|
45
|
-
id: string
|
|
46
|
-
ref: string
|
|
47
|
-
label: string
|
|
48
|
-
isMasterRef?: boolean
|
|
49
|
-
scheduledAt?: number | undefined
|
|
45
|
+
id: string
|
|
46
|
+
ref: string
|
|
47
|
+
label: string
|
|
48
|
+
isMasterRef?: boolean
|
|
49
|
+
scheduledAt?: number | undefined
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
interface ContentApiAlternateLanguage {
|
|
53
|
-
id: string
|
|
54
|
-
type: string
|
|
55
|
-
lang: string
|
|
56
|
-
uid?: string
|
|
53
|
+
id: string
|
|
54
|
+
type: string
|
|
55
|
+
lang: string
|
|
56
|
+
uid?: string
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
interface ContentApiRepoConfigResponse {
|
|
60
|
-
refs: ContentApiRef[]
|
|
61
|
-
bookmarks: Record<string, unknown
|
|
62
|
-
types: Record<string, string
|
|
60
|
+
refs: ContentApiRef[]
|
|
61
|
+
bookmarks: Record<string, unknown>
|
|
62
|
+
types: Record<string, string>
|
|
63
63
|
languages: {
|
|
64
|
-
id: string
|
|
65
|
-
name: string
|
|
66
|
-
is_master: boolean
|
|
67
|
-
}[]
|
|
68
|
-
oauth_initiate: string
|
|
69
|
-
oauth_token: string
|
|
70
|
-
tags: string[]
|
|
71
|
-
license: string
|
|
72
|
-
version: string
|
|
64
|
+
id: string
|
|
65
|
+
name: string
|
|
66
|
+
is_master: boolean
|
|
67
|
+
}[]
|
|
68
|
+
oauth_initiate: string
|
|
69
|
+
oauth_token: string
|
|
70
|
+
tags: string[]
|
|
71
|
+
license: string
|
|
72
|
+
version: string
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
type SearchQueryParams = {
|
|
76
|
-
ref?: string
|
|
77
|
-
query?: string
|
|
78
|
-
q?: string
|
|
79
|
-
graphQuery?: string
|
|
80
|
-
fetchLinks?: string
|
|
81
|
-
orderings?: string
|
|
82
|
-
pageSize?: number
|
|
83
|
-
page?: number
|
|
84
|
-
lang?: string
|
|
85
|
-
after?: string
|
|
86
|
-
routes?: string
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
type ApiVersions = "v1" | "v2"
|
|
76
|
+
ref?: string
|
|
77
|
+
query?: string
|
|
78
|
+
q?: string
|
|
79
|
+
graphQuery?: string
|
|
80
|
+
fetchLinks?: string
|
|
81
|
+
orderings?: string
|
|
82
|
+
pageSize?: number
|
|
83
|
+
page?: number
|
|
84
|
+
lang?: string
|
|
85
|
+
after?: string
|
|
86
|
+
routes?: string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type ApiVersions = "v1" | "v2"
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
* Client to query the Prismic content api. Uses Playwright to benefit from
|
|
93
|
-
*
|
|
94
|
-
* https://prismic.io/docs/rest-api-technical-reference
|
|
92
|
+
* Client to query the Prismic content api. Uses Playwright to benefit from network request traces
|
|
93
|
+
* in your reports. See api docs: https://prismic.io/docs/rest-api-technical-reference
|
|
95
94
|
*/
|
|
96
95
|
export class ContentApiClient extends AuthenticatedApiClient {
|
|
97
|
-
private version: ApiVersions
|
|
98
|
-
private accessToken: string | undefined
|
|
96
|
+
private version: ApiVersions
|
|
97
|
+
private accessToken: string | undefined
|
|
99
98
|
|
|
100
99
|
/**
|
|
101
|
-
* @example
|
|
100
|
+
* @example
|
|
101
|
+
* To instantiate the class:
|
|
102
102
|
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
103
|
+
* ```js
|
|
104
|
+
* new ContentApiClient("https://my-repo.cdn.prismic.io", {
|
|
105
105
|
* version: "v2",
|
|
106
106
|
* accessToken: "my-secret-token",
|
|
107
|
-
*
|
|
108
|
-
*
|
|
107
|
+
* });
|
|
108
|
+
* ```
|
|
109
109
|
*
|
|
110
|
-
* @param baseURL -
|
|
110
|
+
* @param baseURL - The api base URL like https://my-repo.cdn.prismic.io
|
|
111
111
|
* @param config - Optional configuration
|
|
112
112
|
*
|
|
113
113
|
* - {@link config.version}: Api version, default is "v2"
|
|
114
114
|
* - {@link config.accessToken}: Access token for the content api -
|
|
115
|
-
*
|
|
115
|
+
* https://prismic.io/docs/access-token
|
|
116
116
|
*/
|
|
117
|
-
constructor(
|
|
118
|
-
baseURL: string,
|
|
119
|
-
config: { version?: ApiVersions; accessToken?: string } = {},
|
|
120
|
-
) {
|
|
117
|
+
constructor(baseURL: string, config: { version?: ApiVersions; accessToken?: string } = {}) {
|
|
121
118
|
// Use an empty string as Authorization header in case it is already set globally in the project Playwright config file.
|
|
122
119
|
// This is because the content api returns an error in case it gets an non-empty invalid Authorization
|
|
123
120
|
// even though it actually checks authorization from the access_token query parameter.
|
|
124
|
-
super(baseURL, config.accessToken || "")
|
|
125
|
-
this.version = config.version || "v2"
|
|
126
|
-
this.accessToken = config.accessToken
|
|
121
|
+
super(baseURL, config.accessToken || "")
|
|
122
|
+
this.version = config.version || "v2"
|
|
123
|
+
this.accessToken = config.accessToken
|
|
127
124
|
}
|
|
128
125
|
|
|
129
126
|
async get(
|
|
@@ -131,15 +128,15 @@ export class ContentApiClient extends AuthenticatedApiClient {
|
|
|
131
128
|
params?: SearchQueryParams,
|
|
132
129
|
headers?: Record<string, string>,
|
|
133
130
|
): Promise<APIResponse> {
|
|
134
|
-
const context = await this.getContext()
|
|
135
|
-
const securityParams =
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
const context = await this.getContext()
|
|
132
|
+
const securityParams = this.accessToken
|
|
133
|
+
? { access_token: this.accessToken }
|
|
134
|
+
: ({} as Record<string, never>)
|
|
138
135
|
|
|
139
136
|
return context.get(path, {
|
|
140
137
|
params: { ...securityParams, ...params },
|
|
141
138
|
headers,
|
|
142
|
-
})
|
|
139
|
+
})
|
|
143
140
|
}
|
|
144
141
|
|
|
145
142
|
async getAsJson<T>(
|
|
@@ -147,77 +144,62 @@ export class ContentApiClient extends AuthenticatedApiClient {
|
|
|
147
144
|
params?: SearchQueryParams,
|
|
148
145
|
headers?: Record<string, string>,
|
|
149
146
|
): Promise<T> {
|
|
150
|
-
const response = await this.get(url, params, headers)
|
|
147
|
+
const response = await this.get(url, params, headers)
|
|
151
148
|
|
|
152
|
-
return response.json() as T
|
|
149
|
+
return response.json() as T
|
|
153
150
|
}
|
|
154
151
|
|
|
155
152
|
/** Query the graphql api - https://prismic.io/docs/graphql-technical-reference */
|
|
156
|
-
async graphql(
|
|
157
|
-
ref:
|
|
158
|
-
query: string,
|
|
159
|
-
): Promise<ContentApiGraphQLResponse> {
|
|
160
|
-
return this.getAsJson<ContentApiGraphQLResponse>(
|
|
161
|
-
"graphql",
|
|
162
|
-
{ query },
|
|
163
|
-
{ "Prismic-ref": ref },
|
|
164
|
-
);
|
|
153
|
+
async graphql(ref: string, query: string): Promise<ContentApiGraphQLResponse> {
|
|
154
|
+
return this.getAsJson<ContentApiGraphQLResponse>("graphql", { query }, { "Prismic-ref": ref })
|
|
165
155
|
}
|
|
166
156
|
|
|
167
157
|
async getRefs(): Promise<ContentApiRef[]> {
|
|
168
|
-
const data = await this.getAsJson<ContentApiRepoConfigResponse>(
|
|
169
|
-
`api/${this.version}`,
|
|
170
|
-
);
|
|
158
|
+
const data = await this.getAsJson<ContentApiRepoConfigResponse>(`api/${this.version}`)
|
|
171
159
|
|
|
172
|
-
return data.refs
|
|
160
|
+
return data.refs
|
|
173
161
|
}
|
|
174
162
|
|
|
175
163
|
async getMasterRef(): Promise<string> {
|
|
176
|
-
const refs = await this.getRefs()
|
|
164
|
+
const refs = await this.getRefs()
|
|
177
165
|
|
|
178
|
-
const masterRef = refs.find(({ isMasterRef }) => isMasterRef === true)
|
|
166
|
+
const masterRef = refs.find(({ isMasterRef }) => isMasterRef === true)
|
|
179
167
|
if (!masterRef) {
|
|
180
|
-
throw "No master ref found"
|
|
168
|
+
throw "No master ref found"
|
|
181
169
|
}
|
|
182
170
|
|
|
183
|
-
return masterRef.ref
|
|
171
|
+
return masterRef.ref
|
|
184
172
|
}
|
|
185
173
|
|
|
186
174
|
async getRefByReleaseID(releaseID: string): Promise<string> {
|
|
187
|
-
const refs = await this.getRefs()
|
|
188
|
-
const release = refs.find(({ id }) => id === releaseID)
|
|
175
|
+
const refs = await this.getRefs()
|
|
176
|
+
const release = refs.find(({ id }) => id === releaseID)
|
|
189
177
|
if (!release) {
|
|
190
|
-
throw `No ref found for release ${releaseID}
|
|
178
|
+
throw `No ref found for release ${releaseID}`
|
|
191
179
|
}
|
|
192
180
|
|
|
193
|
-
return release.ref
|
|
181
|
+
return release.ref
|
|
194
182
|
}
|
|
195
183
|
|
|
196
184
|
/** Search documents from the `/api/v<version>/documents/search` endpoint. */
|
|
197
185
|
async search(filters?: SearchQueryParams): Promise<ContentApiSearchResponse> {
|
|
198
|
-
let ref = filters?.ref
|
|
186
|
+
let ref = filters?.ref
|
|
199
187
|
if (!ref) {
|
|
200
|
-
ref = await this.getMasterRef()
|
|
188
|
+
ref = await this.getMasterRef()
|
|
201
189
|
}
|
|
202
190
|
|
|
203
|
-
return this.getAsJson<ContentApiSearchResponse>(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
ref,
|
|
208
|
-
},
|
|
209
|
-
);
|
|
191
|
+
return this.getAsJson<ContentApiSearchResponse>(`api/${this.version}/documents/search`, {
|
|
192
|
+
...filters,
|
|
193
|
+
ref,
|
|
194
|
+
})
|
|
210
195
|
}
|
|
211
196
|
|
|
212
197
|
/**
|
|
213
|
-
* Search for a single document by its it, using the
|
|
214
|
-
*
|
|
198
|
+
* Search for a single document by its it, using the `/api/v<version>/documents/search` endpoint
|
|
199
|
+
* and a default filter.
|
|
215
200
|
*/
|
|
216
|
-
async searchByID(
|
|
217
|
-
|
|
218
|
-
filters?: SearchQueryParams,
|
|
219
|
-
): Promise<ContentApiSearchResponse> {
|
|
220
|
-
return this.search({ ...filters, q: `[[at(document.id, "${id}")]]` });
|
|
201
|
+
async searchByID(id: string, filters?: SearchQueryParams): Promise<ContentApiSearchResponse> {
|
|
202
|
+
return this.search({ ...filters, q: `[[at(document.id, "${id}")]]` })
|
|
221
203
|
}
|
|
222
204
|
|
|
223
205
|
/** Retrieve a single document or undefined if not found. */
|
|
@@ -225,14 +207,14 @@ export class ContentApiClient extends AuthenticatedApiClient {
|
|
|
225
207
|
id: string,
|
|
226
208
|
filters?: SearchQueryParams,
|
|
227
209
|
): Promise<ContentApiDocument | undefined> {
|
|
228
|
-
const data = await this.searchByID(id, filters)
|
|
210
|
+
const data = await this.searchByID(id, filters)
|
|
229
211
|
switch (data.results_size) {
|
|
230
212
|
case 0:
|
|
231
|
-
return
|
|
213
|
+
return
|
|
232
214
|
case 1:
|
|
233
|
-
return data.results[0]
|
|
215
|
+
return data.results[0]
|
|
234
216
|
default:
|
|
235
|
-
throw new Error(`Too many documents returned with the same id ${id}`)
|
|
217
|
+
throw new Error(`Too many documents returned with the same id ${id}`)
|
|
236
218
|
}
|
|
237
219
|
}
|
|
238
220
|
}
|