@prismicio/e2e-tests-utils 1.15.1-alpha.0 → 1.17.0-alpha.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.
|
@@ -71,7 +71,18 @@ class AssetApiClient extends apiClient.AuthenticatedApiClient {
|
|
|
71
71
|
*/
|
|
72
72
|
async search(params) {
|
|
73
73
|
const context = await this.getContext();
|
|
74
|
-
const
|
|
74
|
+
const { ids, ...rest } = params ?? {};
|
|
75
|
+
const query = new URLSearchParams();
|
|
76
|
+
for (const [key, value] of Object.entries(rest)) {
|
|
77
|
+
if (value !== void 0) {
|
|
78
|
+
query.set(key, String(value));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
for (const id of ids ?? []) {
|
|
82
|
+
query.append("ids", id);
|
|
83
|
+
}
|
|
84
|
+
const url = query.size ? `assets?${query}` : "assets";
|
|
85
|
+
const result = await context.get(url);
|
|
75
86
|
if (200 !== result.status()) {
|
|
76
87
|
await log.logPlaywrightApiResponse(result);
|
|
77
88
|
throw new Error("Could not search the asset API.");
|
|
@@ -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 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
|
|
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\tids?: string[];\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\t\tconst { ids, ...rest } = params ?? {};\n\t\tconst query = new URLSearchParams();\n\t\tfor (const [key, value] of Object.entries(rest)) {\n\t\t\tif (value !== undefined) {\n\t\t\t\tquery.set(key, String(value));\n\t\t\t}\n\t\t}\n\t\tfor (const id of ids ?? []) {\n\t\t\tquery.append(\"ids\", id);\n\t\t}\n\t\tconst url = query.size ? `assets?${query}` : \"assets\";\n\n\t\tconst result = await context.get(url);\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":";;;;AA6DM,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;AAC3B,UAAM,EAAE,KAAK,GAAG,SAAS,UAAU,CAAA;AAC7B,UAAA,QAAQ,IAAI;AAClB,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAAI,GAAG;AAChD,UAAI,UAAU,QAAW;AACxB,cAAM,IAAI,KAAK,OAAO,KAAK,CAAC;AAAA,MAC7B;AAAA,IACD;AACW,eAAA,MAAM,OAAO,IAAI;AACrB,YAAA,OAAO,OAAO,EAAE;AAAA,IACvB;AACA,UAAM,MAAM,MAAM,OAAO,UAAU,KAAK,KAAK;AAE7C,UAAM,SAAS,MAAM,QAAQ,IAAI,GAAG;AAEhC,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAMA,IAAAA,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,iCAAiC;AAAA,IAClD;AAEA,WAAO,OAAO;EACf;AACA;;"}
|
package/dist/clients/assetApi.js
CHANGED
|
@@ -69,7 +69,18 @@ class AssetApiClient extends AuthenticatedApiClient {
|
|
|
69
69
|
*/
|
|
70
70
|
async search(params) {
|
|
71
71
|
const context = await this.getContext();
|
|
72
|
-
const
|
|
72
|
+
const { ids, ...rest } = params ?? {};
|
|
73
|
+
const query = new URLSearchParams();
|
|
74
|
+
for (const [key, value] of Object.entries(rest)) {
|
|
75
|
+
if (value !== void 0) {
|
|
76
|
+
query.set(key, String(value));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
for (const id of ids ?? []) {
|
|
80
|
+
query.append("ids", id);
|
|
81
|
+
}
|
|
82
|
+
const url = query.size ? `assets?${query}` : "assets";
|
|
83
|
+
const result = await context.get(url);
|
|
73
84
|
if (200 !== result.status()) {
|
|
74
85
|
await logPlaywrightApiResponse(result);
|
|
75
86
|
throw new Error("Could not search the asset API.");
|
|
@@ -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 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
|
|
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\tids?: string[];\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\t\tconst { ids, ...rest } = params ?? {};\n\t\tconst query = new URLSearchParams();\n\t\tfor (const [key, value] of Object.entries(rest)) {\n\t\t\tif (value !== undefined) {\n\t\t\t\tquery.set(key, String(value));\n\t\t\t}\n\t\t}\n\t\tfor (const id of ids ?? []) {\n\t\t\tquery.append(\"ids\", id);\n\t\t}\n\t\tconst url = query.size ? `assets?${query}` : \"assets\";\n\n\t\tconst result = await context.get(url);\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":";;AA6DM,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;AAC3B,UAAM,EAAE,KAAK,GAAG,SAAS,UAAU,CAAA;AAC7B,UAAA,QAAQ,IAAI;AAClB,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAAI,GAAG;AAChD,UAAI,UAAU,QAAW;AACxB,cAAM,IAAI,KAAK,OAAO,KAAK,CAAC;AAAA,MAC7B;AAAA,IACD;AACW,eAAA,MAAM,OAAO,IAAI;AACrB,YAAA,OAAO,OAAO,EAAE;AAAA,IACvB;AACA,UAAM,MAAM,MAAM,OAAO,UAAU,KAAK,KAAK;AAE7C,UAAM,SAAS,MAAM,QAAQ,IAAI,GAAG;AAEhC,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
|
@@ -32,6 +32,7 @@ export interface AssetApiResponse {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
type AssetApiSearchParams = {
|
|
35
|
+
ids?: string[];
|
|
35
36
|
keyword?: string;
|
|
36
37
|
limit?: number;
|
|
37
38
|
assetType?: string;
|
|
@@ -138,8 +139,19 @@ export class AssetApiClient extends AuthenticatedApiClient {
|
|
|
138
139
|
*/
|
|
139
140
|
async search(params?: AssetApiSearchParams): Promise<AssetApiSearchResponse> {
|
|
140
141
|
const context = await this.getContext();
|
|
142
|
+
const { ids, ...rest } = params ?? {};
|
|
143
|
+
const query = new URLSearchParams();
|
|
144
|
+
for (const [key, value] of Object.entries(rest)) {
|
|
145
|
+
if (value !== undefined) {
|
|
146
|
+
query.set(key, String(value));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
for (const id of ids ?? []) {
|
|
150
|
+
query.append("ids", id);
|
|
151
|
+
}
|
|
152
|
+
const url = query.size ? `assets?${query}` : "assets";
|
|
141
153
|
|
|
142
|
-
const result = await context.get(
|
|
154
|
+
const result = await context.get(url);
|
|
143
155
|
|
|
144
156
|
if (200 !== result.status()) {
|
|
145
157
|
await logPlaywrightApiResponse(result);
|