@prismicio/e2e-tests-utils 1.6.1 → 1.6.2-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.
@@ -15,18 +15,22 @@ class WroomClient {
15
15
  * @param baseURL - The base URL of the Wroom app. ex: https://prismic.io
16
16
  * @param auth - Authentication credentials.
17
17
  */
18
- constructor(baseURL, auth) {
18
+ constructor(baseURL, auth, cluster) {
19
19
  __publicField(this, "auth");
20
20
  __publicField(this, "client");
21
21
  __publicField(this, "loggedIn", false);
22
22
  this.auth = auth;
23
+ const clusterHeader = cluster ? {
24
+ "X-Prismic-Cluster": cluster
25
+ } : {};
23
26
  this.client = axios.create({
24
27
  baseURL,
25
28
  withCredentials: true,
26
29
  validateStatus: () => true,
27
30
  xsrfCookieName: "X_XSRF",
28
31
  headers: {
29
- "User-Agent": "prismic-cli/prismic-e2e-tests-utils"
32
+ "User-Agent": "prismic-cli/prismic-e2e-tests-utils",
33
+ ...clusterHeader
30
34
  }
31
35
  });
32
36
  this.client.interceptors.response.use((response) => {
@@ -1 +1 @@
1
- {"version":3,"file":"wroom.cjs","sources":["../../../src/clients/wroom.ts"],"sourcesContent":["import axios, { AxiosInstance, AxiosResponse } from \"axios\";\n\nimport { AuthConfig } from \"../types\";\n\nimport { extractCookie } from \"../utils/cookies\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\n/**\n * Client for interacting with the Wroom service to perform operations on\n * repositories.\n */\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 */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tprivate readonly auth: AuthConfig,\n\t) {\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},\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(\n\t\trepository: string | null,\n\t\tpath: string,\n\t\tdata?: unknown,\n\t): 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 *\n\t * @returns The Axios Reponse\n\t */\n\tasync updateRole(\n\t\trepository: string,\n\t\temail: string,\n\t\trole: string,\n\t): 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 *\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"],"names":["cookies","extractCookie","getRepositoryUrl","logger","logHttpResponse"],"mappings":";;;;;;;;;;;;MAYa,YAAW;AAAA;AAAA;AAAA;AAAA;AAAA,EAQvB,YACC,SACiB,MAAgB;AAAhB;AATD;AACT,oCAAW;AAQD,SAAI,OAAJ;AAEZ,SAAA,SAAS,MAAM,OAAO;AAAA,MAC1B;AAAA,MACA,iBAAiB;AAAA,MACjB,gBAAgB,MAAM;AAAA,MACtB,gBAAgB;AAAA,MAChB,SAAS;AAAA,QACR,cAAc;AAAA,MACd;AAAA,IAAA,CACD;AAGD,SAAK,OAAO,aAAa,SAAS,IAAI,CAAC,aAAY;AAC5C,YAAAA,YAAU,SAAS,QAAQ,YAAY;AAC7C,UAAIA,aAAWC,QAAAA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ACA,cAAoC;AAEpC,UAAM,SAAS,IAAI,gBAAgB,EAAE,MAAO,CAAA;AAC5C,UAAM,OAAO,sCAAsC,OAAO,SAAA,CAAU;AAEpE,WAAO,KAAK,KAAK,YAAY,MAAM,YAAY;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOQ,MAAM,QAAK;AACZ,UAAA,WAAWE,WAAO;AACxB,UAAM,WAAW,MAAM,KAAK,OAAO,KAAa,0BAA0B;AAAA,MACzE,OAAO,KAAK,KAAK;AAAA,MACjB,UAAU,KAAK,KAAK;AAAA,IAAA,CACpB;AAEG,QAAA,SAAS,WAAW,KAAK;AAC5BC,UAAA,gBAAgB,QAAQ;AAClB,YAAA,IAAI,MAAM,oDAAoD;AAAA,IACrE;AACA,SAAK,WAAW;AAChB,aAAS,KAAK,EAAE,SAAS,uBAAwB,CAAA;AAAA,EAClD;AACA;;"}
1
+ {"version":3,"file":"wroom.cjs","sources":["../../../src/clients/wroom.ts"],"sourcesContent":["import axios, { AxiosInstance, AxiosResponse } from \"axios\";\n\nimport { AuthConfig } from \"../types\";\n\nimport { extractCookie } from \"../utils/cookies\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\n/**\n * Client for interacting with the Wroom service to perform operations on\n * repositories.\n */\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 */\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(\n\t\trepository: string | null,\n\t\tpath: string,\n\t\tdata?: unknown,\n\t): 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 *\n\t * @returns The Axios Reponse\n\t */\n\tasync updateRole(\n\t\trepository: string,\n\t\temail: string,\n\t\trole: string,\n\t): 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 *\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"],"names":["cookies","extractCookie","getRepositoryUrl","logger","logHttpResponse"],"mappings":";;;;;;;;;;;;MAYa,YAAW;AAAA;AAAA;AAAA;AAAA;AAAA,EAQvB,YACC,SACiB,MACjB,SAAgB;AADC;AATD;AACT,oCAAW;AAQD,SAAI,OAAJ;AAGjB,UAAM,gBAAgB,UACnB;AAAA,MACA,qBAAqB;AAAA,QAErB;AAEE,SAAA,SAAS,MAAM,OAAO;AAAA,MAC1B;AAAA,MACA,iBAAiB;AAAA,MACjB,gBAAgB,MAAM;AAAA,MACtB,gBAAgB;AAAA,MAChB,SAAS;AAAA,QACR,cAAc;AAAA,QACd,GAAG;AAAA,MACH;AAAA,IAAA,CACD;AAGD,SAAK,OAAO,aA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AAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,mBACL,YACA,OACA,cAAoC;AAEpC,UAAM,SAAS,IAAI,gBAAgB,EAAE,MAAO,CAAA;AAC5C,UAAM,OAAO,sCAAsC,OAAO,SAAA,CAAU;AAEpE,WAAO,KAAK,KAAK,YAAY,MAAM,YAAY;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOQ,MAAM,QAAK;AACZ,UAAA,WAAWE,WAAO;AACxB,UAAM,WAAW,MAAM,KAAK,OAAO,KAAa,0BAA0B;AAAA,MACzE,OAAO,KAAK,KAAK;AAAA,MACjB,UAAU,KAAK,KAAK;AAAA,IAAA,CACpB;AAEG,QAAA,SAAS,WAAW,KAAK;AAC5BC,UAAA,gBAAgB,QAAQ;AAClB,YAAA,IAAI,MAAM,oDAAoD;AAAA,IACrE;AACA,SAAK,WAAW;AAChB,aAAS,KAAK,EAAE,SAAS,uBAAwB,CAAA;AAAA,EAClD;AACA;;"}
@@ -12,7 +12,7 @@ export declare class WroomClient {
12
12
  * @param baseURL - The base URL of the Wroom app. ex: https://prismic.io
13
13
  * @param auth - Authentication credentials.
14
14
  */
15
- constructor(baseURL: string, auth: AuthConfig);
15
+ constructor(baseURL: string, auth: AuthConfig, cluster?: string);
16
16
  getBaseURL(): string;
17
17
  /** authenticated GET request on the wroom backend */
18
18
  get(repository: string | null, path: string): Promise<AxiosResponse>;
@@ -13,18 +13,22 @@ class WroomClient {
13
13
  * @param baseURL - The base URL of the Wroom app. ex: https://prismic.io
14
14
  * @param auth - Authentication credentials.
15
15
  */
16
- constructor(baseURL, auth) {
16
+ constructor(baseURL, auth, cluster) {
17
17
  __publicField(this, "auth");
18
18
  __publicField(this, "client");
19
19
  __publicField(this, "loggedIn", false);
20
20
  this.auth = auth;
21
+ const clusterHeader = cluster ? {
22
+ "X-Prismic-Cluster": cluster
23
+ } : {};
21
24
  this.client = axios.create({
22
25
  baseURL,
23
26
  withCredentials: true,
24
27
  validateStatus: () => true,
25
28
  xsrfCookieName: "X_XSRF",
26
29
  headers: {
27
- "User-Agent": "prismic-cli/prismic-e2e-tests-utils"
30
+ "User-Agent": "prismic-cli/prismic-e2e-tests-utils",
31
+ ...clusterHeader
28
32
  }
29
33
  });
30
34
  this.client.interceptors.response.use((response) => {
@@ -1 +1 @@
1
- {"version":3,"file":"wroom.js","sources":["../../../src/clients/wroom.ts"],"sourcesContent":["import axios, { AxiosInstance, AxiosResponse } from \"axios\";\n\nimport { AuthConfig } from \"../types\";\n\nimport { extractCookie } from \"../utils/cookies\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\n/**\n * Client for interacting with the Wroom service to perform operations on\n * repositories.\n */\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 */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tprivate readonly auth: AuthConfig,\n\t) {\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},\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(\n\t\trepository: string | null,\n\t\tpath: string,\n\t\tdata?: unknown,\n\t): 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 *\n\t * @returns The Axios Reponse\n\t */\n\tasync updateRole(\n\t\trepository: string,\n\t\temail: string,\n\t\trole: string,\n\t): 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 *\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"],"names":[],"mappings":";;;;;;;;;;MAYa,YAAW;AAAA;AAAA;AAAA;AAAA;AAAA,EAQvB,YACC,SACiB,MAAgB;AAAhB;AATD;AACT,oCAAW;AAQD,SAAI,OAAJ;AAEZ,SAAA,SAAS,MAAM,OAAO;AAAA,MAC1B;AAAA,MACA,iBAAiB;AAAA,MACjB,gBAAgB,MAAM;AAAA,MACtB,gBAAgB;AAAA,MAChB,SAAS;AAAA,QACR,cAAc;AAAA,MACd;AAAA,IAAA,CACD;AAGD,SAAK,OAAO,aAAa,SAAS,IAAI,CAAC,aAAY;AAC5C,YAAA,UAAU,SAAS,QAAQ,YAAY;AAC7C,UAAI,WAAW,cAAc,SAAS,SAAS,GAAG;AACjD,aAAK,OAAO,SAAS,QAAQ,QAAQ,IAAI;AAAA,MAC1C;AAEO,aAAA;AAAA,IAAA,CACP;AAAA,EACF;AAAA,EAEA,aAAU;AACF,WAAA,KAAK,OAAO;EACpB;AAAA;AAAA,EAGA,MAAM,IAAI,YAA2B,MAAY;AAC5C,QAAA,CAAC,KAAK,UAAU;AACnB,YAAM,KAAK;IACZ;AAEI,QAAA,MAAM,IAAI,IAAI,MAAM,KAAK,OAAO,OAAA,CAAQ,EAAE;AAC9C,QAAI,YAAY;AACT,YAAA,iBAAiB,KAAK,UAAU;AAAA,IACvC;AAEO,WAAA,KAAK,OAAO,IAAI,GAAG;AAAA,EAC3B;AAAA;AAAA,EAGA,MAAM,KACL,YACA,MACA,MAAc;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AAwB,CAAA;AAAA,EAClD;AACA;"}
1
+ {"version":3,"file":"wroom.js","sources":["../../../src/clients/wroom.ts"],"sourcesContent":["import axios, { AxiosInstance, AxiosResponse } from \"axios\";\n\nimport { AuthConfig } from \"../types\";\n\nimport { extractCookie } from \"../utils/cookies\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\n/**\n * Client for interacting with the Wroom service to perform operations on\n * repositories.\n */\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 */\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(\n\t\trepository: string | null,\n\t\tpath: string,\n\t\tdata?: unknown,\n\t): 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 *\n\t * @returns The Axios Reponse\n\t */\n\tasync updateRole(\n\t\trepository: string,\n\t\temail: string,\n\t\trole: string,\n\t): 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 *\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"],"names":[],"mappings":";;;;;;;;;;MAYa,YAAW;AAAA;AAAA;AAAA;AAAA;AAAA,EAQvB,YACC,SACiB,MACjB,SAAgB;AADC;AATD;AACT,oCAAW;AAQD,SAAI,OAAJ;AAGjB,UAAM,gBAAgB,UACnB;AAAA,MACA,qBAAqB;AAAA,QAErB;AAEE,SAAA,SAAS,MAAM,OAAO;AAAA,MAC1B;AAAA,MACA,iBAAiB;AAAA,MACjB,gBAAgB,MAAM;AAAA,MACtB,gBAAgB;AAAA,MAChB,SAAS;AAAA,QACR,cAAc;AAAA,QACd,GAAG;AAAA,MACH;AAAA,IAAA,CACD;AAGD,SAAK,OAAO,aAAa,SAAS,IAAI,CAAC,aAAY;AAC5C,YAAA,UAAU,SAAS,QAAQ,YAAY;AAC7C,UAAI,WAAW,cAAc,SAAS,SAAS,GAAG;AACjD,aAAK,OAAO,SAAS,QAAQ,QAAQ,IAAI;AAAA,MAC1C;AAEO,aAAA;AAAA,IAAA,CACP;AAAA,EACF;AAAA,EAEA,aAAU;AACF,WAAA,KAAK,OAAO;EACpB;AAAA;AAAA,EAGA,MAAM,IAAI,YAA2B,MAAY;AAC5C,QAAA,CAAC,KAAK,UAAU;AACnB,YAAM,KAAK;IACZ;AAEI,QAAA,MAAM,IAAI,IAAI,MAAM,KAAK,OAAO,OAAA,CAAQ,EAAE;AAC9C,QAAI,YAAY;AACT,YAAA,iBAAiB,KAAK,UAAU;AAAA,IACvC;AAEO,WAAA,KAAK,OAAO,IAAI,GAAG;AAAA,EAC3B;AAAA;AAAA,EAGA,MAAM,KACL,YACA,MACA,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AS,uBAAwB,CAAA;AAAA,EAClD;AACA;"}
@@ -41,7 +41,8 @@ class RepositoriesManager {
41
41
  // When a string is provided, treat it as the 'base' property
42
42
  urlConfig: typeof configuration.urlConfig === "string" ? this.inferUrls(configuration.urlConfig) : configuration.urlConfig
43
43
  };
44
- this.wroomClient = new wroom.WroomClient(this.config.urlConfig.baseURL, this.config.authConfig);
44
+ console.log(this.config);
45
+ this.wroomClient = new wroom.WroomClient(this.config.urlConfig.baseURL, this.config.authConfig, this.config.cluster);
45
46
  this.authClient = new authenticationApi.AuthenticationApiClient(this.config.urlConfig.authenticationApi, this.config.authConfig);
46
47
  this.manageV2Client = new manageV2.ManageV2Client(this.config.urlConfig.baseURL, this.config.manageV2Config);
47
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"repositories.cjs","sources":["../../../src/managers/repositories.ts"],"sourcesContent":["import { SetupConfiguration, UrlConfig } from \"../types\";\n\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\";\nimport { CoreApiClient } from \"../clients/coreApi\";\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\";\nimport { ManageV2Client } from \"../clients/manageV2\";\nimport { MigrationApiClient } from \"../clients/migrationApi\";\nimport { WroomClient } from \"../clients/wroom\";\nimport { EnvVariableManager } from \"../utils/envVariableManager\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { randomString } from \"../utils/random\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\nimport { RepositoryConfig, RepositoryManager } from \"./repository\";\n\n/**\n * Factory method to create a RepositoriesManager to manage repositories test\n * data.\n *\n * @param configuration - Global object containing the different configurations\n * required to setup the RepositoriesManager.\n *\n * - {@link configuration.urlConfig}: Configuration around the API's URLs management.\n * - {@link configuration.authConfig}: Configuration around the authentication of a user.\n * - {@link configuration.manageV2Config}: Optional Configuration used to make calls to ManageV2.\n *\n * @returns An instance of {@link RepositoriesManager} to manage test data.\n */\nexport const createRepositoriesManager = (\n\tconfiguration: SetupConfiguration,\n): RepositoriesManager => {\n\treturn new RepositoriesManager(configuration);\n};\n\n/** Utility object to manage Prismic test data */\nexport class RepositoriesManager {\n\tprivate readonly config: Omit<SetupConfiguration, \"urlConfig\"> & {\n\t\turlConfig: UrlConfig;\n\t};\n\tprivate readonly wroomClient: WroomClient;\n\tprivate readonly authClient: AuthenticationApiClient;\n\tprivate readonly manageV2Client: ManageV2Client;\n\t/**\n\t * helper to keep track of repositories across independent test phases (setup,\n\t * teardown)\n\t */\n\tprivate readonly repositories = new EnvVariableManager(\n\t\t\"_PRISMIC_E2E_TESTS_REPOS\",\n\t);\n\n\t/**\n\t * @param configuration - Global object containing the different configuration\n\t * required to setup the different clients.\n\t * @param credentials - Authentication credentials (email and password)\n\t */\n\tconstructor(configuration: SetupConfiguration) {\n\t\tthis.config = {\n\t\t\t...configuration,\n\t\t\t// When a string is provided, treat it as the 'base' property\n\t\t\turlConfig:\n\t\t\t\ttypeof configuration.urlConfig === \"string\"\n\t\t\t\t\t? this.inferUrls(configuration.urlConfig)\n\t\t\t\t\t: configuration.urlConfig,\n\t\t};\n\n\t\tthis.wroomClient = new WroomClient(\n\t\t\tthis.config.urlConfig.baseURL,\n\t\t\tthis.config.authConfig,\n\t\t);\n\t\tthis.authClient = new AuthenticationApiClient(\n\t\t\tthis.config.urlConfig.authenticationApi,\n\t\t\tthis.config.authConfig,\n\t\t);\n\t\tthis.manageV2Client = new ManageV2Client(\n\t\t\tthis.config.urlConfig.baseURL,\n\t\t\tthis.config.manageV2Config,\n\t\t);\n\t}\n\n\t/**\n\t * If the baseURL is prismic.io, assume the other services have the format\n\t * <name>.prismic.io\n\t */\n\tprivate inferUrls(baseURL: string): UrlConfig {\n\t\tconst url = new URL(baseURL);\n\t\tconst protocol = url.protocol.slice(0, -1); // Remove the trailing colon from the protocol\n\n\t\treturn {\n\t\t\tbaseURL: baseURL,\n\t\t\tauthenticationApi: `${protocol}://auth.${url.hostname}`,\n\t\t\tcustomTypesApi: `${protocol}://customtypes.${url.hostname}`,\n\t\t\tmigrationApi: `${protocol}://migration.${url.hostname}`,\n\t\t};\n\t}\n\n\t/**\n\t * Generate a user token from the authentication service.\n\t *\n\t * @returns a JWT token\n\t */\n\tasync getUserApiToken(): Promise<string> {\n\t\treturn this.authClient.getToken();\n\t}\n\n\t/**\n\t * Create a new repository in Wroom.\n\t *\n\t * @param repositoryName - The name of the repository.\n\t *\n\t * @throws Error if the repository creation fails.\n\t */\n\tasync createRepository(\n\t\tconfig: {\n\t\t\tprefix?: string;\n\t\t} & RepositoryConfig = {},\n\t): Promise<RepositoryManager> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst { prefix = \"e2e-tests\" } = config;\n\t\tconst repositoryName = `${prefix}-${randomString()}`;\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tnull,\n\t\t\t\"authentication/newrepository\",\n\t\t\t{\n\t\t\t\tdomain: repositoryName,\n\t\t\t\tframework: \"vue\",\n\t\t\t\tplan: \"personal\",\n\t\t\t\tisAnnual: \"false\",\n\t\t\t\trole: \"developer\",\n\t\t\t},\n\t\t);\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not create repository ${repositoryName}`);\n\t\t}\n\t\tthis.repositories.add(repositoryName);\n\n\t\tconst repository = this.getRepositoryManager(repositoryName);\n\t\tconst version = await repository.getDeployedVersion();\n\n\t\tprofiler.done({\n\t\t\tmessage: `created repository '${repositoryName}', Wroom version is \"${version}\"`,\n\t\t});\n\t\tawait repository.configure(config);\n\n\t\treturn repository;\n\t}\n\n\t/**\n\t * Delete a repository from Wroom.\n\t *\n\t * @param repository - The name of the repository.\n\t *\n\t * @throws Error if the repository deletion fails.\n\t */\n\tasync deleteRepository(repository: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst post = async () =>\n\t\t\tthis.wroomClient.post(repository, \"app/settings/delete\", {\n\t\t\t\tconfirm: repository,\n\t\t\t\tpassword: this.config.authConfig.password,\n\t\t\t});\n\t\tconst response = await post();\n\t\tif (response.status !== 200) {\n\t\t\t// sometimes the deletion returns 500 but actually succeeds\n\t\t\t// we run the query again and check the repo is actually deleted (404)\n\t\t\tconst retry = await post();\n\t\t\tif (retry.status !== 404) {\n\t\t\t\tlogHttpResponse(response);\n\t\t\t\tthrow new Error(`Could not delete repository ${repository}`);\n\t\t\t}\n\t\t}\n\t\tthis.repositories.remove(repository);\n\t\tprofiler.done({ message: `deleted repository '${repository}'` });\n\t}\n\n\t/**\n\t * Cleanup test data. For example, it deletes repositories created using\n\t * createRepository()\n\t */\n\tasync tearDown(): Promise<void> {\n\t\tconst repositories = this.repositories.getAll();\n\t\tfor (const repository of repositories) {\n\t\t\tawait this.deleteRepository(repository);\n\t\t}\n\t}\n\n\t/**\n\t * Return a repository utilities object for a repository.\n\t *\n\t * @param repository - The name of the repository.\n\t */\n\tgetRepositoryManager(repository: string): RepositoryManager {\n\t\tconst { urlConfig } = this.config;\n\t\tconst authToken = () => this.authClient.getToken();\n\t\tconst customTypeClient = new CustomTypesApiClient(\n\t\t\turlConfig.customTypesApi,\n\t\t\t{\n\t\t\t\tauthToken,\n\t\t\t\trepository,\n\t\t\t},\n\t\t);\n\t\tconst coreApiUrl = getRepositoryUrl(urlConfig.baseURL, repository);\n\t\tconst coreApiClient = new CoreApiClient(coreApiUrl, authToken);\n\t\tconst migrationApiClient = urlConfig.migrationApi\n\t\t\t? new MigrationApiClient(urlConfig.migrationApi, {\n\t\t\t\t\tauthToken,\n\t\t\t\t\trepository,\n\t\t\t\t})\n\t\t\t: undefined;\n\n\t\treturn new RepositoryManager(\n\t\t\trepository,\n\t\t\tcoreApiClient,\n\t\t\tthis.authClient,\n\t\t\tthis.wroomClient,\n\t\t\tcustomTypeClient,\n\t\t\tmigrationApiClient,\n\t\t\tthis.manageV2Client,\n\t\t);\n\t}\n}\n"],"names":["EnvVariableManager","WroomClient","AuthenticationApiClient","ManageV2Client","logger","randomString","logHttpResponse","repository","CustomTypesApiClient","getRepositoryUrl","CoreApiClient","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K,iBAAiBA,WAAU;AAAA,IACvC;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,qBAAqBA,cAAkB;AAChC,UAAA,EAAE,UAAS,IAAK,KAAK;AAC3B,UAAM,YAAY,MAAM,KAAK,WAAW,SAAQ;AAChD,UAAM,mBAAmB,IAAIC,oCAC5B,UAAU,gBACV;AAAA,MACC;AAAA,MAAA,YACAD;AAAAA,IAAA,CACA;AAEF,UAAM,aAAaE,KAAA,iBAAiB,UAAU,SAASF,YAAU;AACjE,UAAM,gBAAgB,IAAIG,QAAAA,cAAc,YAAY,SAAS;AAC7D,UAAM,qBAAqB,UAAU,eAClC,IAAIC,aAAA,mBAAmB,UAAU,cAAc;AAAA,MAC/C;AAAA,MAAA,YACAJ;AAAAA,IAAA,CACA,IACA;AAEI,WAAA,IAAIK,WAAAA,kBACVL,cACA,eACA,KAAK,YACL,KAAK,aACL,kBACA,oBACA,KAAK,cAAc;AAAA,EAErB;AACA;;;"}
1
+ {"version":3,"file":"repositories.cjs","sources":["../../../src/managers/repositories.ts"],"sourcesContent":["import { SetupConfiguration, UrlConfig } from \"../types\";\n\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\";\nimport { CoreApiClient } from \"../clients/coreApi\";\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\";\nimport { ManageV2Client } from \"../clients/manageV2\";\nimport { MigrationApiClient } from \"../clients/migrationApi\";\nimport { WroomClient } from \"../clients/wroom\";\nimport { EnvVariableManager } from \"../utils/envVariableManager\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { randomString } from \"../utils/random\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\nimport { RepositoryConfig, RepositoryManager } from \"./repository\";\n\n/**\n * Factory method to create a RepositoriesManager to manage repositories test\n * data.\n *\n * @param configuration - Global object containing the different configurations\n * required to setup the RepositoriesManager.\n *\n * - {@link configuration.urlConfig}: Configuration around the API's URLs management.\n * - {@link configuration.authConfig}: Configuration around the authentication of a user.\n * - {@link configuration.manageV2Config}: Optional Configuration used to make calls to ManageV2.\n *\n * @returns An instance of {@link RepositoriesManager} to manage test data.\n */\nexport const createRepositoriesManager = (\n\tconfiguration: SetupConfiguration,\n): RepositoriesManager => {\n\treturn new RepositoriesManager(configuration);\n};\n\n/** Utility object to manage Prismic test data */\nexport class RepositoriesManager {\n\tprivate readonly config: Omit<SetupConfiguration, \"urlConfig\"> & {\n\t\turlConfig: UrlConfig;\n\t};\n\tprivate readonly wroomClient: WroomClient;\n\tprivate readonly authClient: AuthenticationApiClient;\n\tprivate readonly manageV2Client: ManageV2Client;\n\t/**\n\t * helper to keep track of repositories across independent test phases (setup,\n\t * teardown)\n\t */\n\tprivate readonly repositories = new EnvVariableManager(\n\t\t\"_PRISMIC_E2E_TESTS_REPOS\",\n\t);\n\n\t/**\n\t * @param configuration - Global object containing the different configuration\n\t * required to setup the different clients.\n\t * @param credentials - Authentication credentials (email and password)\n\t */\n\tconstructor(configuration: SetupConfiguration) {\n\t\tthis.config = {\n\t\t\t...configuration,\n\t\t\t// When a string is provided, treat it as the 'base' property\n\t\t\turlConfig:\n\t\t\t\ttypeof configuration.urlConfig === \"string\"\n\t\t\t\t\t? this.inferUrls(configuration.urlConfig)\n\t\t\t\t\t: configuration.urlConfig,\n\t\t};\n\t\tconsole.log(this.config);\n\t\tthis.wroomClient = new WroomClient(\n\t\t\tthis.config.urlConfig.baseURL,\n\t\t\tthis.config.authConfig,\n\t\t\tthis.config.cluster,\n\t\t);\n\t\tthis.authClient = new AuthenticationApiClient(\n\t\t\tthis.config.urlConfig.authenticationApi,\n\t\t\tthis.config.authConfig,\n\t\t);\n\t\tthis.manageV2Client = new ManageV2Client(\n\t\t\tthis.config.urlConfig.baseURL,\n\t\t\tthis.config.manageV2Config,\n\t\t);\n\t}\n\n\t/**\n\t * If the baseURL is prismic.io, assume the other services have the format\n\t * <name>.prismic.io\n\t */\n\tprivate inferUrls(baseURL: string): UrlConfig {\n\t\tconst url = new URL(baseURL);\n\t\tconst protocol = url.protocol.slice(0, -1); // Remove the trailing colon from the protocol\n\n\t\treturn {\n\t\t\tbaseURL: baseURL,\n\t\t\tauthenticationApi: `${protocol}://auth.${url.hostname}`,\n\t\t\tcustomTypesApi: `${protocol}://customtypes.${url.hostname}`,\n\t\t\tmigrationApi: `${protocol}://migration.${url.hostname}`,\n\t\t};\n\t}\n\n\t/**\n\t * Generate a user token from the authentication service.\n\t *\n\t * @returns a JWT token\n\t */\n\tasync getUserApiToken(): Promise<string> {\n\t\treturn this.authClient.getToken();\n\t}\n\n\t/**\n\t * Create a new repository in Wroom.\n\t *\n\t * @param repositoryName - The name of the repository.\n\t *\n\t * @throws Error if the repository creation fails.\n\t */\n\tasync createRepository(\n\t\tconfig: {\n\t\t\tprefix?: string;\n\t\t} & RepositoryConfig = {},\n\t): Promise<RepositoryManager> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst { prefix = \"e2e-tests\" } = config;\n\t\tconst repositoryName = `${prefix}-${randomString()}`;\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tnull,\n\t\t\t\"authentication/newrepository\",\n\t\t\t{\n\t\t\t\tdomain: repositoryName,\n\t\t\t\tframework: \"vue\",\n\t\t\t\tplan: \"personal\",\n\t\t\t\tisAnnual: \"false\",\n\t\t\t\trole: \"developer\",\n\t\t\t},\n\t\t);\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not create repository ${repositoryName}`);\n\t\t}\n\t\tthis.repositories.add(repositoryName);\n\n\t\tconst repository = this.getRepositoryManager(repositoryName);\n\t\tconst version = await repository.getDeployedVersion();\n\n\t\tprofiler.done({\n\t\t\tmessage: `created repository '${repositoryName}', Wroom version is \"${version}\"`,\n\t\t});\n\t\tawait repository.configure(config);\n\n\t\treturn repository;\n\t}\n\n\t/**\n\t * Delete a repository from Wroom.\n\t *\n\t * @param repository - The name of the repository.\n\t *\n\t * @throws Error if the repository deletion fails.\n\t */\n\tasync deleteRepository(repository: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst post = async () =>\n\t\t\tthis.wroomClient.post(repository, \"app/settings/delete\", {\n\t\t\t\tconfirm: repository,\n\t\t\t\tpassword: this.config.authConfig.password,\n\t\t\t});\n\t\tconst response = await post();\n\t\tif (response.status !== 200) {\n\t\t\t// sometimes the deletion returns 500 but actually succeeds\n\t\t\t// we run the query again and check the repo is actually deleted (404)\n\t\t\tconst retry = await post();\n\t\t\tif (retry.status !== 404) {\n\t\t\t\tlogHttpResponse(response);\n\t\t\t\tthrow new Error(`Could not delete repository ${repository}`);\n\t\t\t}\n\t\t}\n\t\tthis.repositories.remove(repository);\n\t\tprofiler.done({ message: `deleted repository '${repository}'` });\n\t}\n\n\t/**\n\t * Cleanup test data. For example, it deletes repositories created using\n\t * createRepository()\n\t */\n\tasync tearDown(): Promise<void> {\n\t\tconst repositories = this.repositories.getAll();\n\t\tfor (const repository of repositories) {\n\t\t\tawait this.deleteRepository(repository);\n\t\t}\n\t}\n\n\t/**\n\t * Return a repository utilities object for a repository.\n\t *\n\t * @param repository - The name of the repository.\n\t */\n\tgetRepositoryManager(repository: string): RepositoryManager {\n\t\tconst { urlConfig } = this.config;\n\t\tconst authToken = () => this.authClient.getToken();\n\t\tconst customTypeClient = new CustomTypesApiClient(\n\t\t\turlConfig.customTypesApi,\n\t\t\t{\n\t\t\t\tauthToken,\n\t\t\t\trepository,\n\t\t\t},\n\t\t);\n\t\tconst coreApiUrl = getRepositoryUrl(urlConfig.baseURL, repository);\n\t\tconst coreApiClient = new CoreApiClient(coreApiUrl, authToken);\n\t\tconst migrationApiClient = urlConfig.migrationApi\n\t\t\t? new MigrationApiClient(urlConfig.migrationApi, {\n\t\t\t\t\tauthToken,\n\t\t\t\t\trepository,\n\t\t\t\t})\n\t\t\t: undefined;\n\n\t\treturn new RepositoryManager(\n\t\t\trepository,\n\t\t\tcoreApiClient,\n\t\t\tthis.authClient,\n\t\t\tthis.wroomClient,\n\t\t\tcustomTypeClient,\n\t\t\tmigrationApiClient,\n\t\t\tthis.manageV2Client,\n\t\t);\n\t}\n}\n"],"names":["EnvVariableManager","WroomClient","AuthenticationApiClient","ManageV2Client","logger","randomString","logHttpResponse","repository","CustomTypesApiClient","getRepositoryUrl","CoreApiClient","MigrationApiClient","RepositoryManager"],"mappings":";;;;;;;;;;;;;;;;;;;AA4Ba,MAAA,4BAA4B,CACxC,kBACwB;AACjB,SAAA,IAAI,oBAAoB,aAAa;AAC7C;MAGa,oBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoB/B,YAAY,eAAiC;AAnB5B;AAGA;AACA;AACA;AAKA;AAAA;AAAA;AAAA;AAAA,wCAAe,IAAIA,sCACnC,0BAA0B;AAS1B,SAAK,SAAS;AAAA,MACb,GAAG;AAAA;AAAA,MAEH,WACC,OAAO,cAAc,cAAc,WAChC,KAAK,UAAU,cAAc,SAAS,IACtC,cAAc;AAAA,IAAA;AAEX,YAAA,IAAI,KAAK,MAAM;AACvB,SAAK,cAAc,IAAIC,MACtB,YAAA,KAAK,OAAO,UAAU,SACtB,KAAK,OAAO,YACZ,KAAK,OAAO,OAAO;AAEf,SAAA,aAAa,IAAIC,kBACrB,wBAAA,KAAK,OAAO,UAAU,mBACtB,KAAK,OAAO,UAAU;AAElB,SAAA,iBAAiB,IAAIC,SACzB,eAAA,KAAK,OAAO,UAAU,SACtB,KAAK,OAAO,cAAc;AAAA,EAE5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,UAAU,SAAe;AAC1B,UAAA,MAAM,IAAI,IAAI,OAAO;AAC3B,UAAM,WAAW,IAAI,SAAS,MAAM,GAAG,EAAE;AAElC,WAAA;AAAA,MACN;AAAA,MACA,mBAAmB,GAAG,QAAQ,WAAW,IAAI,QAAQ;AAAA,MACrD,gBAAgB,GAAG,QAAQ,kBAAkB,IAAI,QAAQ;AAAA,MACzD,cAAc,GAAG,QAAQ,gBAAgB,IAAI,QAAQ;AAAA,IAAA;AAA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D;AAAA,IACD;AACK,SAAA,aAAa,OAAOA,WAAU;AACnC,aAAS,KAAK,EAAE,SAAS,uBAAuBA,WAAU,KAAK;AAAA,EAChE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WAAQ;AACP,UAAA,eAAe,KAAK,aAAa;AACvC,eAAWA,eAAc,cAAc;AAChC,YAAA,KAAK,iBAAiBA,WAAU;AAAA,IACvC;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,qBAAqBA,cAAkB;AAChC,UAAA,EAAE,UAAS,IAAK,KAAK;AAC3B,UAAM,YAAY,MAAM,KAAK,WAAW,SAAQ;AAChD,UAAM,mBAAmB,IAAIC,oCAC5B,UAAU,gBACV;AAAA,MACC;AAAA,MAAA,YACAD;AAAAA,IAAA,CACA;AAEF,UAAM,aAAaE,KAAA,iBAAiB,UAAU,SAASF,YAAU;AACjE,UAAM,gBAAgB,IAAIG,QAAAA,cAAc,YAAY,SAAS;AAC7D,UAAM,qBAAqB,UAAU,eAClC,IAAIC,aAAA,mBAAmB,UAAU,cAAc;AAAA,MAC/C;AAAA,MAAA,YACAJ;AAAAA,IAAA,CACA,IACA;AAEI,WAAA,IAAIK,WAAAA,kBACVL,cACA,eACA,KAAK,YACL,KAAK,aACL,kBACA,oBACA,KAAK,cAAc;AAAA,EAErB;AACA;;;"}
@@ -39,7 +39,8 @@ class RepositoriesManager {
39
39
  // When a string is provided, treat it as the 'base' property
40
40
  urlConfig: typeof configuration.urlConfig === "string" ? this.inferUrls(configuration.urlConfig) : configuration.urlConfig
41
41
  };
42
- this.wroomClient = new WroomClient(this.config.urlConfig.baseURL, this.config.authConfig);
42
+ console.log(this.config);
43
+ this.wroomClient = new WroomClient(this.config.urlConfig.baseURL, this.config.authConfig, this.config.cluster);
43
44
  this.authClient = new AuthenticationApiClient(this.config.urlConfig.authenticationApi, this.config.authConfig);
44
45
  this.manageV2Client = new ManageV2Client(this.config.urlConfig.baseURL, this.config.manageV2Config);
45
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"repositories.js","sources":["../../../src/managers/repositories.ts"],"sourcesContent":["import { SetupConfiguration, UrlConfig } from \"../types\";\n\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\";\nimport { CoreApiClient } from \"../clients/coreApi\";\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\";\nimport { ManageV2Client } from \"../clients/manageV2\";\nimport { MigrationApiClient } from \"../clients/migrationApi\";\nimport { WroomClient } from \"../clients/wroom\";\nimport { EnvVariableManager } from \"../utils/envVariableManager\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { randomString } from \"../utils/random\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\nimport { RepositoryConfig, RepositoryManager } from \"./repository\";\n\n/**\n * Factory method to create a RepositoriesManager to manage repositories test\n * data.\n *\n * @param configuration - Global object containing the different configurations\n * required to setup the RepositoriesManager.\n *\n * - {@link configuration.urlConfig}: Configuration around the API's URLs management.\n * - {@link configuration.authConfig}: Configuration around the authentication of a user.\n * - {@link configuration.manageV2Config}: Optional Configuration used to make calls to ManageV2.\n *\n * @returns An instance of {@link RepositoriesManager} to manage test data.\n */\nexport const createRepositoriesManager = (\n\tconfiguration: SetupConfiguration,\n): RepositoriesManager => {\n\treturn new RepositoriesManager(configuration);\n};\n\n/** Utility object to manage Prismic test data */\nexport class RepositoriesManager {\n\tprivate readonly config: Omit<SetupConfiguration, \"urlConfig\"> & {\n\t\turlConfig: UrlConfig;\n\t};\n\tprivate readonly wroomClient: WroomClient;\n\tprivate readonly authClient: AuthenticationApiClient;\n\tprivate readonly manageV2Client: ManageV2Client;\n\t/**\n\t * helper to keep track of repositories across independent test phases (setup,\n\t * teardown)\n\t */\n\tprivate readonly repositories = new EnvVariableManager(\n\t\t\"_PRISMIC_E2E_TESTS_REPOS\",\n\t);\n\n\t/**\n\t * @param configuration - Global object containing the different configuration\n\t * required to setup the different clients.\n\t * @param credentials - Authentication credentials (email and password)\n\t */\n\tconstructor(configuration: SetupConfiguration) {\n\t\tthis.config = {\n\t\t\t...configuration,\n\t\t\t// When a string is provided, treat it as the 'base' property\n\t\t\turlConfig:\n\t\t\t\ttypeof configuration.urlConfig === \"string\"\n\t\t\t\t\t? this.inferUrls(configuration.urlConfig)\n\t\t\t\t\t: configuration.urlConfig,\n\t\t};\n\n\t\tthis.wroomClient = new WroomClient(\n\t\t\tthis.config.urlConfig.baseURL,\n\t\t\tthis.config.authConfig,\n\t\t);\n\t\tthis.authClient = new AuthenticationApiClient(\n\t\t\tthis.config.urlConfig.authenticationApi,\n\t\t\tthis.config.authConfig,\n\t\t);\n\t\tthis.manageV2Client = new ManageV2Client(\n\t\t\tthis.config.urlConfig.baseURL,\n\t\t\tthis.config.manageV2Config,\n\t\t);\n\t}\n\n\t/**\n\t * If the baseURL is prismic.io, assume the other services have the format\n\t * <name>.prismic.io\n\t */\n\tprivate inferUrls(baseURL: string): UrlConfig {\n\t\tconst url = new URL(baseURL);\n\t\tconst protocol = url.protocol.slice(0, -1); // Remove the trailing colon from the protocol\n\n\t\treturn {\n\t\t\tbaseURL: baseURL,\n\t\t\tauthenticationApi: `${protocol}://auth.${url.hostname}`,\n\t\t\tcustomTypesApi: `${protocol}://customtypes.${url.hostname}`,\n\t\t\tmigrationApi: `${protocol}://migration.${url.hostname}`,\n\t\t};\n\t}\n\n\t/**\n\t * Generate a user token from the authentication service.\n\t *\n\t * @returns a JWT token\n\t */\n\tasync getUserApiToken(): Promise<string> {\n\t\treturn this.authClient.getToken();\n\t}\n\n\t/**\n\t * Create a new repository in Wroom.\n\t *\n\t * @param repositoryName - The name of the repository.\n\t *\n\t * @throws Error if the repository creation fails.\n\t */\n\tasync createRepository(\n\t\tconfig: {\n\t\t\tprefix?: string;\n\t\t} & RepositoryConfig = {},\n\t): Promise<RepositoryManager> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst { prefix = \"e2e-tests\" } = config;\n\t\tconst repositoryName = `${prefix}-${randomString()}`;\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tnull,\n\t\t\t\"authentication/newrepository\",\n\t\t\t{\n\t\t\t\tdomain: repositoryName,\n\t\t\t\tframework: \"vue\",\n\t\t\t\tplan: \"personal\",\n\t\t\t\tisAnnual: \"false\",\n\t\t\t\trole: \"developer\",\n\t\t\t},\n\t\t);\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not create repository ${repositoryName}`);\n\t\t}\n\t\tthis.repositories.add(repositoryName);\n\n\t\tconst repository = this.getRepositoryManager(repositoryName);\n\t\tconst version = await repository.getDeployedVersion();\n\n\t\tprofiler.done({\n\t\t\tmessage: `created repository '${repositoryName}', Wroom version is \"${version}\"`,\n\t\t});\n\t\tawait repository.configure(config);\n\n\t\treturn repository;\n\t}\n\n\t/**\n\t * Delete a repository from Wroom.\n\t *\n\t * @param repository - The name of the repository.\n\t *\n\t * @throws Error if the repository deletion fails.\n\t */\n\tasync deleteRepository(repository: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst post = async () =>\n\t\t\tthis.wroomClient.post(repository, \"app/settings/delete\", {\n\t\t\t\tconfirm: repository,\n\t\t\t\tpassword: this.config.authConfig.password,\n\t\t\t});\n\t\tconst response = await post();\n\t\tif (response.status !== 200) {\n\t\t\t// sometimes the deletion returns 500 but actually succeeds\n\t\t\t// we run the query again and check the repo is actually deleted (404)\n\t\t\tconst retry = await post();\n\t\t\tif (retry.status !== 404) {\n\t\t\t\tlogHttpResponse(response);\n\t\t\t\tthrow new Error(`Could not delete repository ${repository}`);\n\t\t\t}\n\t\t}\n\t\tthis.repositories.remove(repository);\n\t\tprofiler.done({ message: `deleted repository '${repository}'` });\n\t}\n\n\t/**\n\t * Cleanup test data. For example, it deletes repositories created using\n\t * createRepository()\n\t */\n\tasync tearDown(): Promise<void> {\n\t\tconst repositories = this.repositories.getAll();\n\t\tfor (const repository of repositories) {\n\t\t\tawait this.deleteRepository(repository);\n\t\t}\n\t}\n\n\t/**\n\t * Return a repository utilities object for a repository.\n\t *\n\t * @param repository - The name of the repository.\n\t */\n\tgetRepositoryManager(repository: string): RepositoryManager {\n\t\tconst { urlConfig } = this.config;\n\t\tconst authToken = () => this.authClient.getToken();\n\t\tconst customTypeClient = new CustomTypesApiClient(\n\t\t\turlConfig.customTypesApi,\n\t\t\t{\n\t\t\t\tauthToken,\n\t\t\t\trepository,\n\t\t\t},\n\t\t);\n\t\tconst coreApiUrl = getRepositoryUrl(urlConfig.baseURL, repository);\n\t\tconst coreApiClient = new CoreApiClient(coreApiUrl, authToken);\n\t\tconst migrationApiClient = urlConfig.migrationApi\n\t\t\t? new MigrationApiClient(urlConfig.migrationApi, {\n\t\t\t\t\tauthToken,\n\t\t\t\t\trepository,\n\t\t\t\t})\n\t\t\t: undefined;\n\n\t\treturn new RepositoryManager(\n\t\t\trepository,\n\t\t\tcoreApiClient,\n\t\t\tthis.authClient,\n\t\t\tthis.wroomClient,\n\t\t\tcustomTypeClient,\n\t\t\tmigrationApiClient,\n\t\t\tthis.manageV2Client,\n\t\t);\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA4Ba,MAAA,4BAA4B,CACxC,kBACwB;AACjB,SAAA,IAAI,oBAAoB,aAAa;AAC7C;MAGa,oBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoB/B,YAAY,eAAiC;AAnB5B;AAGA;AACA;AACA;AAKA;AAAA;AAAA;AAAA;AAAA,wCAAe,IAAI,mBACnC,0BAA0B;AAS1B,SAAK,SAAS;AAAA,MACb,GAAG;AAAA;AAAA,MAEH,WACC,OAAO,cAAc,cAAc,WAChC,KAAK,UAAU,cAAc,SAAS,IACtC,cAAc;AAAA,IAAA;AAGd,SAAA,cAAc,IAAI,YACtB,KAAK,OAAO,UAAU,SACtB,KAAK,OAAO,UAAU;AAElB,SAAA,aAAa,IAAI,wBACrB,KAAK,OAAO,UAAU,mBACtB,KAAK,OAAO,UAAU;AAElB,SAAA,iBAA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;AAAA,EASA,MAAM,iBAAiB,YAAkB;AAClC,UAAA,WAAW,OAAO;AAExB,UAAM,OAAO,YACZ,KAAK,YAAY,KAAK,YAAY,uBAAuB;AAAA,MACxD,SAAS;AAAA,MACT,UAAU,KAAK,OAAO,WAAW;AAAA,IAAA,CACjC;AACI,UAAA,WAAW,MAAM;AACnB,QAAA,SAAS,WAAW,KAAK;AAGtB,YAAA,QAAQ,MAAM;AAChB,UAAA,MAAM,WAAW,KAAK;AACzB,wBAAgB,QAAQ;AACxB,cAAM,IAAI,MAAM,+BAA+B,UAAU,EAAE;AAAA,MAC5D;AAAA,IACD;AACK,SAAA,aAAa,OAAO,UAAU;AACnC,aAAS,KAAK,EAAE,SAAS,uBAAuB,UAAU,KAAK;AAAA,EAChE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WAAQ;AACP,UAAA,eAAe,KAAK,aAAa;AACvC,eAAW,cAAc,cAAc;AAChC,YAAA,KAAK,iBAAiB,UAAU;AAAA,IACvC;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,qBAAqB,YAAkB;AAChC,UAAA,EAAE,UAAS,IAAK,KAAK;AAC3B,UAAM,YAAY,MAAM,KAAK,WAAW,SAAQ;AAChD,UAAM,mBAAmB,IAAI,qBAC5B,UAAU,gBACV;AAAA,MACC;AAAA,MACA;AAAA,IAAA,CACA;AAEF,UAAM,aAAa,iBAAiB,UAAU,SAAS,UAAU;AACjE,UAAM,gBAAgB,IAAI,cAAc,YAAY,SAAS;AAC7D,UAAM,qBAAqB,UAAU,eAClC,IAAI,mBAAmB,UAAU,cAAc;AAAA,MAC/C;AAAA,MACA;AAAA,IAAA,CACA,IACA;AAEI,WAAA,IAAI,kBACV,YACA,eACA,KAAK,YACL,KAAK,aACL,kBACA,oBACA,KAAK,cAAc;AAAA,EAErB;AACA;"}
1
+ {"version":3,"file":"repositories.js","sources":["../../../src/managers/repositories.ts"],"sourcesContent":["import { SetupConfiguration, UrlConfig } from \"../types\";\n\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\";\nimport { CoreApiClient } from \"../clients/coreApi\";\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\";\nimport { ManageV2Client } from \"../clients/manageV2\";\nimport { MigrationApiClient } from \"../clients/migrationApi\";\nimport { WroomClient } from \"../clients/wroom\";\nimport { EnvVariableManager } from \"../utils/envVariableManager\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { randomString } from \"../utils/random\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\nimport { RepositoryConfig, RepositoryManager } from \"./repository\";\n\n/**\n * Factory method to create a RepositoriesManager to manage repositories test\n * data.\n *\n * @param configuration - Global object containing the different configurations\n * required to setup the RepositoriesManager.\n *\n * - {@link configuration.urlConfig}: Configuration around the API's URLs management.\n * - {@link configuration.authConfig}: Configuration around the authentication of a user.\n * - {@link configuration.manageV2Config}: Optional Configuration used to make calls to ManageV2.\n *\n * @returns An instance of {@link RepositoriesManager} to manage test data.\n */\nexport const createRepositoriesManager = (\n\tconfiguration: SetupConfiguration,\n): RepositoriesManager => {\n\treturn new RepositoriesManager(configuration);\n};\n\n/** Utility object to manage Prismic test data */\nexport class RepositoriesManager {\n\tprivate readonly config: Omit<SetupConfiguration, \"urlConfig\"> & {\n\t\turlConfig: UrlConfig;\n\t};\n\tprivate readonly wroomClient: WroomClient;\n\tprivate readonly authClient: AuthenticationApiClient;\n\tprivate readonly manageV2Client: ManageV2Client;\n\t/**\n\t * helper to keep track of repositories across independent test phases (setup,\n\t * teardown)\n\t */\n\tprivate readonly repositories = new EnvVariableManager(\n\t\t\"_PRISMIC_E2E_TESTS_REPOS\",\n\t);\n\n\t/**\n\t * @param configuration - Global object containing the different configuration\n\t * required to setup the different clients.\n\t * @param credentials - Authentication credentials (email and password)\n\t */\n\tconstructor(configuration: SetupConfiguration) {\n\t\tthis.config = {\n\t\t\t...configuration,\n\t\t\t// When a string is provided, treat it as the 'base' property\n\t\t\turlConfig:\n\t\t\t\ttypeof configuration.urlConfig === \"string\"\n\t\t\t\t\t? this.inferUrls(configuration.urlConfig)\n\t\t\t\t\t: configuration.urlConfig,\n\t\t};\n\t\tconsole.log(this.config);\n\t\tthis.wroomClient = new WroomClient(\n\t\t\tthis.config.urlConfig.baseURL,\n\t\t\tthis.config.authConfig,\n\t\t\tthis.config.cluster,\n\t\t);\n\t\tthis.authClient = new AuthenticationApiClient(\n\t\t\tthis.config.urlConfig.authenticationApi,\n\t\t\tthis.config.authConfig,\n\t\t);\n\t\tthis.manageV2Client = new ManageV2Client(\n\t\t\tthis.config.urlConfig.baseURL,\n\t\t\tthis.config.manageV2Config,\n\t\t);\n\t}\n\n\t/**\n\t * If the baseURL is prismic.io, assume the other services have the format\n\t * <name>.prismic.io\n\t */\n\tprivate inferUrls(baseURL: string): UrlConfig {\n\t\tconst url = new URL(baseURL);\n\t\tconst protocol = url.protocol.slice(0, -1); // Remove the trailing colon from the protocol\n\n\t\treturn {\n\t\t\tbaseURL: baseURL,\n\t\t\tauthenticationApi: `${protocol}://auth.${url.hostname}`,\n\t\t\tcustomTypesApi: `${protocol}://customtypes.${url.hostname}`,\n\t\t\tmigrationApi: `${protocol}://migration.${url.hostname}`,\n\t\t};\n\t}\n\n\t/**\n\t * Generate a user token from the authentication service.\n\t *\n\t * @returns a JWT token\n\t */\n\tasync getUserApiToken(): Promise<string> {\n\t\treturn this.authClient.getToken();\n\t}\n\n\t/**\n\t * Create a new repository in Wroom.\n\t *\n\t * @param repositoryName - The name of the repository.\n\t *\n\t * @throws Error if the repository creation fails.\n\t */\n\tasync createRepository(\n\t\tconfig: {\n\t\t\tprefix?: string;\n\t\t} & RepositoryConfig = {},\n\t): Promise<RepositoryManager> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst { prefix = \"e2e-tests\" } = config;\n\t\tconst repositoryName = `${prefix}-${randomString()}`;\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tnull,\n\t\t\t\"authentication/newrepository\",\n\t\t\t{\n\t\t\t\tdomain: repositoryName,\n\t\t\t\tframework: \"vue\",\n\t\t\t\tplan: \"personal\",\n\t\t\t\tisAnnual: \"false\",\n\t\t\t\trole: \"developer\",\n\t\t\t},\n\t\t);\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not create repository ${repositoryName}`);\n\t\t}\n\t\tthis.repositories.add(repositoryName);\n\n\t\tconst repository = this.getRepositoryManager(repositoryName);\n\t\tconst version = await repository.getDeployedVersion();\n\n\t\tprofiler.done({\n\t\t\tmessage: `created repository '${repositoryName}', Wroom version is \"${version}\"`,\n\t\t});\n\t\tawait repository.configure(config);\n\n\t\treturn repository;\n\t}\n\n\t/**\n\t * Delete a repository from Wroom.\n\t *\n\t * @param repository - The name of the repository.\n\t *\n\t * @throws Error if the repository deletion fails.\n\t */\n\tasync deleteRepository(repository: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst post = async () =>\n\t\t\tthis.wroomClient.post(repository, \"app/settings/delete\", {\n\t\t\t\tconfirm: repository,\n\t\t\t\tpassword: this.config.authConfig.password,\n\t\t\t});\n\t\tconst response = await post();\n\t\tif (response.status !== 200) {\n\t\t\t// sometimes the deletion returns 500 but actually succeeds\n\t\t\t// we run the query again and check the repo is actually deleted (404)\n\t\t\tconst retry = await post();\n\t\t\tif (retry.status !== 404) {\n\t\t\t\tlogHttpResponse(response);\n\t\t\t\tthrow new Error(`Could not delete repository ${repository}`);\n\t\t\t}\n\t\t}\n\t\tthis.repositories.remove(repository);\n\t\tprofiler.done({ message: `deleted repository '${repository}'` });\n\t}\n\n\t/**\n\t * Cleanup test data. For example, it deletes repositories created using\n\t * createRepository()\n\t */\n\tasync tearDown(): Promise<void> {\n\t\tconst repositories = this.repositories.getAll();\n\t\tfor (const repository of repositories) {\n\t\t\tawait this.deleteRepository(repository);\n\t\t}\n\t}\n\n\t/**\n\t * Return a repository utilities object for a repository.\n\t *\n\t * @param repository - The name of the repository.\n\t */\n\tgetRepositoryManager(repository: string): RepositoryManager {\n\t\tconst { urlConfig } = this.config;\n\t\tconst authToken = () => this.authClient.getToken();\n\t\tconst customTypeClient = new CustomTypesApiClient(\n\t\t\turlConfig.customTypesApi,\n\t\t\t{\n\t\t\t\tauthToken,\n\t\t\t\trepository,\n\t\t\t},\n\t\t);\n\t\tconst coreApiUrl = getRepositoryUrl(urlConfig.baseURL, repository);\n\t\tconst coreApiClient = new CoreApiClient(coreApiUrl, authToken);\n\t\tconst migrationApiClient = urlConfig.migrationApi\n\t\t\t? new MigrationApiClient(urlConfig.migrationApi, {\n\t\t\t\t\tauthToken,\n\t\t\t\t\trepository,\n\t\t\t\t})\n\t\t\t: undefined;\n\n\t\treturn new RepositoryManager(\n\t\t\trepository,\n\t\t\tcoreApiClient,\n\t\t\tthis.authClient,\n\t\t\tthis.wroomClient,\n\t\t\tcustomTypeClient,\n\t\t\tmigrationApiClient,\n\t\t\tthis.manageV2Client,\n\t\t);\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA4Ba,MAAA,4BAA4B,CACxC,kBACwB;AACjB,SAAA,IAAI,oBAAoB,aAAa;AAC7C;MAGa,oBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoB/B,YAAY,eAAiC;AAnB5B;AAGA;AACA;AACA;AAKA;AAAA;AAAA;AAAA;AAAA,wCAAe,IAAI,mBACnC,0BAA0B;AAS1B,SAAK,SAAS;AAAA,MACb,GAAG;AAAA;AAAA,MAEH,WACC,OAAO,cAAc,cAAc,WAChC,KAAK,UAAU,cAAc,SAAS,IACtC,cAAc;AAAA,IAAA;AAEX,YAAA,IAAI,KAAK,MAAM;AACvB,SAAK,cAAc,IAAI,YACtB,KAAK,OAAO,UAAU,SACtB,KAAK,OAAO,YACZ,KAAK,OAAO,OAAO;AAEf,SAAA,aAAa,IAAI,wBACrB,KAAK,OAAO,UAAU,mBACtB,KAAK,OAAO,UAAU;AAElB,SAAA,iBAAiB,IAAI,eACzB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uthConfig;
22
22
  manageV2Config?: ManageV2Config;
23
+ cluster?: string;
23
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/e2e-tests-utils",
3
- "version": "1.6.1",
3
+ "version": "1.6.2-alpha.1",
4
4
  "description": "A collection of utilities for to manage Prismic test data",
5
5
  "keywords": [
6
6
  "typescript",
@@ -21,7 +21,14 @@ export class WroomClient {
21
21
  constructor(
22
22
  baseURL: string,
23
23
  private readonly auth: AuthConfig,
24
+ cluster?: string,
24
25
  ) {
26
+ const clusterHeader = cluster
27
+ ? {
28
+ "X-Prismic-Cluster": cluster,
29
+ }
30
+ : {};
31
+
25
32
  this.client = axios.create({
26
33
  baseURL,
27
34
  withCredentials: true,
@@ -29,6 +36,7 @@ export class WroomClient {
29
36
  xsrfCookieName: "X_XSRF",
30
37
  headers: {
31
38
  "User-Agent": "prismic-cli/prismic-e2e-tests-utils",
39
+ ...clusterHeader,
32
40
  },
33
41
  });
34
42
 
@@ -62,10 +62,11 @@ export class RepositoriesManager {
62
62
  ? this.inferUrls(configuration.urlConfig)
63
63
  : configuration.urlConfig,
64
64
  };
65
-
65
+ console.log(this.config);
66
66
  this.wroomClient = new WroomClient(
67
67
  this.config.urlConfig.baseURL,
68
68
  this.config.authConfig,
69
+ this.config.cluster,
69
70
  );
70
71
  this.authClient = new AuthenticationApiClient(
71
72
  this.config.urlConfig.authenticationApi,
package/src/types.ts CHANGED
@@ -26,4 +26,5 @@ export type SetupConfiguration = {
26
26
  urlConfig: UrlConfig | string;
27
27
  authConfig: AuthConfig;
28
28
  manageV2Config?: ManageV2Config;
29
+ cluster?: string;
29
30
  };