@prismicio/e2e-tests-utils 1.17.1-alpha.0 → 1.18.0-canary.7615426
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 +123 -145
- package/dist/clients/coreApi.cjs.map +1 -1
- package/dist/clients/coreApi.d.cts +122 -0
- package/dist/clients/coreApi.d.cts.map +1 -0
- package/dist/clients/coreApi.d.ts +111 -109
- package/dist/clients/coreApi.d.ts.map +1 -0
- package/dist/clients/coreApi.js +122 -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 +529 -616
- package/dist/managers/repository.cjs.map +1 -1
- package/dist/managers/repository.d.cts +308 -0
- package/dist/managers/repository.d.cts.map +1 -0
- package/dist/managers/repository.d.ts +303 -307
- package/dist/managers/repository.d.ts.map +1 -0
- package/dist/managers/repository.js +529 -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 +109 -129
- package/src/clients/coreApi.ts +113 -117
- package/src/clients/customTypesApi.ts +54 -76
- 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 +303 -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetApi.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"assetApi.cjs","names":["AuthenticatedApiClient","logPlaywrightApiResponse"],"sources":["../../src/clients/assetApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\"\nimport type { AuthServerToken } from \"./apiClient\"\nimport { 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\n\t * \tTo instantiate the class:\n\t *\n\t * \t```js\n\t * \tnew AssetApiClient(\"https://asset-api.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \trepository: \"my-repo-name\",\n\t * \t});\n\t * \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 function to fetch it\n\t * when it's needed.\n\t * - {@link config.repository}: Repository name.\n\t */\n\tconstructor(baseURL: string, config: { authToken: AuthServerToken; repository: string }) {\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 * @returns The API response containing asset information.\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 * @returns The API response containing asset information.\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 * @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"],"mappings":";;;AA6DA,IAAa,iBAAb,cAAoCA,kBAAAA,uBAAuB;;;;;;;;;;;;;;;;;;;CAmB1D,YAAY,SAAiB,QAA4D;EACxF,MAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,WAAW,CAAC;CACnE;;;;;;;;CASA,MAAM,YAAY,MAAwD;EAGzE,MAAM,SAAS,OAAM,MAFC,KAAK,WAAW,EAAA,CAET,KAAK,UAAU,EAC3C,WAAW,EAAE,MAAM,KAAK,EACzB,CAAC;EAED,IAAI,QAAQ,OAAO,OAAO,GAAG;GAC5B,MAAMC,YAAAA,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,gDAAgD;EACjE;EAEA,OAAO,OAAO,KAAK;CACpB;;;;;;;;CASA,MAAM,WAAW,MAAiD;EACjE,MAAM,UAAU,MAAM,KAAK,WAAW;EACtC,MAAM,EAAE,SAAS,GAAG,SAAS;EAC7B,MAAM,SAAS,MAAM,QAAQ,MAAM,UAAU,WAAW,EAAE,KAAK,CAAC;EAEhE,IAAI,QAAQ,OAAO,OAAO,GAAG;GAC5B,MAAMA,YAAAA,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,iCAAiC;EAClD;EAEA,OAAO,OAAO,KAAK;CACpB;;;;;;;CAQA,MAAM,OAAO,QAAgE;EAC5E,MAAM,UAAU,MAAM,KAAK,WAAW;EACtC,MAAM,EAAE,KAAK,GAAG,SAAS,UAAU,CAAC;EACpC,MAAM,QAAQ,IAAI,gBAAgB;EAClC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,GAC7C,IAAI,UAAU,KAAA,GACb,MAAM,IAAI,KAAK,OAAO,KAAK,CAAC;EAG9B,KAAK,MAAM,MAAM,OAAO,CAAC,GACxB,MAAM,OAAO,OAAO,EAAE;EAEvB,MAAM,MAAM,MAAM,OAAO,UAAU,UAAU;EAE7C,MAAM,SAAS,MAAM,QAAQ,IAAI,GAAG;EAEpC,IAAI,QAAQ,OAAO,OAAO,GAAG;GAC5B,MAAMA,YAAAA,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,iCAAiC;EAClD;EAEA,OAAO,OAAO,KAAK;CACpB;AACD"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { AuthServerToken, AuthenticatedApiClient } from "./apiClient.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/clients/assetApi.d.ts
|
|
4
|
+
interface AssetApiCreatePayload {
|
|
5
|
+
name: string;
|
|
6
|
+
mimeType: string;
|
|
7
|
+
buffer: Buffer;
|
|
8
|
+
}
|
|
9
|
+
type AssetApiCreateResponse = AssetApiResponse;
|
|
10
|
+
interface AssetApiResponse {
|
|
11
|
+
id: string;
|
|
12
|
+
url: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
size: number;
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
last_modified: number;
|
|
18
|
+
kind: string;
|
|
19
|
+
extension: string;
|
|
20
|
+
created_at: number;
|
|
21
|
+
uploader_id: string;
|
|
22
|
+
tags: string[];
|
|
23
|
+
ai_metadata?: {
|
|
24
|
+
is_logo?: boolean;
|
|
25
|
+
logo_company_industry?: string;
|
|
26
|
+
logo_company_name?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
keywords?: string[];
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
type AssetApiSearchParams = {
|
|
32
|
+
ids?: string[];
|
|
33
|
+
keyword?: string;
|
|
34
|
+
limit?: number;
|
|
35
|
+
assetType?: string;
|
|
36
|
+
cursor?: string;
|
|
37
|
+
};
|
|
38
|
+
interface AssetApiSearchResponse {
|
|
39
|
+
items: AssetApiResponse[];
|
|
40
|
+
total: number;
|
|
41
|
+
cursor: string;
|
|
42
|
+
is_opensearch_result: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface PatchAssetArgs {
|
|
45
|
+
assetId: string;
|
|
46
|
+
filename?: string;
|
|
47
|
+
notes?: string;
|
|
48
|
+
credits?: string;
|
|
49
|
+
alt?: string;
|
|
50
|
+
tags?: string[];
|
|
51
|
+
ai_metadata?: {
|
|
52
|
+
description?: string;
|
|
53
|
+
keywords?: string[];
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
declare class AssetApiClient extends AuthenticatedApiClient {
|
|
57
|
+
/**
|
|
58
|
+
* @example
|
|
59
|
+
* To instantiate the class:
|
|
60
|
+
*
|
|
61
|
+
* ```js
|
|
62
|
+
* new AssetApiClient("https://asset-api.prismic.io", {
|
|
63
|
+
* authToken: "my-secret-token",
|
|
64
|
+
* repository: "my-repo-name",
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @param baseURL - The API base URL, such as https://asset-api.prismic.io
|
|
69
|
+
* @param config - Optional configuration
|
|
70
|
+
*
|
|
71
|
+
* - {@link config.authToken}: API token generated from the auth service or a function to fetch it
|
|
72
|
+
* when it's needed.
|
|
73
|
+
* - {@link config.repository}: Repository name.
|
|
74
|
+
*/
|
|
75
|
+
constructor(baseURL: string, config: {
|
|
76
|
+
authToken: AuthServerToken;
|
|
77
|
+
repository: string;
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* Uploads an asset file to the server.
|
|
81
|
+
*
|
|
82
|
+
* @param data - The payload containing the file and filename.
|
|
83
|
+
* @returns The API response containing asset information.
|
|
84
|
+
* @throws An error if the upload fails.
|
|
85
|
+
*/
|
|
86
|
+
createAsset(data: AssetApiCreatePayload): Promise<AssetApiResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* Patch an existing asset.
|
|
89
|
+
*
|
|
90
|
+
* @param args - Asset id + the payload
|
|
91
|
+
* @returns The API response containing asset information.
|
|
92
|
+
* @throws An error if the upload fails.
|
|
93
|
+
*/
|
|
94
|
+
patchAsset(args: PatchAssetArgs): Promise<AssetApiResponse>;
|
|
95
|
+
/**
|
|
96
|
+
* Searches for assets.
|
|
97
|
+
*
|
|
98
|
+
* @param params - Optional parameters to refine search results.
|
|
99
|
+
* @returns The API response containing assets.
|
|
100
|
+
*/
|
|
101
|
+
search(params?: AssetApiSearchParams): Promise<AssetApiSearchResponse>;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { AssetApiClient, AssetApiCreatePayload, AssetApiCreateResponse, AssetApiResponse };
|
|
105
|
+
//# sourceMappingURL=assetApi.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assetApi.d.cts","names":[],"sources":["../../src/clients/assetApi.ts"],"mappings":";;;UAIiB,qBAAA;EAChB,IAAA;EACA,QAAA;EACA,MAAA,EAAQ,MAAM;AAAA;AAAA,KAGH,sBAAA,GAAyB,gBAAgB;AAAA,UACpC,gBAAA;EAChB,EAAA;EACA,GAAA;EACA,QAAA;EACA,IAAA;EACA,KAAA;EACA,MAAA;EACA,aAAA;EACA,IAAA;EACA,SAAA;EACA,UAAA;EACA,WAAA;EACA,IAAA;EACA,WAAA;IACC,OAAA;IACA,qBAAA;IACA,iBAAA;IACA,WAAA;IACA,QAAA;EAAA;AAAA;AAAA,KAIG,oBAAA;EACJ,GAAA;EACA,OAAA;EACA,KAAA;EACA,SAAA;EACA,MAAA;AAAA;AAAA,UAGS,sBAAA;EACT,KAAA,EAAO,gBAAgB;EACvB,KAAA;EACA,MAAA;EACA,oBAAA;AAAA;AAAA,UAGS,cAAA;EACT,OAAA;EACA,QAAA;EACA,KAAA;EACA,OAAA;EACA,GAAA;EACA,IAAA;EACA,WAAA;IACC,WAAA;IACA,QAAA;EAAA;AAAA;AAAA,cAIW,cAAA,SAAuB,sBAAA;;;;;;;;;AAhBf;AAAA;;;;;;;;;cAmCR,OAAA,UAAiB,MAAA;IAAU,SAAA,EAAW,eAAA;IAAiB,UAAA;EAAA;EAvB1D;AAAA;AAIV;;;;;EA8BO,WAAA,CAAY,IAAA,EAAM,qBAAA,GAAwB,OAAA,CAAQ,gBAAA;EAAR;;;;;;;EAsB1C,UAAA,CAAW,IAAA,EAAM,cAAA,GAAiB,OAAA,CAAQ,gBAAA;EApDS;;;;;;EAuEnD,MAAA,CAAO,MAAA,GAAS,oBAAA,GAAuB,OAAA,CAAQ,sBAAA;AAAA"}
|
|
@@ -1,106 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { AuthServerToken, AuthenticatedApiClient } from "./apiClient.js";
|
|
2
|
+
|
|
3
|
+
//#region src/clients/assetApi.d.ts
|
|
4
|
+
interface AssetApiCreatePayload {
|
|
5
|
+
name: string;
|
|
6
|
+
mimeType: string;
|
|
7
|
+
buffer: Buffer;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
type AssetApiCreateResponse = AssetApiResponse;
|
|
10
|
+
interface AssetApiResponse {
|
|
11
|
+
id: string;
|
|
12
|
+
url: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
size: number;
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
last_modified: number;
|
|
18
|
+
kind: string;
|
|
19
|
+
extension: string;
|
|
20
|
+
created_at: number;
|
|
21
|
+
uploader_id: string;
|
|
22
|
+
tags: string[];
|
|
23
|
+
ai_metadata?: {
|
|
24
|
+
is_logo?: boolean;
|
|
25
|
+
logo_company_industry?: string;
|
|
26
|
+
logo_company_name?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
keywords?: string[];
|
|
29
|
+
};
|
|
29
30
|
}
|
|
30
31
|
type AssetApiSearchParams = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
ids?: string[];
|
|
33
|
+
keyword?: string;
|
|
34
|
+
limit?: number;
|
|
35
|
+
assetType?: string;
|
|
36
|
+
cursor?: string;
|
|
36
37
|
};
|
|
37
38
|
interface AssetApiSearchResponse {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
items: AssetApiResponse[];
|
|
40
|
+
total: number;
|
|
41
|
+
cursor: string;
|
|
42
|
+
is_opensearch_result: boolean;
|
|
42
43
|
}
|
|
43
44
|
interface PatchAssetArgs {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
assetId: string;
|
|
46
|
+
filename?: string;
|
|
47
|
+
notes?: string;
|
|
48
|
+
credits?: string;
|
|
49
|
+
alt?: string;
|
|
50
|
+
tags?: string[];
|
|
51
|
+
ai_metadata?: {
|
|
52
|
+
description?: string;
|
|
53
|
+
keywords?: string[];
|
|
54
|
+
};
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
*
|
|
102
|
-
* @returns The API response containing assets.
|
|
103
|
-
*/
|
|
104
|
-
search(params?: AssetApiSearchParams): Promise<AssetApiSearchResponse>;
|
|
56
|
+
declare class AssetApiClient extends AuthenticatedApiClient {
|
|
57
|
+
/**
|
|
58
|
+
* @example
|
|
59
|
+
* To instantiate the class:
|
|
60
|
+
*
|
|
61
|
+
* ```js
|
|
62
|
+
* new AssetApiClient("https://asset-api.prismic.io", {
|
|
63
|
+
* authToken: "my-secret-token",
|
|
64
|
+
* repository: "my-repo-name",
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @param baseURL - The API base URL, such as https://asset-api.prismic.io
|
|
69
|
+
* @param config - Optional configuration
|
|
70
|
+
*
|
|
71
|
+
* - {@link config.authToken}: API token generated from the auth service or a function to fetch it
|
|
72
|
+
* when it's needed.
|
|
73
|
+
* - {@link config.repository}: Repository name.
|
|
74
|
+
*/
|
|
75
|
+
constructor(baseURL: string, config: {
|
|
76
|
+
authToken: AuthServerToken;
|
|
77
|
+
repository: string;
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* Uploads an asset file to the server.
|
|
81
|
+
*
|
|
82
|
+
* @param data - The payload containing the file and filename.
|
|
83
|
+
* @returns The API response containing asset information.
|
|
84
|
+
* @throws An error if the upload fails.
|
|
85
|
+
*/
|
|
86
|
+
createAsset(data: AssetApiCreatePayload): Promise<AssetApiResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* Patch an existing asset.
|
|
89
|
+
*
|
|
90
|
+
* @param args - Asset id + the payload
|
|
91
|
+
* @returns The API response containing asset information.
|
|
92
|
+
* @throws An error if the upload fails.
|
|
93
|
+
*/
|
|
94
|
+
patchAsset(args: PatchAssetArgs): Promise<AssetApiResponse>;
|
|
95
|
+
/**
|
|
96
|
+
* Searches for assets.
|
|
97
|
+
*
|
|
98
|
+
* @param params - Optional parameters to refine search results.
|
|
99
|
+
* @returns The API response containing assets.
|
|
100
|
+
*/
|
|
101
|
+
search(params?: AssetApiSearchParams): Promise<AssetApiSearchResponse>;
|
|
105
102
|
}
|
|
106
|
-
|
|
103
|
+
//#endregion
|
|
104
|
+
export { AssetApiClient, AssetApiCreatePayload, AssetApiCreateResponse, AssetApiResponse };
|
|
105
|
+
//# sourceMappingURL=assetApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assetApi.d.ts","names":[],"sources":["../../src/clients/assetApi.ts"],"mappings":";;;UAIiB,qBAAA;EAChB,IAAA;EACA,QAAA;EACA,MAAA,EAAQ,MAAM;AAAA;AAAA,KAGH,sBAAA,GAAyB,gBAAgB;AAAA,UACpC,gBAAA;EAChB,EAAA;EACA,GAAA;EACA,QAAA;EACA,IAAA;EACA,KAAA;EACA,MAAA;EACA,aAAA;EACA,IAAA;EACA,SAAA;EACA,UAAA;EACA,WAAA;EACA,IAAA;EACA,WAAA;IACC,OAAA;IACA,qBAAA;IACA,iBAAA;IACA,WAAA;IACA,QAAA;EAAA;AAAA;AAAA,KAIG,oBAAA;EACJ,GAAA;EACA,OAAA;EACA,KAAA;EACA,SAAA;EACA,MAAA;AAAA;AAAA,UAGS,sBAAA;EACT,KAAA,EAAO,gBAAgB;EACvB,KAAA;EACA,MAAA;EACA,oBAAA;AAAA;AAAA,UAGS,cAAA;EACT,OAAA;EACA,QAAA;EACA,KAAA;EACA,OAAA;EACA,GAAA;EACA,IAAA;EACA,WAAA;IACC,WAAA;IACA,QAAA;EAAA;AAAA;AAAA,cAIW,cAAA,SAAuB,sBAAA;;;;;;;;;AAhBf;AAAA;;;;;;;;;cAmCR,OAAA,UAAiB,MAAA;IAAU,SAAA,EAAW,eAAA;IAAiB,UAAA;EAAA;EAvB1D;AAAA;AAIV;;;;;EA8BO,WAAA,CAAY,IAAA,EAAM,qBAAA,GAAwB,OAAA,CAAQ,gBAAA;EAAR;;;;;;;EAsB1C,UAAA,CAAW,IAAA,EAAM,cAAA,GAAiB,OAAA,CAAQ,gBAAA;EApDS;;;;;;EAuEnD,MAAA,CAAO,MAAA,GAAS,oBAAA,GAAuB,OAAA,CAAQ,sBAAA;AAAA"}
|
package/dist/clients/assetApi.js
CHANGED
|
@@ -1,94 +1,82 @@
|
|
|
1
1
|
import { logPlaywrightApiResponse } from "../utils/log.js";
|
|
2
2
|
import { AuthenticatedApiClient } from "./apiClient.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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);
|
|
84
|
-
if (200 !== result.status()) {
|
|
85
|
-
await logPlaywrightApiResponse(result);
|
|
86
|
-
throw new Error("Could not search the asset API.");
|
|
87
|
-
}
|
|
88
|
-
return result.json();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
export {
|
|
92
|
-
AssetApiClient
|
|
3
|
+
//#region src/clients/assetApi.ts
|
|
4
|
+
var AssetApiClient = class extends AuthenticatedApiClient {
|
|
5
|
+
/**
|
|
6
|
+
* @example
|
|
7
|
+
* To instantiate the class:
|
|
8
|
+
*
|
|
9
|
+
* ```js
|
|
10
|
+
* new AssetApiClient("https://asset-api.prismic.io", {
|
|
11
|
+
* authToken: "my-secret-token",
|
|
12
|
+
* repository: "my-repo-name",
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param baseURL - The API base URL, such as https://asset-api.prismic.io
|
|
17
|
+
* @param config - Optional configuration
|
|
18
|
+
*
|
|
19
|
+
* - {@link config.authToken}: API token generated from the auth service or a function to fetch it
|
|
20
|
+
* when it's needed.
|
|
21
|
+
* - {@link config.repository}: Repository name.
|
|
22
|
+
*/
|
|
23
|
+
constructor(baseURL, config) {
|
|
24
|
+
super(baseURL, config.authToken, { repository: config.repository });
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Uploads an asset file to the server.
|
|
28
|
+
*
|
|
29
|
+
* @param data - The payload containing the file and filename.
|
|
30
|
+
* @returns The API response containing asset information.
|
|
31
|
+
* @throws An error if the upload fails.
|
|
32
|
+
*/
|
|
33
|
+
async createAsset(data) {
|
|
34
|
+
const result = await (await this.getContext()).post("assets", { multipart: { file: data } });
|
|
35
|
+
if (200 !== result.status()) {
|
|
36
|
+
await logPlaywrightApiResponse(result);
|
|
37
|
+
throw new Error("Could not upload the asset with the asset API.");
|
|
38
|
+
}
|
|
39
|
+
return result.json();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Patch an existing asset.
|
|
43
|
+
*
|
|
44
|
+
* @param args - Asset id + the payload
|
|
45
|
+
* @returns The API response containing asset information.
|
|
46
|
+
* @throws An error if the upload fails.
|
|
47
|
+
*/
|
|
48
|
+
async patchAsset(args) {
|
|
49
|
+
const context = await this.getContext();
|
|
50
|
+
const { assetId, ...data } = args;
|
|
51
|
+
const result = await context.patch(`assets/${assetId}`, { data });
|
|
52
|
+
if (200 !== result.status()) {
|
|
53
|
+
await logPlaywrightApiResponse(result);
|
|
54
|
+
throw new Error("Could not search the asset API.");
|
|
55
|
+
}
|
|
56
|
+
return result.json();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Searches for assets.
|
|
60
|
+
*
|
|
61
|
+
* @param params - Optional parameters to refine search results.
|
|
62
|
+
* @returns The API response containing assets.
|
|
63
|
+
*/
|
|
64
|
+
async search(params) {
|
|
65
|
+
const context = await this.getContext();
|
|
66
|
+
const { ids, ...rest } = params ?? {};
|
|
67
|
+
const query = new URLSearchParams();
|
|
68
|
+
for (const [key, value] of Object.entries(rest)) if (value !== void 0) query.set(key, String(value));
|
|
69
|
+
for (const id of ids ?? []) query.append("ids", id);
|
|
70
|
+
const url = query.size ? `assets?${query}` : "assets";
|
|
71
|
+
const result = await context.get(url);
|
|
72
|
+
if (200 !== result.status()) {
|
|
73
|
+
await logPlaywrightApiResponse(result);
|
|
74
|
+
throw new Error("Could not search the asset API.");
|
|
75
|
+
}
|
|
76
|
+
return result.json();
|
|
77
|
+
}
|
|
93
78
|
};
|
|
94
|
-
//#
|
|
79
|
+
//#endregion
|
|
80
|
+
export { AssetApiClient };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=assetApi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetApi.js","sources":["
|
|
1
|
+
{"version":3,"file":"assetApi.js","names":[],"sources":["../../src/clients/assetApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\"\nimport type { AuthServerToken } from \"./apiClient\"\nimport { 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\n\t * \tTo instantiate the class:\n\t *\n\t * \t```js\n\t * \tnew AssetApiClient(\"https://asset-api.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \trepository: \"my-repo-name\",\n\t * \t});\n\t * \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 function to fetch it\n\t * when it's needed.\n\t * - {@link config.repository}: Repository name.\n\t */\n\tconstructor(baseURL: string, config: { authToken: AuthServerToken; repository: string }) {\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 * @returns The API response containing asset information.\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 * @returns The API response containing asset information.\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 * @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"],"mappings":";;;AA6DA,IAAa,iBAAb,cAAoC,uBAAuB;;;;;;;;;;;;;;;;;;;CAmB1D,YAAY,SAAiB,QAA4D;EACxF,MAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,WAAW,CAAC;CACnE;;;;;;;;CASA,MAAM,YAAY,MAAwD;EAGzE,MAAM,SAAS,OAAM,MAFC,KAAK,WAAW,EAAA,CAET,KAAK,UAAU,EAC3C,WAAW,EAAE,MAAM,KAAK,EACzB,CAAC;EAED,IAAI,QAAQ,OAAO,OAAO,GAAG;GAC5B,MAAM,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,gDAAgD;EACjE;EAEA,OAAO,OAAO,KAAK;CACpB;;;;;;;;CASA,MAAM,WAAW,MAAiD;EACjE,MAAM,UAAU,MAAM,KAAK,WAAW;EACtC,MAAM,EAAE,SAAS,GAAG,SAAS;EAC7B,MAAM,SAAS,MAAM,QAAQ,MAAM,UAAU,WAAW,EAAE,KAAK,CAAC;EAEhE,IAAI,QAAQ,OAAO,OAAO,GAAG;GAC5B,MAAM,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,iCAAiC;EAClD;EAEA,OAAO,OAAO,KAAK;CACpB;;;;;;;CAQA,MAAM,OAAO,QAAgE;EAC5E,MAAM,UAAU,MAAM,KAAK,WAAW;EACtC,MAAM,EAAE,KAAK,GAAG,SAAS,UAAU,CAAC;EACpC,MAAM,QAAQ,IAAI,gBAAgB;EAClC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,GAC7C,IAAI,UAAU,KAAA,GACb,MAAM,IAAI,KAAK,OAAO,KAAK,CAAC;EAG9B,KAAK,MAAM,MAAM,OAAO,CAAC,GACxB,MAAM,OAAO,OAAO,EAAE;EAEvB,MAAM,MAAM,MAAM,OAAO,UAAU,UAAU;EAE7C,MAAM,SAAS,MAAM,QAAQ,IAAI,GAAG;EAEpC,IAAI,QAAQ,OAAO,OAAO,GAAG;GAC5B,MAAM,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,iCAAiC;EAClD;EAEA,OAAO,OAAO,KAAK;CACpB;AACD"}
|