@prismicio/e2e-tests-utils 1.15.0-alpha.1 → 1.15.1-alpha.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.
|
@@ -43,6 +43,25 @@ class AssetApiClient extends apiClient.AuthenticatedApiClient {
|
|
|
43
43
|
}
|
|
44
44
|
return result.json();
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Patch an existing asset.
|
|
48
|
+
*
|
|
49
|
+
* @param args - Asset id + the payload
|
|
50
|
+
*
|
|
51
|
+
* @returns The API response containing asset information.
|
|
52
|
+
*
|
|
53
|
+
* @throws An error if the upload fails.
|
|
54
|
+
*/
|
|
55
|
+
async patchAsset(args) {
|
|
56
|
+
const context = await this.getContext();
|
|
57
|
+
const { assetId, ...data } = args;
|
|
58
|
+
const result = await context.patch(`assets/${assetId}`, { data });
|
|
59
|
+
if (200 !== result.status()) {
|
|
60
|
+
await log.logPlaywrightApiResponse(result);
|
|
61
|
+
throw new Error("Could not search the asset API.");
|
|
62
|
+
}
|
|
63
|
+
return result.json();
|
|
64
|
+
}
|
|
46
65
|
/**
|
|
47
66
|
* Searches for assets.
|
|
48
67
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetApi.cjs","sources":["../../../src/clients/assetApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\nexport interface AssetApiCreatePayload {\n\tname: string;\n\tmimeType: string;\n\tbuffer: Buffer;\n}\n\nexport
|
|
1
|
+
{"version":3,"file":"assetApi.cjs","sources":["../../../src/clients/assetApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\nexport interface AssetApiCreatePayload {\n\tname: string;\n\tmimeType: string;\n\tbuffer: Buffer;\n}\n\nexport type AssetApiCreateResponse = AssetApiResponse;\nexport interface AssetApiResponse {\n\tid: string;\n\turl: string;\n\tfilename: string;\n\tsize: number;\n\twidth: number;\n\theight: number;\n\tlast_modified: number;\n\tkind: string;\n\textension: string;\n\tcreated_at: number;\n\tuploader_id: string;\n\ttags: string[];\n\tai_metadata?: {\n\t\tis_logo?: boolean;\n\t\tlogo_company_industry?: string;\n\t\tlogo_company_name?: string;\n\t\tdescription?: string;\n\t\tkeywords?: string[];\n\t};\n}\n\ntype AssetApiSearchParams = {\n\tkeyword?: string;\n\tlimit?: number;\n\tassetType?: string;\n\tcursor?: string;\n};\n\ninterface AssetApiSearchResponse {\n\titems: AssetApiResponse[];\n\ttotal: number;\n\tcursor: string;\n\tis_opensearch_result: boolean;\n}\n\ninterface PatchAssetArgs {\n\tassetId: string;\n\tfilename?: string;\n\tnotes?: string;\n\tcredits?: string;\n\talt?: string;\n\ttags?: string[];\n\tai_metadata?: {\n\t\tdescription?: string;\n\t\tkeywords?: string[];\n\t};\n}\n\nexport class AssetApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new AssetApiClient(\"https://asset-api.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \trepository: \"my-repo-name\",\n\t * });\n\t * ```\n\t *\n\t * @param baseURL - The API base URL, such as https://asset-api.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.authToken}: API token generated from the auth service or a\n\t * function to fetch it when it's needed.\n\t * - {@link config.repository}: Repository name.\n\t */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { authToken: AuthServerToken; repository: string },\n\t) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository });\n\t}\n\n\t/**\n\t * Uploads an asset file to the server.\n\t *\n\t * @param data - The payload containing the file and filename.\n\t *\n\t * @returns The API response containing asset information.\n\t *\n\t * @throws An error if the upload fails.\n\t */\n\tasync createAsset(data: AssetApiCreatePayload): Promise<AssetApiResponse> {\n\t\tconst context = await this.getContext();\n\n\t\tconst result = await context.post(\"assets\", {\n\t\t\tmultipart: { file: data },\n\t\t});\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not upload the asset with the asset API.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n\n\t/**\n\t * Patch an existing asset.\n\t *\n\t * @param args - Asset id + the payload\n\t *\n\t * @returns The API response containing asset information.\n\t *\n\t * @throws An error if the upload fails.\n\t */\n\tasync patchAsset(args: PatchAssetArgs): Promise<AssetApiResponse> {\n\t\tconst context = await this.getContext();\n\t\tconst { assetId, ...data } = args;\n\t\tconst result = await context.patch(`assets/${assetId}`, { data });\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not search the asset API.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n\n\t/**\n\t * Searches for assets.\n\t *\n\t * @param params - Optional parameters to refine search results.\n\t *\n\t * @returns The API response containing assets.\n\t */\n\tasync search(params?: AssetApiSearchParams): Promise<AssetApiSearchResponse> {\n\t\tconst context = await this.getContext();\n\n\t\tconst result = await context.get(\"assets\", { params });\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not search the asset API.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n}\n"],"names":["AuthenticatedApiClient","logPlaywrightApiResponse"],"mappings":";;;;AA4DM,MAAO,uBAAuBA,UAAAA,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBzD,YACC,SACA,QAA0D;AAE1D,UAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,YAAY;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,YAAY,MAA2B;AACtC,UAAA,UAAU,MAAM,KAAK;AAE3B,UAAM,SAAS,MAAM,QAAQ,KAAK,UAAU;AAAA,MAC3C,WAAW,EAAE,MAAM,KAAM;AAAA,IAAA,CACzB;AAEG,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAMC,IAAAA,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,gDAAgD;AAAA,IACjE;AAEA,WAAO,OAAO;EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,WAAW,MAAoB;AAC9B,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,EAAE,SAAS,GAAG,KAAA,IAAS;AACvB,UAAA,SAAS,MAAM,QAAQ,MAAM,UAAU,OAAO,IAAI,EAAE,KAAA,CAAM;AAE5D,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAMA,IAAAA,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,iCAAiC;AAAA,IAClD;AAEA,WAAO,OAAO;EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,OAAO,QAA6B;AACnC,UAAA,UAAU,MAAM,KAAK;AAE3B,UAAM,SAAS,MAAM,QAAQ,IAAI,UAAU,EAAE,QAAQ;AAEjD,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAMA,IAAAA,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,iCAAiC;AAAA,IAClD;AAEA,WAAO,OAAO;EACf;AACA;;"}
|
|
@@ -5,7 +5,8 @@ export interface AssetApiCreatePayload {
|
|
|
5
5
|
mimeType: string;
|
|
6
6
|
buffer: Buffer;
|
|
7
7
|
}
|
|
8
|
-
export
|
|
8
|
+
export type AssetApiCreateResponse = AssetApiResponse;
|
|
9
|
+
export interface AssetApiResponse {
|
|
9
10
|
id: string;
|
|
10
11
|
url: string;
|
|
11
12
|
filename: string;
|
|
@@ -18,6 +19,13 @@ export interface AssetApiCreateResponse {
|
|
|
18
19
|
created_at: number;
|
|
19
20
|
uploader_id: string;
|
|
20
21
|
tags: string[];
|
|
22
|
+
ai_metadata?: {
|
|
23
|
+
is_logo?: boolean;
|
|
24
|
+
logo_company_industry?: string;
|
|
25
|
+
logo_company_name?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
keywords?: string[];
|
|
28
|
+
};
|
|
21
29
|
}
|
|
22
30
|
type AssetApiSearchParams = {
|
|
23
31
|
keyword?: string;
|
|
@@ -26,11 +34,23 @@ type AssetApiSearchParams = {
|
|
|
26
34
|
cursor?: string;
|
|
27
35
|
};
|
|
28
36
|
interface AssetApiSearchResponse {
|
|
29
|
-
items:
|
|
37
|
+
items: AssetApiResponse[];
|
|
30
38
|
total: number;
|
|
31
39
|
cursor: string;
|
|
32
40
|
is_opensearch_result: boolean;
|
|
33
41
|
}
|
|
42
|
+
interface PatchAssetArgs {
|
|
43
|
+
assetId: string;
|
|
44
|
+
filename?: string;
|
|
45
|
+
notes?: string;
|
|
46
|
+
credits?: string;
|
|
47
|
+
alt?: string;
|
|
48
|
+
tags?: string[];
|
|
49
|
+
ai_metadata?: {
|
|
50
|
+
description?: string;
|
|
51
|
+
keywords?: string[];
|
|
52
|
+
};
|
|
53
|
+
}
|
|
34
54
|
export declare class AssetApiClient extends AuthenticatedApiClient {
|
|
35
55
|
/**
|
|
36
56
|
* @example To instantiate the class:
|
|
@@ -62,7 +82,17 @@ export declare class AssetApiClient extends AuthenticatedApiClient {
|
|
|
62
82
|
*
|
|
63
83
|
* @throws An error if the upload fails.
|
|
64
84
|
*/
|
|
65
|
-
createAsset(data: AssetApiCreatePayload): Promise<
|
|
85
|
+
createAsset(data: AssetApiCreatePayload): Promise<AssetApiResponse>;
|
|
86
|
+
/**
|
|
87
|
+
* Patch an existing asset.
|
|
88
|
+
*
|
|
89
|
+
* @param args - Asset id + the payload
|
|
90
|
+
*
|
|
91
|
+
* @returns The API response containing asset information.
|
|
92
|
+
*
|
|
93
|
+
* @throws An error if the upload fails.
|
|
94
|
+
*/
|
|
95
|
+
patchAsset(args: PatchAssetArgs): Promise<AssetApiResponse>;
|
|
66
96
|
/**
|
|
67
97
|
* Searches for assets.
|
|
68
98
|
*
|
package/dist/clients/assetApi.js
CHANGED
|
@@ -41,6 +41,25 @@ class AssetApiClient extends AuthenticatedApiClient {
|
|
|
41
41
|
}
|
|
42
42
|
return result.json();
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Patch an existing asset.
|
|
46
|
+
*
|
|
47
|
+
* @param args - Asset id + the payload
|
|
48
|
+
*
|
|
49
|
+
* @returns The API response containing asset information.
|
|
50
|
+
*
|
|
51
|
+
* @throws An error if the upload fails.
|
|
52
|
+
*/
|
|
53
|
+
async patchAsset(args) {
|
|
54
|
+
const context = await this.getContext();
|
|
55
|
+
const { assetId, ...data } = args;
|
|
56
|
+
const result = await context.patch(`assets/${assetId}`, { data });
|
|
57
|
+
if (200 !== result.status()) {
|
|
58
|
+
await logPlaywrightApiResponse(result);
|
|
59
|
+
throw new Error("Could not search the asset API.");
|
|
60
|
+
}
|
|
61
|
+
return result.json();
|
|
62
|
+
}
|
|
44
63
|
/**
|
|
45
64
|
* Searches for assets.
|
|
46
65
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetApi.js","sources":["../../../src/clients/assetApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\nexport interface AssetApiCreatePayload {\n\tname: string;\n\tmimeType: string;\n\tbuffer: Buffer;\n}\n\nexport
|
|
1
|
+
{"version":3,"file":"assetApi.js","sources":["../../../src/clients/assetApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\nexport interface AssetApiCreatePayload {\n\tname: string;\n\tmimeType: string;\n\tbuffer: Buffer;\n}\n\nexport type AssetApiCreateResponse = AssetApiResponse;\nexport interface AssetApiResponse {\n\tid: string;\n\turl: string;\n\tfilename: string;\n\tsize: number;\n\twidth: number;\n\theight: number;\n\tlast_modified: number;\n\tkind: string;\n\textension: string;\n\tcreated_at: number;\n\tuploader_id: string;\n\ttags: string[];\n\tai_metadata?: {\n\t\tis_logo?: boolean;\n\t\tlogo_company_industry?: string;\n\t\tlogo_company_name?: string;\n\t\tdescription?: string;\n\t\tkeywords?: string[];\n\t};\n}\n\ntype AssetApiSearchParams = {\n\tkeyword?: string;\n\tlimit?: number;\n\tassetType?: string;\n\tcursor?: string;\n};\n\ninterface AssetApiSearchResponse {\n\titems: AssetApiResponse[];\n\ttotal: number;\n\tcursor: string;\n\tis_opensearch_result: boolean;\n}\n\ninterface PatchAssetArgs {\n\tassetId: string;\n\tfilename?: string;\n\tnotes?: string;\n\tcredits?: string;\n\talt?: string;\n\ttags?: string[];\n\tai_metadata?: {\n\t\tdescription?: string;\n\t\tkeywords?: string[];\n\t};\n}\n\nexport class AssetApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new AssetApiClient(\"https://asset-api.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \trepository: \"my-repo-name\",\n\t * });\n\t * ```\n\t *\n\t * @param baseURL - The API base URL, such as https://asset-api.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.authToken}: API token generated from the auth service or a\n\t * function to fetch it when it's needed.\n\t * - {@link config.repository}: Repository name.\n\t */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { authToken: AuthServerToken; repository: string },\n\t) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository });\n\t}\n\n\t/**\n\t * Uploads an asset file to the server.\n\t *\n\t * @param data - The payload containing the file and filename.\n\t *\n\t * @returns The API response containing asset information.\n\t *\n\t * @throws An error if the upload fails.\n\t */\n\tasync createAsset(data: AssetApiCreatePayload): Promise<AssetApiResponse> {\n\t\tconst context = await this.getContext();\n\n\t\tconst result = await context.post(\"assets\", {\n\t\t\tmultipart: { file: data },\n\t\t});\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not upload the asset with the asset API.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n\n\t/**\n\t * Patch an existing asset.\n\t *\n\t * @param args - Asset id + the payload\n\t *\n\t * @returns The API response containing asset information.\n\t *\n\t * @throws An error if the upload fails.\n\t */\n\tasync patchAsset(args: PatchAssetArgs): Promise<AssetApiResponse> {\n\t\tconst context = await this.getContext();\n\t\tconst { assetId, ...data } = args;\n\t\tconst result = await context.patch(`assets/${assetId}`, { data });\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not search the asset API.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n\n\t/**\n\t * Searches for assets.\n\t *\n\t * @param params - Optional parameters to refine search results.\n\t *\n\t * @returns The API response containing assets.\n\t */\n\tasync search(params?: AssetApiSearchParams): Promise<AssetApiSearchResponse> {\n\t\tconst context = await this.getContext();\n\n\t\tconst result = await context.get(\"assets\", { params });\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not search the asset API.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n}\n"],"names":[],"mappings":";;AA4DM,MAAO,uBAAuB,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBzD,YACC,SACA,QAA0D;AAE1D,UAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,YAAY;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,YAAY,MAA2B;AACtC,UAAA,UAAU,MAAM,KAAK;AAE3B,UAAM,SAAS,MAAM,QAAQ,KAAK,UAAU;AAAA,MAC3C,WAAW,EAAE,MAAM,KAAM;AAAA,IAAA,CACzB;AAEG,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAM,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,gDAAgD;AAAA,IACjE;AAEA,WAAO,OAAO;EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,WAAW,MAAoB;AAC9B,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,EAAE,SAAS,GAAG,KAAA,IAAS;AACvB,UAAA,SAAS,MAAM,QAAQ,MAAM,UAAU,OAAO,IAAI,EAAE,KAAA,CAAM;AAE5D,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAM,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,iCAAiC;AAAA,IAClD;AAEA,WAAO,OAAO;EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,OAAO,QAA6B;AACnC,UAAA,UAAU,MAAM,KAAK;AAE3B,UAAM,SAAS,MAAM,QAAQ,IAAI,UAAU,EAAE,QAAQ;AAEjD,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAM,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,iCAAiC;AAAA,IAClD;AAEA,WAAO,OAAO;EACf;AACA;"}
|
package/package.json
CHANGED
package/src/clients/assetApi.ts
CHANGED
|
@@ -8,7 +8,8 @@ export interface AssetApiCreatePayload {
|
|
|
8
8
|
buffer: Buffer;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export type AssetApiCreateResponse = AssetApiResponse;
|
|
12
|
+
export interface AssetApiResponse {
|
|
12
13
|
id: string;
|
|
13
14
|
url: string;
|
|
14
15
|
filename: string;
|
|
@@ -21,6 +22,13 @@ export interface AssetApiCreateResponse {
|
|
|
21
22
|
created_at: number;
|
|
22
23
|
uploader_id: string;
|
|
23
24
|
tags: string[];
|
|
25
|
+
ai_metadata?: {
|
|
26
|
+
is_logo?: boolean;
|
|
27
|
+
logo_company_industry?: string;
|
|
28
|
+
logo_company_name?: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
keywords?: string[];
|
|
31
|
+
};
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
type AssetApiSearchParams = {
|
|
@@ -31,12 +39,25 @@ type AssetApiSearchParams = {
|
|
|
31
39
|
};
|
|
32
40
|
|
|
33
41
|
interface AssetApiSearchResponse {
|
|
34
|
-
items:
|
|
42
|
+
items: AssetApiResponse[];
|
|
35
43
|
total: number;
|
|
36
44
|
cursor: string;
|
|
37
45
|
is_opensearch_result: boolean;
|
|
38
46
|
}
|
|
39
47
|
|
|
48
|
+
interface PatchAssetArgs {
|
|
49
|
+
assetId: string;
|
|
50
|
+
filename?: string;
|
|
51
|
+
notes?: string;
|
|
52
|
+
credits?: string;
|
|
53
|
+
alt?: string;
|
|
54
|
+
tags?: string[];
|
|
55
|
+
ai_metadata?: {
|
|
56
|
+
description?: string;
|
|
57
|
+
keywords?: string[];
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
40
61
|
export class AssetApiClient extends AuthenticatedApiClient {
|
|
41
62
|
/**
|
|
42
63
|
* @example To instantiate the class:
|
|
@@ -71,9 +92,7 @@ export class AssetApiClient extends AuthenticatedApiClient {
|
|
|
71
92
|
*
|
|
72
93
|
* @throws An error if the upload fails.
|
|
73
94
|
*/
|
|
74
|
-
async createAsset(
|
|
75
|
-
data: AssetApiCreatePayload,
|
|
76
|
-
): Promise<AssetApiCreateResponse> {
|
|
95
|
+
async createAsset(data: AssetApiCreatePayload): Promise<AssetApiResponse> {
|
|
77
96
|
const context = await this.getContext();
|
|
78
97
|
|
|
79
98
|
const result = await context.post("assets", {
|
|
@@ -88,6 +107,28 @@ export class AssetApiClient extends AuthenticatedApiClient {
|
|
|
88
107
|
return result.json();
|
|
89
108
|
}
|
|
90
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Patch an existing asset.
|
|
112
|
+
*
|
|
113
|
+
* @param args - Asset id + the payload
|
|
114
|
+
*
|
|
115
|
+
* @returns The API response containing asset information.
|
|
116
|
+
*
|
|
117
|
+
* @throws An error if the upload fails.
|
|
118
|
+
*/
|
|
119
|
+
async patchAsset(args: PatchAssetArgs): Promise<AssetApiResponse> {
|
|
120
|
+
const context = await this.getContext();
|
|
121
|
+
const { assetId, ...data } = args;
|
|
122
|
+
const result = await context.patch(`assets/${assetId}`, { data });
|
|
123
|
+
|
|
124
|
+
if (200 !== result.status()) {
|
|
125
|
+
await logPlaywrightApiResponse(result);
|
|
126
|
+
throw new Error("Could not search the asset API.");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return result.json();
|
|
130
|
+
}
|
|
131
|
+
|
|
91
132
|
/**
|
|
92
133
|
* Searches for assets.
|
|
93
134
|
*
|