@prismicio/e2e-tests-utils 1.17.1-alpha.0 → 1.18.0-canary.933a809
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 +52 -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 +52 -73
- 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 +25 -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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wroom.d.cts","names":[],"sources":["../../src/clients/wroom.ts"],"mappings":";;;;;cASa,WAAA;EAAA,iBAWM,IAAA;EAAA,iBAVD,MAAA;EAAA,QACT,QAAA;EASgB;;;;;cADvB,OAAA,UACiB,IAAA,EAAM,UAAA,EACvB,OAAA;EA8BD,UAAA;EA+De;EA1DT,GAAA,CAAI,UAAA,iBAA2B,IAAA,WAAe,OAAA,CAAQ,aAAA;EA2DzD;EA7CG,IAAA,CAAK,UAAA,iBAA2B,IAAA,UAAc,IAAA,aAAiB,OAAA,CAAQ,aAAA;EA6CnE;;;;;;;;EAnBJ,UAAA,CAAW,UAAA,UAAoB,KAAA,UAAe,IAAA,WAAe,OAAA,CAAQ,aAAA;EA7C3E;;;;;;;;EA4DM,kBAAA,CACL,UAAA,UACA,KAAA,UACA,YAAA,EAAc,MAAA,mBACZ,OAAA,CAAQ,aAAA;EA7CyC;;;;;EAAA,QAyDtC,KAAA;AAAA"}
|
package/dist/clients/wroom.d.ts
CHANGED
|
@@ -1,49 +1,48 @@
|
|
|
1
|
+
import { AuthConfig } from "../types.js";
|
|
1
2
|
import { AxiosResponse } from "axios";
|
|
2
|
-
|
|
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
|
-
* Authenticate Wroom to call Wroom unofficial endpoints.
|
|
45
|
-
*
|
|
46
|
-
* @throws Error if the login to Wroom fails.
|
|
47
|
-
*/
|
|
48
|
-
private login;
|
|
3
|
+
|
|
4
|
+
//#region src/clients/wroom.d.ts
|
|
5
|
+
/** Client for interacting with the Wroom service to perform operations on repositories. */
|
|
6
|
+
declare class WroomClient {
|
|
7
|
+
private readonly auth;
|
|
8
|
+
private readonly client;
|
|
9
|
+
private loggedIn;
|
|
10
|
+
/**
|
|
11
|
+
* @param baseURL - The base URL of the Wroom app. ex: https://prismic.io
|
|
12
|
+
* @param auth - Authentication credentials.
|
|
13
|
+
* @param cluster - Cluster where to create the repository (only work in staging)
|
|
14
|
+
*/
|
|
15
|
+
constructor(baseURL: string, auth: AuthConfig, cluster?: string);
|
|
16
|
+
getBaseURL(): string;
|
|
17
|
+
/** Authenticated GET request on the wroom backend */
|
|
18
|
+
get(repository: string | null, path: string): Promise<AxiosResponse>;
|
|
19
|
+
/** Authenticated POST request on the wroom backend */
|
|
20
|
+
post(repository: string | null, path: string, data?: unknown): Promise<AxiosResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Update the role of a user in the repository
|
|
23
|
+
*
|
|
24
|
+
* @param {string} repository - The repository name
|
|
25
|
+
* @param {string} email - The email of the user
|
|
26
|
+
* @param {string} role - The new role to be given
|
|
27
|
+
* @returns The Axios Reponse
|
|
28
|
+
*/
|
|
29
|
+
updateRole(repository: string, email: string, role: string): Promise<AxiosResponse>;
|
|
30
|
+
/**
|
|
31
|
+
* Update the role of a user in the repository
|
|
32
|
+
*
|
|
33
|
+
* @param {string} repository - The repository name
|
|
34
|
+
* @param {string} email - The email of the user
|
|
35
|
+
* @param {string} rolePerLocal - The role per local object
|
|
36
|
+
* @returns The Axios Reponse
|
|
37
|
+
*/
|
|
38
|
+
updateRolePerLocal(repository: string, email: string, rolePerLocal: Record<string, string>): Promise<AxiosResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Authenticate Wroom to call Wroom unofficial endpoints.
|
|
41
|
+
*
|
|
42
|
+
* @throws Error if the login to Wroom fails.
|
|
43
|
+
*/
|
|
44
|
+
private login;
|
|
49
45
|
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { WroomClient };
|
|
48
|
+
//# sourceMappingURL=wroom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wroom.d.ts","names":[],"sources":["../../src/clients/wroom.ts"],"mappings":";;;;;cASa,WAAA;EAAA,iBAWM,IAAA;EAAA,iBAVD,MAAA;EAAA,QACT,QAAA;EASgB;;;;;cADvB,OAAA,UACiB,IAAA,EAAM,UAAA,EACvB,OAAA;EA8BD,UAAA;EA+De;EA1DT,GAAA,CAAI,UAAA,iBAA2B,IAAA,WAAe,OAAA,CAAQ,aAAA;EA2DzD;EA7CG,IAAA,CAAK,UAAA,iBAA2B,IAAA,UAAc,IAAA,aAAiB,OAAA,CAAQ,aAAA;EA6CnE;;;;;;;;EAnBJ,UAAA,CAAW,UAAA,UAAoB,KAAA,UAAe,IAAA,WAAe,OAAA,CAAQ,aAAA;EA7C3E;;;;;;;;EA4DM,kBAAA,CACL,UAAA,UACA,KAAA,UACA,YAAA,EAAc,MAAA,mBACZ,OAAA,CAAQ,aAAA;EA7CyC;;;;;EAAA,QAyDtC,KAAA;AAAA"}
|
package/dist/clients/wroom.js
CHANGED
|
@@ -1,124 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
import axios from "axios";
|
|
8
|
-
import { extractCookie } from "../utils/cookies.js";
|
|
9
|
-
import { logger, logHttpResponse } from "../utils/log.js";
|
|
1
|
+
import { logHttpResponse, logger } from "../utils/log.js";
|
|
10
2
|
import { getRepositoryUrl } from "../utils/urls.js";
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
* @throws Error if the login to Wroom fails.
|
|
106
|
-
*/
|
|
107
|
-
async login() {
|
|
108
|
-
const profiler = logger.startTimer();
|
|
109
|
-
const response = await this.client.post("/authentication/signin", {
|
|
110
|
-
email: this.auth.email,
|
|
111
|
-
password: this.auth.password
|
|
112
|
-
});
|
|
113
|
-
if (response.status !== 200) {
|
|
114
|
-
logHttpResponse(response);
|
|
115
|
-
throw new Error("Could not login to Prismic, check your credentials");
|
|
116
|
-
}
|
|
117
|
-
this.loggedIn = true;
|
|
118
|
-
profiler.done({ message: "logged in to Prismic" });
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
export {
|
|
122
|
-
WroomClient
|
|
3
|
+
import { extractCookie } from "../utils/cookies.js";
|
|
4
|
+
import axios from "axios";
|
|
5
|
+
//#region src/clients/wroom.ts
|
|
6
|
+
/** Client for interacting with the Wroom service to perform operations on repositories. */
|
|
7
|
+
var WroomClient = class {
|
|
8
|
+
auth;
|
|
9
|
+
client;
|
|
10
|
+
loggedIn = false;
|
|
11
|
+
/**
|
|
12
|
+
* @param baseURL - The base URL of the Wroom app. ex: https://prismic.io
|
|
13
|
+
* @param auth - Authentication credentials.
|
|
14
|
+
* @param cluster - Cluster where to create the repository (only work in staging)
|
|
15
|
+
*/
|
|
16
|
+
constructor(baseURL, auth, cluster) {
|
|
17
|
+
this.auth = auth;
|
|
18
|
+
const clusterHeader = cluster ? { "X-Prismic-Cluster": cluster } : {};
|
|
19
|
+
this.client = axios.create({
|
|
20
|
+
baseURL,
|
|
21
|
+
withCredentials: true,
|
|
22
|
+
validateStatus: () => true,
|
|
23
|
+
xsrfCookieName: "X_XSRF",
|
|
24
|
+
headers: {
|
|
25
|
+
"User-Agent": "prismic-cli/prismic-e2e-tests-utils",
|
|
26
|
+
...clusterHeader
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
this.client.interceptors.response.use((response) => {
|
|
30
|
+
const cookies = response.headers["set-cookie"];
|
|
31
|
+
if (cookies && extractCookie(cookies, "SESSION")) this.client.defaults.headers["Cookie"] = cookies;
|
|
32
|
+
return response;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
getBaseURL() {
|
|
36
|
+
return this.client.getUri();
|
|
37
|
+
}
|
|
38
|
+
/** Authenticated GET request on the wroom backend */
|
|
39
|
+
async get(repository, path) {
|
|
40
|
+
if (!this.loggedIn) await this.login();
|
|
41
|
+
let url = new URL(path, this.client.getUri()).toString();
|
|
42
|
+
if (repository) url = getRepositoryUrl(url, repository);
|
|
43
|
+
return this.client.get(url);
|
|
44
|
+
}
|
|
45
|
+
/** Authenticated POST request on the wroom backend */
|
|
46
|
+
async post(repository, path, data) {
|
|
47
|
+
if (!this.loggedIn) await this.login();
|
|
48
|
+
let url = new URL(path, this.client.getUri()).toString();
|
|
49
|
+
if (repository) url = getRepositoryUrl(url, repository);
|
|
50
|
+
return await this.client.post(url.toString(), data, { params: { _: extractCookie(this.client.defaults.headers["Cookie"], "X_XSRF") } });
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Update the role of a user in the repository
|
|
54
|
+
*
|
|
55
|
+
* @param {string} repository - The repository name
|
|
56
|
+
* @param {string} email - The email of the user
|
|
57
|
+
* @param {string} role - The new role to be given
|
|
58
|
+
* @returns The Axios Reponse
|
|
59
|
+
*/
|
|
60
|
+
async updateRole(repository, email, role) {
|
|
61
|
+
const path = `/app/settings/users/profiles?${new URLSearchParams({
|
|
62
|
+
email,
|
|
63
|
+
profile: role
|
|
64
|
+
}).toString()}`;
|
|
65
|
+
return this.post(repository, path);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Update the role of a user in the repository
|
|
69
|
+
*
|
|
70
|
+
* @param {string} repository - The repository name
|
|
71
|
+
* @param {string} email - The email of the user
|
|
72
|
+
* @param {string} rolePerLocal - The role per local object
|
|
73
|
+
* @returns The Axios Reponse
|
|
74
|
+
*/
|
|
75
|
+
async updateRolePerLocal(repository, email, rolePerLocal) {
|
|
76
|
+
const path = `/app/settings/users/rolesperlocale?${new URLSearchParams({ email }).toString()}`;
|
|
77
|
+
return this.post(repository, path, rolePerLocal);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Authenticate Wroom to call Wroom unofficial endpoints.
|
|
81
|
+
*
|
|
82
|
+
* @throws Error if the login to Wroom fails.
|
|
83
|
+
*/
|
|
84
|
+
async login() {
|
|
85
|
+
const profiler = logger.startTimer();
|
|
86
|
+
const response = await this.client.post("/authentication/signin", {
|
|
87
|
+
email: this.auth.email,
|
|
88
|
+
password: this.auth.password
|
|
89
|
+
});
|
|
90
|
+
if (response.status !== 200) {
|
|
91
|
+
logHttpResponse(response);
|
|
92
|
+
throw new Error("Could not login to Prismic, check your credentials");
|
|
93
|
+
}
|
|
94
|
+
this.loggedIn = true;
|
|
95
|
+
profiler.done({ message: "logged in to Prismic" });
|
|
96
|
+
}
|
|
123
97
|
};
|
|
124
|
-
//#
|
|
98
|
+
//#endregion
|
|
99
|
+
export { WroomClient };
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=wroom.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wroom.js","sources":["
|
|
1
|
+
{"version":3,"file":"wroom.js","names":[],"sources":["../../src/clients/wroom.ts"],"sourcesContent":["import type { AxiosInstance, AxiosResponse } from \"axios\"\nimport axios from \"axios\"\n\nimport type { AuthConfig } from \"../types\"\nimport { extractCookie } from \"../utils/cookies\"\nimport { logHttpResponse, logger } from \"../utils/log\"\nimport { getRepositoryUrl } from \"../utils/urls\"\n\n/** Client for interacting with the Wroom service to perform operations on repositories. */\nexport class WroomClient {\n\tprivate readonly client: AxiosInstance\n\tprivate loggedIn = false\n\n\t/**\n\t * @param baseURL - The base URL of the Wroom app. ex: https://prismic.io\n\t * @param auth - Authentication credentials.\n\t * @param cluster - Cluster where to create the repository (only work in staging)\n\t */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tprivate readonly auth: AuthConfig,\n\t\tcluster?: string,\n\t) {\n\t\tconst clusterHeader = cluster\n\t\t\t? {\n\t\t\t\t\t\"X-Prismic-Cluster\": cluster,\n\t\t\t\t}\n\t\t\t: {}\n\n\t\tthis.client = axios.create({\n\t\t\tbaseURL,\n\t\t\twithCredentials: true,\n\t\t\tvalidateStatus: () => true,\n\t\t\txsrfCookieName: \"X_XSRF\",\n\t\t\theaders: {\n\t\t\t\t\"User-Agent\": \"prismic-cli/prismic-e2e-tests-utils\",\n\t\t\t\t...clusterHeader,\n\t\t\t},\n\t\t})\n\n\t\t// cookies are not forwarded automatically in a non-browser env\n\t\tthis.client.interceptors.response.use((response) => {\n\t\t\tconst cookies = response.headers[\"set-cookie\"]\n\t\t\tif (cookies && extractCookie(cookies, \"SESSION\")) {\n\t\t\t\tthis.client.defaults.headers[\"Cookie\"] = cookies\n\t\t\t}\n\n\t\t\treturn response\n\t\t})\n\t}\n\n\tgetBaseURL(): string {\n\t\treturn this.client.getUri()\n\t}\n\n\t/** Authenticated GET request on the wroom backend */\n\tasync get(repository: string | null, path: string): Promise<AxiosResponse> {\n\t\tif (!this.loggedIn) {\n\t\t\tawait this.login()\n\t\t}\n\n\t\tlet url = new URL(path, this.client.getUri()).toString()\n\t\tif (repository) {\n\t\t\turl = getRepositoryUrl(url, repository)\n\t\t}\n\n\t\treturn this.client.get(url)\n\t}\n\n\t/** Authenticated POST request on the wroom backend */\n\tasync post(repository: string | null, path: string, data?: unknown): Promise<AxiosResponse> {\n\t\tif (!this.loggedIn) {\n\t\t\tawait this.login()\n\t\t}\n\n\t\tlet url = new URL(path, this.client.getUri()).toString()\n\t\tif (repository) {\n\t\t\turl = getRepositoryUrl(url, repository)\n\t\t}\n\t\tconst response = await this.client.post(url.toString(), data, {\n\t\t\tparams: {\n\t\t\t\t_: extractCookie(this.client.defaults.headers[\"Cookie\"], \"X_XSRF\"),\n\t\t\t},\n\t\t})\n\n\t\treturn response\n\t}\n\n\t/**\n\t * Update the role of a user in the repository\n\t *\n\t * @param {string} repository - The repository name\n\t * @param {string} email - The email of the user\n\t * @param {string} role - The new role to be given\n\t * @returns The Axios Reponse\n\t */\n\tasync updateRole(repository: string, email: string, role: string): Promise<AxiosResponse> {\n\t\tconst params = new URLSearchParams({ email, profile: role })\n\t\tconst path = `/app/settings/users/profiles?${params.toString()}`\n\n\t\treturn this.post(repository, path)\n\t}\n\n\t/**\n\t * Update the role of a user in the repository\n\t *\n\t * @param {string} repository - The repository name\n\t * @param {string} email - The email of the user\n\t * @param {string} rolePerLocal - The role per local object\n\t * @returns The Axios Reponse\n\t */\n\tasync updateRolePerLocal(\n\t\trepository: string,\n\t\temail: string,\n\t\trolePerLocal: Record<string, string>,\n\t): Promise<AxiosResponse> {\n\t\tconst params = new URLSearchParams({ email })\n\t\tconst path = `/app/settings/users/rolesperlocale?${params.toString()}`\n\n\t\treturn this.post(repository, path, rolePerLocal)\n\t}\n\n\t/**\n\t * Authenticate Wroom to call Wroom unofficial endpoints.\n\t *\n\t * @throws Error if the login to Wroom fails.\n\t */\n\tprivate async login(): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\t\tconst response = await this.client.post<string>(\"/authentication/signin\", {\n\t\t\temail: this.auth.email,\n\t\t\tpassword: this.auth.password,\n\t\t})\n\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response)\n\t\t\tthrow new Error(\"Could not login to Prismic, check your credentials\")\n\t\t}\n\t\tthis.loggedIn = true\n\t\tprofiler.done({ message: \"logged in to Prismic\" })\n\t}\n}\n"],"mappings":";;;;;;AASA,IAAa,cAAb,MAAyB;CAWN;CAVlB;CACA,WAAmB;;;;;;CAOnB,YACC,SACA,MACA,SACC;EAFgB,KAAA,OAAA;EAGjB,MAAM,gBAAgB,UACnB,EACA,qBAAqB,QACtB,IACC,CAAC;EAEJ,KAAK,SAAS,MAAM,OAAO;GAC1B;GACA,iBAAiB;GACjB,sBAAsB;GACtB,gBAAgB;GAChB,SAAS;IACR,cAAc;IACd,GAAG;GACJ;EACD,CAAC;EAGD,KAAK,OAAO,aAAa,SAAS,KAAK,aAAa;GACnD,MAAM,UAAU,SAAS,QAAQ;GACjC,IAAI,WAAW,cAAc,SAAS,SAAS,GAC9C,KAAK,OAAO,SAAS,QAAQ,YAAY;GAG1C,OAAO;EACR,CAAC;CACF;CAEA,aAAqB;EACpB,OAAO,KAAK,OAAO,OAAO;CAC3B;;CAGA,MAAM,IAAI,YAA2B,MAAsC;EAC1E,IAAI,CAAC,KAAK,UACT,MAAM,KAAK,MAAM;EAGlB,IAAI,MAAM,IAAI,IAAI,MAAM,KAAK,OAAO,OAAO,CAAC,CAAC,CAAC,SAAS;EACvD,IAAI,YACH,MAAM,iBAAiB,KAAK,UAAU;EAGvC,OAAO,KAAK,OAAO,IAAI,GAAG;CAC3B;;CAGA,MAAM,KAAK,YAA2B,MAAc,MAAwC;EAC3F,IAAI,CAAC,KAAK,UACT,MAAM,KAAK,MAAM;EAGlB,IAAI,MAAM,IAAI,IAAI,MAAM,KAAK,OAAO,OAAO,CAAC,CAAC,CAAC,SAAS;EACvD,IAAI,YACH,MAAM,iBAAiB,KAAK,UAAU;EAQvC,OAAO,MANgB,KAAK,OAAO,KAAK,IAAI,SAAS,GAAG,MAAM,EAC7D,QAAQ,EACP,GAAG,cAAc,KAAK,OAAO,SAAS,QAAQ,WAAW,QAAQ,EAClE,EACD,CAAC;CAGF;;;;;;;;;CAUA,MAAM,WAAW,YAAoB,OAAe,MAAsC;EAEzF,MAAM,OAAO,gCAAgC,IAD1B,gBAAgB;GAAE;GAAO,SAAS;EAAK,CACR,CAAC,CAAC,SAAS;EAE7D,OAAO,KAAK,KAAK,YAAY,IAAI;CAClC;;;;;;;;;CAUA,MAAM,mBACL,YACA,OACA,cACyB;EAEzB,MAAM,OAAO,sCAAsC,IADhC,gBAAgB,EAAE,MAAM,CACa,CAAC,CAAC,SAAS;EAEnE,OAAO,KAAK,KAAK,YAAY,MAAM,YAAY;CAChD;;;;;;CAOA,MAAc,QAAuB;EACpC,MAAM,WAAW,OAAO,WAAW;EACnC,MAAM,WAAW,MAAM,KAAK,OAAO,KAAa,0BAA0B;GACzE,OAAO,KAAK,KAAK;GACjB,UAAU,KAAK,KAAK;EACrB,CAAC;EAED,IAAI,SAAS,WAAW,KAAK;GAC5B,gBAAgB,QAAQ;GACxB,MAAM,IAAI,MAAM,oDAAoD;EACrE;EACA,KAAK,WAAW;EAChB,SAAS,KAAK,EAAE,SAAS,uBAAuB,CAAC;CAClD;AACD"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
16
|
-
//# sourceMappingURL=index.cjs.map
|
|
2
|
+
const require_assetApi = require("./clients/assetApi.cjs");
|
|
3
|
+
const require_coreApi = require("./clients/coreApi.cjs");
|
|
4
|
+
const require_migrationApi = require("./clients/migrationApi.cjs");
|
|
5
|
+
const require_contentApi = require("./clients/contentApi.cjs");
|
|
6
|
+
const require_repository = require("./managers/repository.cjs");
|
|
7
|
+
const require_repositories = require("./managers/repositories.cjs");
|
|
8
|
+
exports.AssetApiClient = require_assetApi.AssetApiClient;
|
|
9
|
+
exports.ContentApiClient = require_contentApi.ContentApiClient;
|
|
10
|
+
exports.CoreApiClient = require_coreApi.CoreApiClient;
|
|
11
|
+
exports.MigrationApiClient = require_migrationApi.MigrationApiClient;
|
|
12
|
+
exports.RepositoriesManager = require_repositories.RepositoriesManager;
|
|
13
|
+
exports.RepositoryManager = require_repository.RepositoryManager;
|
|
14
|
+
exports.createRepositoriesManager = require_repositories.createRepositoriesManager;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AuthConfig, IntegrationFieldConfig, IntegrationFieldData, ManageV2Config, SetupConfiguration, UrlConfig } from "./types.cjs";
|
|
2
|
+
import { AssetApiClient, AssetApiCreatePayload, AssetApiCreateResponse, AssetApiResponse } from "./clients/assetApi.cjs";
|
|
3
|
+
import { ContentApiClient, ContentApiDocument, ContentApiError, ContentApiGraphQLResponse, ContentApiRef, ContentApiSearchResponse } from "./clients/contentApi.cjs";
|
|
4
|
+
import { CoreApiClient, CoreApiDocumentCreationPayload, CoreApiDocumentCreationResponse, CoreApiDocumentData, CoreApiDocumentsPayload, CoreApiDocumentsResponse, CoreApiRepository, Release } from "./clients/coreApi.cjs";
|
|
5
|
+
import { MigrationApiClient, MigrationApiDocumentPayload, MigrationApiDocumentResponse } from "./clients/migrationApi.cjs";
|
|
6
|
+
import { CustomLocale, Preview, RepositoryConfig, RepositoryManager } from "./managers/repository.cjs";
|
|
7
|
+
import { RepositoriesManager, createRepositoriesManager } from "./managers/repositories.cjs";
|
|
8
|
+
export { AssetApiClient, AssetApiCreatePayload, AssetApiCreateResponse, AssetApiResponse, AuthConfig, ContentApiClient, ContentApiDocument, ContentApiError, ContentApiGraphQLResponse, ContentApiRef, ContentApiSearchResponse, CoreApiClient, CoreApiDocumentCreationPayload, CoreApiDocumentCreationResponse, CoreApiDocumentData, CoreApiDocumentsPayload, CoreApiDocumentsResponse, CoreApiRepository, CustomLocale, IntegrationFieldConfig, IntegrationFieldData, ManageV2Config, MigrationApiClient, MigrationApiDocumentPayload, MigrationApiDocumentResponse, Preview, Release, RepositoriesManager, RepositoryConfig, RepositoryManager, SetupConfiguration, UrlConfig, createRepositoriesManager };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { AuthConfig, IntegrationFieldConfig, IntegrationFieldData, ManageV2Config, SetupConfiguration, UrlConfig } from "./types.js";
|
|
2
|
+
import { AssetApiClient, AssetApiCreatePayload, AssetApiCreateResponse, AssetApiResponse } from "./clients/assetApi.js";
|
|
3
|
+
import { ContentApiClient, ContentApiDocument, ContentApiError, ContentApiGraphQLResponse, ContentApiRef, ContentApiSearchResponse } from "./clients/contentApi.js";
|
|
4
|
+
import { CoreApiClient, CoreApiDocumentCreationPayload, CoreApiDocumentCreationResponse, CoreApiDocumentData, CoreApiDocumentsPayload, CoreApiDocumentsResponse, CoreApiRepository, Release } from "./clients/coreApi.js";
|
|
5
|
+
import { MigrationApiClient, MigrationApiDocumentPayload, MigrationApiDocumentResponse } from "./clients/migrationApi.js";
|
|
6
|
+
import { CustomLocale, Preview, RepositoryConfig, RepositoryManager } from "./managers/repository.js";
|
|
7
|
+
import { RepositoriesManager, createRepositoriesManager } from "./managers/repositories.js";
|
|
8
|
+
export { AssetApiClient, AssetApiCreatePayload, AssetApiCreateResponse, AssetApiResponse, AuthConfig, ContentApiClient, ContentApiDocument, ContentApiError, ContentApiGraphQLResponse, ContentApiRef, ContentApiSearchResponse, CoreApiClient, CoreApiDocumentCreationPayload, CoreApiDocumentCreationResponse, CoreApiDocumentData, CoreApiDocumentsPayload, CoreApiDocumentsResponse, CoreApiRepository, CustomLocale, IntegrationFieldConfig, IntegrationFieldData, ManageV2Config, MigrationApiClient, MigrationApiDocumentPayload, MigrationApiDocumentResponse, Preview, Release, RepositoriesManager, RepositoryConfig, RepositoryManager, SetupConfiguration, UrlConfig, createRepositoriesManager };
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import { RepositoriesManager, createRepositoriesManager } from "./managers/repositories.js";
|
|
2
|
-
import { RepositoryManager } from "./managers/repository.js";
|
|
3
|
-
import { CoreApiClient } from "./clients/coreApi.js";
|
|
4
|
-
import { ContentApiClient } from "./clients/contentApi.js";
|
|
5
1
|
import { AssetApiClient } from "./clients/assetApi.js";
|
|
2
|
+
import { CoreApiClient } from "./clients/coreApi.js";
|
|
6
3
|
import { MigrationApiClient } from "./clients/migrationApi.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
MigrationApiClient,
|
|
12
|
-
RepositoriesManager,
|
|
13
|
-
RepositoryManager,
|
|
14
|
-
createRepositoriesManager
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
4
|
+
import { ContentApiClient } from "./clients/contentApi.js";
|
|
5
|
+
import { RepositoryManager } from "./managers/repository.js";
|
|
6
|
+
import { RepositoriesManager, createRepositoriesManager } from "./managers/repositories.js";
|
|
7
|
+
export { AssetApiClient, ContentApiClient, CoreApiClient, MigrationApiClient, RepositoriesManager, RepositoryManager, createRepositoriesManager };
|