@prismicio/e2e-tests-utils 1.10.0-alpha.0 → 1.10.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,8 +20,8 @@ class ManageV2Client {
20
20
  // Not private to have it available on tests
21
21
  __publicField(this, "token", null);
22
22
  /**
23
- * The function `toggleRolePerLocal` enable or disable the role per local
24
- * feature
23
+ * The function `toggleRolePerLocal` enables or disables the RolesPerLocale
24
+ * workflow
25
25
  *
26
26
  * @param repository - The Repository name
27
27
  * @param enabled - The feature new status
@@ -33,6 +33,20 @@ class ManageV2Client {
33
33
  author: ManageV2StaticAuthor
34
34
  });
35
35
  }));
36
+ /**
37
+ * The function `toggleCustomRoles` enables or disables the CustomRoles
38
+ * workflow
39
+ *
40
+ * @param repository - The Repository name
41
+ * @param enabled - The feature new status
42
+ */
43
+ __publicField(this, "toggleCustomRoles", this.assertTokenExist((params) => {
44
+ return this.client.post("/repository/toggleCustomRoles", {
45
+ domain: params.repository,
46
+ enabled: params.enabled,
47
+ author: ManageV2StaticAuthor
48
+ });
49
+ }));
36
50
  /**
37
51
  * The function `changePlan` changes the plan of a repository the database
38
52
  *
@@ -1 +1 @@
1
- {"version":3,"file":"manageV2.cjs","sources":["../../../src/clients/manageV2.ts"],"sourcesContent":["import axios, { AxiosInstance, AxiosResponse } from \"axios\";\nimport jwt from \"jsonwebtoken\";\n\nimport { ManageV2Config } from \"../types\";\n\nimport { extractCookie } from \"../utils/cookies\";\n\nconst ManageV2StaticAuthor = \"prismic-e2e-tests-utils\";\n\n/**\n * Client for interacting with ManageV2 routes to perform operations on\n * repositories.\n */\nexport class ManageV2Client {\n\treadonly client: AxiosInstance; // Not private to have it available on tests\n\tprivate token: string | null = null;\n\n\t/**\n\t * @param baseURL - The base URL of the Wroom app. ex: https://prismic.io\n\t * @param config - ManageV2 configuration variable to call ManageV2.\n\t */\n\tconstructor(baseUrl: string, config?: ManageV2Config | undefined) {\n\t\tthis.token = config ? this.generateToken(config) : null;\n\n\t\tthis.client = axios.create({\n\t\t\tbaseURL: `${baseUrl}/manageroutes/`,\n\t\t\twithCredentials: true,\n\t\t\tvalidateStatus: () => true,\n\t\t\theaders: {\n\t\t\t\t\"User-Agent\": \"prismic-cli/prismic-e2e-tests-utils\",\n\t\t\t\tAuthorization: `Bearer ${this.token}`,\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\t/**\n\t * The function generates a JWT token using the provided configuration\n\t * parameters.\n\t *\n\t * @param {ManageV2Config} config - The `config` parameter in the\n\t * `generateToken` function is of type `ManageV2Config`. It contains the\n\t * following properties:\n\t *\n\t * @returns A JSON Web Token (JWT) is being returned by the `generateToken`\n\t * function. The token is signed using the provided `config.secret` with the\n\t * HS256 algorithm and includes the specified audience and issuer values.\n\t */\n\tprivate generateToken(config: ManageV2Config): string {\n\t\treturn jwt.sign({}, config.secret, {\n\t\t\talgorithm: \"HS256\",\n\t\t\taudience: config.audience,\n\t\t\tissuer: \"prismic.io\",\n\t\t});\n\t}\n\n\t/**\n\t * The function `assertTokenExist` checks if a token exists before executing a\n\t * given function.\n\t *\n\t * @param f - The `assertTokenExist` function takes a function `f` as a\n\t * parameter. This function `f` should accept a parameter of type\n\t * `Parameters` and return a Promise that resolves to an AxiosResponse. The\n\t * `assertTokenExist` function ensures that a token is not null before\n\t * calling the provided\n\t *\n\t * @returns A function is being returned that takes a parameter of type\n\t * Parameters and checks if the token is null. If the token is null, an\n\t * error is thrown. Otherwise, the function f is called with the provided\n\t * parameters.\n\t */\n\tprivate assertTokenExist<Parameters>(\n\t\tf: (_: Parameters) => Promise<AxiosResponse>,\n\t) {\n\t\treturn (params: Parameters) => {\n\t\t\tif (this.token === null) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Undefined configuration for ManageV2 while trying to use it's routes\",\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\treturn f(params);\n\t\t\t}\n\t\t};\n\t}\n\n\tgetBaseURL(): string {\n\t\treturn this.client.getUri();\n\t}\n\n\t/**\n\t * The function `toggleRolePerLocal` enable or disable the role per local\n\t * feature\n\t *\n\t * @param repository - The Repository name\n\t * @param enabled - The feature new status\n\t */\n\ttoggleRolePerLocal = this.assertTokenExist(\n\t\t(params: { repository: string; enabled: boolean }) => {\n\t\t\treturn this.client.post(\"/repository/toggleRolesPerLocale\", {\n\t\t\t\tdomain: params.repository,\n\t\t\t\tenabled: params.enabled,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n\n\t/**\n\t * The function `changePlan` changes the plan of a repository the database\n\t *\n\t * @param repository - The Repository name\n\t * @param newPlanId - The new planId\n\t * @param bypassManualBilling - Beware that using this will not verify that\n\t * the database and Stripe are in sync\n\t */\n\tchangePlan = this.assertTokenExist(\n\t\t({\n\t\t\trepository,\n\t\t\tnewPlanId,\n\t\t\tbypassManualBilling = false,\n\t\t}: {\n\t\t\trepository: string;\n\t\t\tnewPlanId: string;\n\t\t\tbypassManualBilling?: boolean;\n\t\t}) => {\n\t\t\treturn this.client.post(\n\t\t\t\t`/repository/changePlan?bypassManualBilling=${bypassManualBilling}`,\n\t\t\t\t{\n\t\t\t\t\tdomain: repository,\n\t\t\t\t\tnewPlan: newPlanId,\n\t\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t);\n\n\t/**\n\t * The function `addUserToRepository` adds a user corresponding to the email\n\t * to the given repository\n\t *\n\t * @param repository - The Repository name\n\t * @param email - The user email\n\t */\n\taddUserToRepository = this.assertTokenExist(\n\t\t({ repository, email }: { repository: string; email: string }) => {\n\t\t\treturn this.client.post(\"/repository/addUser\", {\n\t\t\t\tdomain: repository,\n\t\t\t\temail: email,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n\n\t/**\n\t * The function `removeUserFromRepository` removes a user corresponding to the\n\t * email from the given repository\n\t *\n\t * @param repository - The Repository name\n\t * @param email - The user email\n\t */\n\tremoveUserFromRepository = this.assertTokenExist(\n\t\t({ repository, email }: { repository: string; email: string }) => {\n\t\t\treturn this.client.post(\"/repository/removeUser\", {\n\t\t\t\tdomain: repository,\n\t\t\t\temail: email,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n}\n"],"names":["cookies","extractCookie"],"mappings":";;;;;;;;;;;AAOA,MAAM,uBAAuB;MAMhB,eAAc;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ1B,YAAY,SAAiB,QAAmC;AAPvD;AACD;AAAA,iCAAuB;AA0F/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8CAAqB,KAAK,iBACzB,CAAC,WAAoD;AAC7C,aAAA,KAAK,OAAO,KAAK,oCAAoC;AAAA,QAC3D,QAAQ,OAAO;AAAA,QACf,SAAS,OAAO;AAAA,QAChB,QAAQ;AAAA,MAAA,CACR;AAAA,IAAA,CACD;AAWF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAAa,KAAK,iBACjB,CAAC,EACA,YACA,WACA,sBAAsB,YAKlB;AACJ,aAAO,KAAK,OAAO,KAClB,8CAA8C,mBAAmB,IACjE;AAAA,QACC,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,QAAQ;AAAA,MAAA,CACR;AAAA,IAAA,CAEF;AAUF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+CAAsB,KAAK,iBAC1B,CAAC,EAAE,YAAY,YAAkD;AACzD,aAAA,KAAK,OAAO,KAAK,uBAAuB;AAAA,QAC9C,QAAQ;AAAA,QACR;AAAA,QACA,QAAQ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AAAA,MAChB;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,aAAU;AACF,WAAA,KAAK,OAAO;EACpB;AAiFA;;"}
1
+ {"version":3,"file":"manageV2.cjs","sources":["../../../src/clients/manageV2.ts"],"sourcesContent":["import axios, { AxiosInstance, AxiosResponse } from \"axios\";\nimport jwt from \"jsonwebtoken\";\n\nimport { ManageV2Config } from \"../types\";\n\nimport { extractCookie } from \"../utils/cookies\";\n\nconst ManageV2StaticAuthor = \"prismic-e2e-tests-utils\";\n\n/**\n * Client for interacting with ManageV2 routes to perform operations on\n * repositories.\n */\nexport class ManageV2Client {\n\treadonly client: AxiosInstance; // Not private to have it available on tests\n\tprivate token: string | null = null;\n\n\t/**\n\t * @param baseURL - The base URL of the Wroom app. ex: https://prismic.io\n\t * @param config - ManageV2 configuration variable to call ManageV2.\n\t */\n\tconstructor(baseUrl: string, config?: ManageV2Config | undefined) {\n\t\tthis.token = config ? this.generateToken(config) : null;\n\n\t\tthis.client = axios.create({\n\t\t\tbaseURL: `${baseUrl}/manageroutes/`,\n\t\t\twithCredentials: true,\n\t\t\tvalidateStatus: () => true,\n\t\t\theaders: {\n\t\t\t\t\"User-Agent\": \"prismic-cli/prismic-e2e-tests-utils\",\n\t\t\t\tAuthorization: `Bearer ${this.token}`,\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\t/**\n\t * The function generates a JWT token using the provided configuration\n\t * parameters.\n\t *\n\t * @param {ManageV2Config} config - The `config` parameter in the\n\t * `generateToken` function is of type `ManageV2Config`. It contains the\n\t * following properties:\n\t *\n\t * @returns A JSON Web Token (JWT) is being returned by the `generateToken`\n\t * function. The token is signed using the provided `config.secret` with the\n\t * HS256 algorithm and includes the specified audience and issuer values.\n\t */\n\tprivate generateToken(config: ManageV2Config): string {\n\t\treturn jwt.sign({}, config.secret, {\n\t\t\talgorithm: \"HS256\",\n\t\t\taudience: config.audience,\n\t\t\tissuer: \"prismic.io\",\n\t\t});\n\t}\n\n\t/**\n\t * The function `assertTokenExist` checks if a token exists before executing a\n\t * given function.\n\t *\n\t * @param f - The `assertTokenExist` function takes a function `f` as a\n\t * parameter. This function `f` should accept a parameter of type\n\t * `Parameters` and return a Promise that resolves to an AxiosResponse. The\n\t * `assertTokenExist` function ensures that a token is not null before\n\t * calling the provided\n\t *\n\t * @returns A function is being returned that takes a parameter of type\n\t * Parameters and checks if the token is null. If the token is null, an\n\t * error is thrown. Otherwise, the function f is called with the provided\n\t * parameters.\n\t */\n\tprivate assertTokenExist<Parameters>(\n\t\tf: (_: Parameters) => Promise<AxiosResponse>,\n\t) {\n\t\treturn (params: Parameters) => {\n\t\t\tif (this.token === null) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Undefined configuration for ManageV2 while trying to use it's routes\",\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\treturn f(params);\n\t\t\t}\n\t\t};\n\t}\n\n\tgetBaseURL(): string {\n\t\treturn this.client.getUri();\n\t}\n\n\t/**\n\t * The function `toggleRolePerLocal` enables or disables the RolesPerLocale\n\t * workflow\n\t *\n\t * @param repository - The Repository name\n\t * @param enabled - The feature new status\n\t */\n\ttoggleRolePerLocal = this.assertTokenExist(\n\t\t(params: { repository: string; enabled: boolean }) => {\n\t\t\treturn this.client.post(\"/repository/toggleRolesPerLocale\", {\n\t\t\t\tdomain: params.repository,\n\t\t\t\tenabled: params.enabled,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n\n\t/**\n\t * The function `toggleCustomRoles` enables or disables the CustomRoles\n\t * workflow\n\t *\n\t * @param repository - The Repository name\n\t * @param enabled - The feature new status\n\t */\n\ttoggleCustomRoles = this.assertTokenExist(\n\t\t(params: { repository: string; enabled: boolean }) => {\n\t\t\treturn this.client.post(\"/repository/toggleCustomRoles\", {\n\t\t\t\tdomain: params.repository,\n\t\t\t\tenabled: params.enabled,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n\n\t/**\n\t * The function `changePlan` changes the plan of a repository the database\n\t *\n\t * @param repository - The Repository name\n\t * @param newPlanId - The new planId\n\t * @param bypassManualBilling - Beware that using this will not verify that\n\t * the database and Stripe are in sync\n\t */\n\tchangePlan = this.assertTokenExist(\n\t\t({\n\t\t\trepository,\n\t\t\tnewPlanId,\n\t\t\tbypassManualBilling = false,\n\t\t}: {\n\t\t\trepository: string;\n\t\t\tnewPlanId: string;\n\t\t\tbypassManualBilling?: boolean;\n\t\t}) => {\n\t\t\treturn this.client.post(\n\t\t\t\t`/repository/changePlan?bypassManualBilling=${bypassManualBilling}`,\n\t\t\t\t{\n\t\t\t\t\tdomain: repository,\n\t\t\t\t\tnewPlan: newPlanId,\n\t\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t);\n\n\t/**\n\t * The function `addUserToRepository` adds a user corresponding to the email\n\t * to the given repository\n\t *\n\t * @param repository - The Repository name\n\t * @param email - The user email\n\t */\n\taddUserToRepository = this.assertTokenExist(\n\t\t({ repository, email }: { repository: string; email: string }) => {\n\t\t\treturn this.client.post(\"/repository/addUser\", {\n\t\t\t\tdomain: repository,\n\t\t\t\temail: email,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n\n\t/**\n\t * The function `removeUserFromRepository` removes a user corresponding to the\n\t * email from the given repository\n\t *\n\t * @param repository - The Repository name\n\t * @param email - The user email\n\t */\n\tremoveUserFromRepository = this.assertTokenExist(\n\t\t({ repository, email }: { repository: string; email: string }) => {\n\t\t\treturn this.client.post(\"/repository/removeUser\", {\n\t\t\t\tdomain: repository,\n\t\t\t\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ManageV2Client {
43
43
  private assertTokenExist;
44
44
  getBaseURL(): string;
45
45
  /**
46
- * The function `toggleRolePerLocal` enable or disable the role per local
47
- * feature
46
+ * The function `toggleRolePerLocal` enables or disables the RolesPerLocale
47
+ * workflow
48
48
  *
49
49
  * @param repository - The Repository name
50
50
  * @param enabled - The feature new status
@@ -53,6 +53,17 @@ export declare class ManageV2Client {
53
53
  repository: string;
54
54
  enabled: boolean;
55
55
  }) => Promise<AxiosResponse<any, any>>;
56
+ /**
57
+ * The function `toggleCustomRoles` enables or disables the CustomRoles
58
+ * workflow
59
+ *
60
+ * @param repository - The Repository name
61
+ * @param enabled - The feature new status
62
+ */
63
+ toggleCustomRoles: (params: {
64
+ repository: string;
65
+ enabled: boolean;
66
+ }) => Promise<AxiosResponse<any, any>>;
56
67
  /**
57
68
  * The function `changePlan` changes the plan of a repository the database
58
69
  *
@@ -18,8 +18,8 @@ class ManageV2Client {
18
18
  // Not private to have it available on tests
19
19
  __publicField(this, "token", null);
20
20
  /**
21
- * The function `toggleRolePerLocal` enable or disable the role per local
22
- * feature
21
+ * The function `toggleRolePerLocal` enables or disables the RolesPerLocale
22
+ * workflow
23
23
  *
24
24
  * @param repository - The Repository name
25
25
  * @param enabled - The feature new status
@@ -31,6 +31,20 @@ class ManageV2Client {
31
31
  author: ManageV2StaticAuthor
32
32
  });
33
33
  }));
34
+ /**
35
+ * The function `toggleCustomRoles` enables or disables the CustomRoles
36
+ * workflow
37
+ *
38
+ * @param repository - The Repository name
39
+ * @param enabled - The feature new status
40
+ */
41
+ __publicField(this, "toggleCustomRoles", this.assertTokenExist((params) => {
42
+ return this.client.post("/repository/toggleCustomRoles", {
43
+ domain: params.repository,
44
+ enabled: params.enabled,
45
+ author: ManageV2StaticAuthor
46
+ });
47
+ }));
34
48
  /**
35
49
  * The function `changePlan` changes the plan of a repository the database
36
50
  *
@@ -1 +1 @@
1
- {"version":3,"file":"manageV2.js","sources":["../../../src/clients/manageV2.ts"],"sourcesContent":["import axios, { AxiosInstance, AxiosResponse } from \"axios\";\nimport jwt from \"jsonwebtoken\";\n\nimport { ManageV2Config } from \"../types\";\n\nimport { extractCookie } from \"../utils/cookies\";\n\nconst ManageV2StaticAuthor = \"prismic-e2e-tests-utils\";\n\n/**\n * Client for interacting with ManageV2 routes to perform operations on\n * repositories.\n */\nexport class ManageV2Client {\n\treadonly client: AxiosInstance; // Not private to have it available on tests\n\tprivate token: string | null = null;\n\n\t/**\n\t * @param baseURL - The base URL of the Wroom app. ex: https://prismic.io\n\t * @param config - ManageV2 configuration variable to call ManageV2.\n\t */\n\tconstructor(baseUrl: string, config?: ManageV2Config | undefined) {\n\t\tthis.token = config ? this.generateToken(config) : null;\n\n\t\tthis.client = axios.create({\n\t\t\tbaseURL: `${baseUrl}/manageroutes/`,\n\t\t\twithCredentials: true,\n\t\t\tvalidateStatus: () => true,\n\t\t\theaders: {\n\t\t\t\t\"User-Agent\": \"prismic-cli/prismic-e2e-tests-utils\",\n\t\t\t\tAuthorization: `Bearer ${this.token}`,\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\t/**\n\t * The function generates a JWT token using the provided configuration\n\t * parameters.\n\t *\n\t * @param {ManageV2Config} config - The `config` parameter in the\n\t * `generateToken` function is of type `ManageV2Config`. It contains the\n\t * following properties:\n\t *\n\t * @returns A JSON Web Token (JWT) is being returned by the `generateToken`\n\t * function. The token is signed using the provided `config.secret` with the\n\t * HS256 algorithm and includes the specified audience and issuer values.\n\t */\n\tprivate generateToken(config: ManageV2Config): string {\n\t\treturn jwt.sign({}, config.secret, {\n\t\t\talgorithm: \"HS256\",\n\t\t\taudience: config.audience,\n\t\t\tissuer: \"prismic.io\",\n\t\t});\n\t}\n\n\t/**\n\t * The function `assertTokenExist` checks if a token exists before executing a\n\t * given function.\n\t *\n\t * @param f - The `assertTokenExist` function takes a function `f` as a\n\t * parameter. This function `f` should accept a parameter of type\n\t * `Parameters` and return a Promise that resolves to an AxiosResponse. The\n\t * `assertTokenExist` function ensures that a token is not null before\n\t * calling the provided\n\t *\n\t * @returns A function is being returned that takes a parameter of type\n\t * Parameters and checks if the token is null. If the token is null, an\n\t * error is thrown. Otherwise, the function f is called with the provided\n\t * parameters.\n\t */\n\tprivate assertTokenExist<Parameters>(\n\t\tf: (_: Parameters) => Promise<AxiosResponse>,\n\t) {\n\t\treturn (params: Parameters) => {\n\t\t\tif (this.token === null) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Undefined configuration for ManageV2 while trying to use it's routes\",\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\treturn f(params);\n\t\t\t}\n\t\t};\n\t}\n\n\tgetBaseURL(): string {\n\t\treturn this.client.getUri();\n\t}\n\n\t/**\n\t * The function `toggleRolePerLocal` enable or disable the role per local\n\t * feature\n\t *\n\t * @param repository - The Repository name\n\t * @param enabled - The feature new status\n\t */\n\ttoggleRolePerLocal = this.assertTokenExist(\n\t\t(params: { repository: string; enabled: boolean }) => {\n\t\t\treturn this.client.post(\"/repository/toggleRolesPerLocale\", {\n\t\t\t\tdomain: params.repository,\n\t\t\t\tenabled: params.enabled,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n\n\t/**\n\t * The function `changePlan` changes the plan of a repository the database\n\t *\n\t * @param repository - The Repository name\n\t * @param newPlanId - The new planId\n\t * @param bypassManualBilling - Beware that using this will not verify that\n\t * the database and Stripe are in sync\n\t */\n\tchangePlan = this.assertTokenExist(\n\t\t({\n\t\t\trepository,\n\t\t\tnewPlanId,\n\t\t\tbypassManualBilling = false,\n\t\t}: {\n\t\t\trepository: string;\n\t\t\tnewPlanId: string;\n\t\t\tbypassManualBilling?: boolean;\n\t\t}) => {\n\t\t\treturn this.client.post(\n\t\t\t\t`/repository/changePlan?bypassManualBilling=${bypassManualBilling}`,\n\t\t\t\t{\n\t\t\t\t\tdomain: repository,\n\t\t\t\t\tnewPlan: newPlanId,\n\t\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t);\n\n\t/**\n\t * The function `addUserToRepository` adds a user corresponding to the email\n\t * to the given repository\n\t *\n\t * @param repository - The Repository name\n\t * @param email - The user email\n\t */\n\taddUserToRepository = this.assertTokenExist(\n\t\t({ repository, email }: { repository: string; email: string }) => {\n\t\t\treturn this.client.post(\"/repository/addUser\", {\n\t\t\t\tdomain: repository,\n\t\t\t\temail: email,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n\n\t/**\n\t * The function `removeUserFromRepository` removes a user corresponding to the\n\t * email from the given repository\n\t *\n\t * @param repository - The Repository name\n\t * @param email - The user email\n\t */\n\tremoveUserFromRepository = this.assertTokenExist(\n\t\t({ repository, email }: { repository: string; email: string }) => {\n\t\t\treturn this.client.post(\"/repository/removeUser\", {\n\t\t\t\tdomain: repository,\n\t\t\t\temail: email,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n}\n"],"names":[],"mappings":";;;;;;;;;AAOA,MAAM,uBAAuB;MAMhB,eAAc;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ1B,YAAY,SAAiB,QAAmC;AAPvD;AACD;AAAA,iCAAuB;AA0F/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8CAAqB,KAAK,iBACzB,CAAC,WAAoD;AAC7C,aAAA,KAAK,OAAO,KAAK,oCAAoC;AAAA,QAC3D,QAAQ,OAAO;AAAA,QACf,SAAS,OAAO;AAAA,QAChB,QAAQ;AAAA,MAAA,CACR;AAAA,IAAA,CACD;AAWF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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3C,WAAO,IAAI,KAAK,IAAI,OAAO,QAAQ;AAAA,MAClC,WAAW;AAAA,MACX,UAAU,OAAO;AAAA,MACjB,QAAQ;AAAA,IAAA,CACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBQ,iBACP,GAA4C;AAE5C,WAAO,CAAC,WAAsB;AACzB,UAAA,KAAK,UAAU,MAAM;AAClB,cAAA,IAAI,MACT,sEAAsE;AAAA,MAAA,OAEjE;AACN,eAAO,EAAE,MAAM;AAAA,MAChB;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,aAAU;AACF,WAAA,KAAK,OAAO;EACpB;AAiFA;"}
1
+ {"version":3,"file":"manageV2.js","sources":["../../../src/clients/manageV2.ts"],"sourcesContent":["import axios, { AxiosInstance, AxiosResponse } from \"axios\";\nimport jwt from \"jsonwebtoken\";\n\nimport { ManageV2Config } from \"../types\";\n\nimport { extractCookie } from \"../utils/cookies\";\n\nconst ManageV2StaticAuthor = \"prismic-e2e-tests-utils\";\n\n/**\n * Client for interacting with ManageV2 routes to perform operations on\n * repositories.\n */\nexport class ManageV2Client {\n\treadonly client: AxiosInstance; // Not private to have it available on tests\n\tprivate token: string | null = null;\n\n\t/**\n\t * @param baseURL - The base URL of the Wroom app. ex: https://prismic.io\n\t * @param config - ManageV2 configuration variable to call ManageV2.\n\t */\n\tconstructor(baseUrl: string, config?: ManageV2Config | undefined) {\n\t\tthis.token = config ? this.generateToken(config) : null;\n\n\t\tthis.client = axios.create({\n\t\t\tbaseURL: `${baseUrl}/manageroutes/`,\n\t\t\twithCredentials: true,\n\t\t\tvalidateStatus: () => true,\n\t\t\theaders: {\n\t\t\t\t\"User-Agent\": \"prismic-cli/prismic-e2e-tests-utils\",\n\t\t\t\tAuthorization: `Bearer ${this.token}`,\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\t/**\n\t * The function generates a JWT token using the provided configuration\n\t * parameters.\n\t *\n\t * @param {ManageV2Config} config - The `config` parameter in the\n\t * `generateToken` function is of type `ManageV2Config`. It contains the\n\t * following properties:\n\t *\n\t * @returns A JSON Web Token (JWT) is being returned by the `generateToken`\n\t * function. The token is signed using the provided `config.secret` with the\n\t * HS256 algorithm and includes the specified audience and issuer values.\n\t */\n\tprivate generateToken(config: ManageV2Config): string {\n\t\treturn jwt.sign({}, config.secret, {\n\t\t\talgorithm: \"HS256\",\n\t\t\taudience: config.audience,\n\t\t\tissuer: \"prismic.io\",\n\t\t});\n\t}\n\n\t/**\n\t * The function `assertTokenExist` checks if a token exists before executing a\n\t * given function.\n\t *\n\t * @param f - The `assertTokenExist` function takes a function `f` as a\n\t * parameter. This function `f` should accept a parameter of type\n\t * `Parameters` and return a Promise that resolves to an AxiosResponse. The\n\t * `assertTokenExist` function ensures that a token is not null before\n\t * calling the provided\n\t *\n\t * @returns A function is being returned that takes a parameter of type\n\t * Parameters and checks if the token is null. If the token is null, an\n\t * error is thrown. Otherwise, the function f is called with the provided\n\t * parameters.\n\t */\n\tprivate assertTokenExist<Parameters>(\n\t\tf: (_: Parameters) => Promise<AxiosResponse>,\n\t) {\n\t\treturn (params: Parameters) => {\n\t\t\tif (this.token === null) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Undefined configuration for ManageV2 while trying to use it's routes\",\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\treturn f(params);\n\t\t\t}\n\t\t};\n\t}\n\n\tgetBaseURL(): string {\n\t\treturn this.client.getUri();\n\t}\n\n\t/**\n\t * The function `toggleRolePerLocal` enables or disables the RolesPerLocale\n\t * workflow\n\t *\n\t * @param repository - The Repository name\n\t * @param enabled - The feature new status\n\t */\n\ttoggleRolePerLocal = this.assertTokenExist(\n\t\t(params: { repository: string; enabled: boolean }) => {\n\t\t\treturn this.client.post(\"/repository/toggleRolesPerLocale\", {\n\t\t\t\tdomain: params.repository,\n\t\t\t\tenabled: params.enabled,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n\n\t/**\n\t * The function `toggleCustomRoles` enables or disables the CustomRoles\n\t * workflow\n\t *\n\t * @param repository - The Repository name\n\t * @param enabled - The feature new status\n\t */\n\ttoggleCustomRoles = this.assertTokenExist(\n\t\t(params: { repository: string; enabled: boolean }) => {\n\t\t\treturn this.client.post(\"/repository/toggleCustomRoles\", {\n\t\t\t\tdomain: params.repository,\n\t\t\t\tenabled: params.enabled,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n\n\t/**\n\t * The function `changePlan` changes the plan of a repository the database\n\t *\n\t * @param repository - The Repository name\n\t * @param newPlanId - The new planId\n\t * @param bypassManualBilling - Beware that using this will not verify that\n\t * the database and Stripe are in sync\n\t */\n\tchangePlan = this.assertTokenExist(\n\t\t({\n\t\t\trepository,\n\t\t\tnewPlanId,\n\t\t\tbypassManualBilling = false,\n\t\t}: {\n\t\t\trepository: string;\n\t\t\tnewPlanId: string;\n\t\t\tbypassManualBilling?: boolean;\n\t\t}) => {\n\t\t\treturn this.client.post(\n\t\t\t\t`/repository/changePlan?bypassManualBilling=${bypassManualBilling}`,\n\t\t\t\t{\n\t\t\t\t\tdomain: repository,\n\t\t\t\t\tnewPlan: newPlanId,\n\t\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t);\n\n\t/**\n\t * The function `addUserToRepository` adds a user corresponding to the email\n\t * to the given repository\n\t *\n\t * @param repository - The Repository name\n\t * @param email - The user email\n\t */\n\taddUserToRepository = this.assertTokenExist(\n\t\t({ repository, email }: { repository: string; email: string }) => {\n\t\t\treturn this.client.post(\"/repository/addUser\", {\n\t\t\t\tdomain: repository,\n\t\t\t\temail: email,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n\n\t/**\n\t * The function `removeUserFromRepository` removes a user corresponding to the\n\t * email from the given repository\n\t *\n\t * @param repository - The Repository name\n\t * @param email - The user email\n\t */\n\tremoveUserFromRepository = this.assertTokenExist(\n\t\t({ repository, email }: { repository: string; email: string }) => {\n\t\t\treturn this.client.post(\"/repository/removeUser\", {\n\t\t\t\tdomain: repository,\n\t\t\t\temail: email,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n}\n"],"names":[],"mappings":";;;;;;;;;AAOA,MAAM,uBAAuB;MAMhB,eAAc;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ1B,YAAY,SAAiB,QAAmC;AAPvD;AACD;AAAA,iCAAuB;AA0F/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8CAAqB,KAAK,iBACzB,CAAC,WAAoD;AAC7C,aAAA,KAAK,OAAO,KAAK,oCAAoC;AAAA,QAC3D,QAAQ,OAAO;AAAA,QACf,SAAS,OAAO;AAAA,QAChB,QAAQ;AAAA,MAAA,CACR;AAAA,IAAA,CACD;AAUF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6CAAoB,KAAK,iBACxB,CAAC,WAAoD;AAC7C,aAAA,KAAK,OAAO,KAAK,iCAAiC;AAAA,QACxD,QAAQ,OAAO;AAAA,QACf,SAAS,OAAO;AAAA,QAChB,QAAQ;AAAA,MAAA,CACR;AAAA,IAAA,CACD;AAWF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAAa,KAAK,iBACjB,CAAC,EACA,YACA,WACA,sBAAsB,YAKlB;AACJ,aAAO,KAAK,OAAO,KAClB,8CAA8C,mBAAmB,IACjE;AAAA,QACC,QAAQ;AAAA,QACR,S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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBQ,iBACP,GAA4C;AAE5C,WAAO,CAAC,WAAsB;AACzB,UAAA,KAAK,UAAU,MAAM;AAClB,cAAA,IAAI,MACT,sEAAsE;AAAA,MAAA,OAEjE;AACN,eAAO,EAAE,MAAM;AAAA,MAChB;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,aAAU;AACF,WAAA,KAAK,OAAO;EACpB;AAkGA;"}
@@ -84,7 +84,7 @@ class RepositoriesManager {
84
84
  const repositoryName = `${prefix}-${random.randomString()}`;
85
85
  const response = await this.wroomClient.post(null, "authentication/newrepository", {
86
86
  domain: repositoryName,
87
- framework: "next",
87
+ framework: "vue",
88
88
  plan: "personal",
89
89
  isAnnual: "false",
90
90
  role: "developer"
@@ -1 +1 @@
1
- {"version":3,"file":"repositories.cjs","sources":["../../../src/managers/repositories.ts"],"sourcesContent":["import { SetupConfiguration, UrlConfig } from \"../types\";\n\nimport { AssetApiClient } from \"../clients/assetApi\";\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\tcluster: configuration.cluster,\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\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\n\t\t// This logic specific to staging environment allow us to target a specific version of the custom types API.\n\t\t// This is only works for unify-exp at the moment.\n\t\t// Having this logic here avoids duplicating it across different CI workflows.\n\t\tthis.config.urlConfig.customTypesApi =\n\t\t\tconfiguration.environment === \"stage\" &&\n\t\t\tconfiguration.cluster === \"unify-exp\"\n\t\t\t\t? `https://customtypes.wroom.io/${configuration.cluster}/`\n\t\t\t\t: this.config.urlConfig.customTypesApi;\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\tassetApi: `${protocol}://asset-api.${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: \"next\",\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\t\tconst assetApiClient = new AssetApiClient(urlConfig.assetApi, {\n\t\t\tauthToken,\n\t\t\trepository,\n\t\t});\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\tassetApiClient,\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","AssetApiClient","RepositoryManager"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6Ba,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,MACH,SAAS,cAAc;AAAA;AAAA,MAEvB,WACC,OAAO,cAAc,cAAc,WAChC,KAAK,UAAU,cAAc,SAAS,IACtC,cAAc;AAAA,IAAA;AAGnB,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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AA,MAAA,YACAJ;AAAAA,IAAA,CACA,IACA;AACH,UAAM,iBAAiB,IAAIK,wBAAe,UAAU,UAAU;AAAA,MAC7D;AAAA,MAAA,YACAL;AAAAA,IAAA,CACA;AAED,WAAO,IAAIM,WAAAA,kBACVN,cACA,eACA,KAAK,YACL,KAAK,aACL,kBACA,oBACA,gBACA,KAAK,cAAc;AAAA,EAErB;AACA;;;"}
1
+ {"version":3,"file":"repositories.cjs","sources":["../../../src/managers/repositories.ts"],"sourcesContent":["import { SetupConfiguration, UrlConfig } from \"../types\";\n\nimport { AssetApiClient } from \"../clients/assetApi\";\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\tcluster: configuration.cluster,\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\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\n\t\t// This logic specific to staging environment allow us to target a specific version of the custom types API.\n\t\t// This is only works for unify-exp at the moment.\n\t\t// Having this logic here avoids duplicating it across different CI workflows.\n\t\tthis.config.urlConfig.customTypesApi =\n\t\t\tconfiguration.environment === \"stage\" &&\n\t\t\tconfiguration.cluster === \"unify-exp\"\n\t\t\t\t? `https://customtypes.wroom.io/${configuration.cluster}/`\n\t\t\t\t: this.config.urlConfig.customTypesApi;\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\tassetApi: `${protocol}://asset-api.${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\t\tconst assetApiClient = new AssetApiClient(urlConfig.assetApi, {\n\t\t\tauthToken,\n\t\t\trepository,\n\t\t});\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\tassetApiClient,\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","AssetApiClient","RepositoryManager"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6Ba,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,MACH,SAAS,cAAc;AAAA;AAAA,MAEvB,WACC,OAAO,cAAc,cAAc,WAChC,KAAK,UAAU,cAAc,SAAS,IACtC,cAAc;AAAA,IAAA;AAGnB,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;AAM3B,SAAK,OAAO,UAAU,iBACrB,cAAc,gBAAgB,WAC9B,cAAc,YAAY,cACvB,gCAAgC,cAAc,OAAO,MACrD,KAAK,OAAO,UAAU;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,UAAU,SAAe;AAC1B,UAAA,MAAM,IAAI,IAAI,OAAO;AAC3B,UAAM,WAAW,IAAI,SAAS,MAAM,G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ager {
82
82
  const repositoryName = `${prefix}-${randomString()}`;
83
83
  const response = await this.wroomClient.post(null, "authentication/newrepository", {
84
84
  domain: repositoryName,
85
- framework: "next",
85
+ framework: "vue",
86
86
  plan: "personal",
87
87
  isAnnual: "false",
88
88
  role: "developer"
@@ -1 +1 @@
1
- {"version":3,"file":"repositories.js","sources":["../../../src/managers/repositories.ts"],"sourcesContent":["import { SetupConfiguration, UrlConfig } from \"../types\";\n\nimport { AssetApiClient } from \"../clients/assetApi\";\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\tcluster: configuration.cluster,\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\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\n\t\t// This logic specific to staging environment allow us to target a specific version of the custom types API.\n\t\t// This is only works for unify-exp at the moment.\n\t\t// Having this logic here avoids duplicating it across different CI workflows.\n\t\tthis.config.urlConfig.customTypesApi =\n\t\t\tconfiguration.environment === \"stage\" &&\n\t\t\tconfiguration.cluster === \"unify-exp\"\n\t\t\t\t? `https://customtypes.wroom.io/${configuration.cluster}/`\n\t\t\t\t: this.config.urlConfig.customTypesApi;\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\tassetApi: `${protocol}://asset-api.${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: \"next\",\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\t\tconst assetApiClient = new AssetApiClient(urlConfig.assetApi, {\n\t\t\tauthToken,\n\t\t\trepository,\n\t\t});\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\tcustom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C5D;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;AACH,UAAM,iBAAiB,IAAI,eAAe,UAAU,UAAU;AAAA,MAC7D;AAAA,MACA;AAAA,IAAA,CACA;AAED,WAAO,IAAI,kBACV,YACA,eACA,KAAK,YACL,KAAK,aACL,kBACA,oBACA,gBACA,KAAK,cAAc;AAAA,EAErB;AACA;"}
1
+ {"version":3,"file":"repositories.js","sources":["../../../src/managers/repositories.ts"],"sourcesContent":["import { SetupConfiguration, UrlConfig } from \"../types\";\n\nimport { AssetApiClient } from \"../clients/assetApi\";\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\tcluster: configuration.cluster,\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\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\n\t\t// This logic specific to staging environment allow us to target a specific version of the custom types API.\n\t\t// This is only works for unify-exp at the moment.\n\t\t// Having this logic here avoids duplicating it across different CI workflows.\n\t\tthis.config.urlConfig.customTypesApi =\n\t\t\tconfiguration.environment === \"stage\" &&\n\t\t\tconfiguration.cluster === \"unify-exp\"\n\t\t\t\t? `https://customtypes.wroom.io/${configuration.cluster}/`\n\t\t\t\t: this.config.urlConfig.customTypesApi;\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\tassetApi: `${protocol}://asset-api.${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\t\tconst assetApiClient = new AssetApiClient(urlConfig.assetApi, {\n\t\t\tauthToken,\n\t\t\trepository,\n\t\t});\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\tassetApiClient,\n\t\t\tthis.manageV2Client,\n\t\t);\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA6Ba,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,MACH,SAAS,cAAc;AAAA;AAAA,MAEvB,WACC,OAAO,cAAc,cAAc,WAChC,KAAK,UAAU,cAAc,SAAS,IACtC,cAAc;AAAA,IAAA;AAGnB,SAAK,cAAc,IAAI,YACtB,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AM,gBAAgB,IAAI,cAAc,YAAY,SAAS;AAC7D,UAAM,qBAAqB,UAAU,eAClC,IAAI,mBAAmB,UAAU,cAAc;AAAA,MAC/C;AAAA,MACA;AAAA,IAAA,CACA,IACA;AACH,UAAM,iBAAiB,IAAI,eAAe,UAAU,UAAU;AAAA,MAC7D;AAAA,MACA;AAAA,IAAA,CACA;AAED,WAAO,IAAI,kBACV,YACA,eACA,KAAK,YACL,KAAK,aACL,kBACA,oBACA,gBACA,KAAK,cAAc;AAAA,EAErB;AACA;"}
@@ -72,6 +72,9 @@ class RepositoryManager {
72
72
  if (config.rolePerLocal) {
73
73
  await this.toggleRolePerLocal(true);
74
74
  }
75
+ if (config.customRoles) {
76
+ await this.toggleCustomRoles(true);
77
+ }
75
78
  }
76
79
  /** @returns the repository base url, like https://my-repo.prismic.io */
77
80
  getBaseURL() {
@@ -340,7 +343,7 @@ class RepositoryManager {
340
343
  return token;
341
344
  }
342
345
  /**
343
- * Toggle the Role per local feature
346
+ * Toggle the Role per Locale workflow
344
347
  *
345
348
  * @param enabled - The feature new status
346
349
  */
@@ -355,6 +358,22 @@ class RepositoryManager {
355
358
  message: `Role per local ${enabled ? "enabled" : "disabled"}`
356
359
  });
357
360
  }
361
+ /**
362
+ * Toggle the Custom Roles workflow
363
+ *
364
+ * @param enabled - The feature new status
365
+ */
366
+ async toggleCustomRoles(enabled) {
367
+ const profiler = log.logger.startTimer();
368
+ const response = await this.manageV2Client.toggleCustomRoles({
369
+ repository: this.name,
370
+ enabled
371
+ });
372
+ this.failIfNot200(response, `Could not ${enabled ? "enable" : "disable"} Custom Roles for ${this.name}`);
373
+ profiler.done({
374
+ message: `Custom Roles ${enabled ? "enabled" : "disabled"}`
375
+ });
376
+ }
358
377
  /**
359
378
  * Change the Repository Plan
360
379
  *
@@ -1 +1 @@
1
- {"version":3,"file":"repository.cjs","sources":["../../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\";\nimport { AxiosResponse } from \"axios\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { AssetApiClient } from \"../clients/assetApi\";\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\";\nimport { ContentApiClient } from \"../clients/contentApi\";\nimport {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n} from \"../clients/coreApi\";\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\";\nimport { ManageV2Client } from \"../clients/manageV2\";\nimport { MigrationApiClient } from \"../clients/migrationApi\";\nimport { WroomClient } from \"../clients/wroom\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\n/** Utility to manage test data for a Prismic repository */\nexport class RepositoryManager {\n\tconstructor(\n\t\treadonly name: string,\n\t\tprivate readonly coreApiClient: CoreApiClient,\n\t\tprivate readonly authApiClient: AuthenticationApiClient,\n\t\tprivate readonly wroomClient: WroomClient,\n\t\tprivate readonly customTypesApiClient: CustomTypesApiClient,\n\t\tprivate readonly migrationApiClient: MigrationApiClient | undefined,\n\t\tprivate readonly assetApiClient: AssetApiClient,\n\t\tprivate readonly manageV2Client: ManageV2Client,\n\t) {}\n\n\tasync configure(config: RepositoryConfig): Promise<void> {\n\t\tconst hasLangConfig =\n\t\t\tconfig.defaultLocale || config.locales || config.customLocale;\n\t\tif (hasLangConfig) {\n\t\t\tconst languages = await this.coreApiClient.getLanguages();\n\t\t\tlet updateDefaultLocaleAtTheEnd = false;\n\t\t\t// if no locale exists on repo, the master locale needs to be set first\n\t\t\tif (config.defaultLocale) {\n\t\t\t\tconst master = languages.find(({ is_master }) => is_master === true);\n\t\t\t\tif (!master) {\n\t\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"create\");\n\t\t\t\t} else if (master.id !== config.defaultLocale) {\n\t\t\t\t\t// update the master lang at the end, after it is created.\n\t\t\t\t\tupdateDefaultLocaleAtTheEnd = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.locales) {\n\t\t\t\t// No need to add default locale and already existing languages\n\t\t\t\tconst localesToAdd = config.locales.filter(\n\t\t\t\t\t(id) => !languages.some((language) => language.id === id),\n\t\t\t\t);\n\t\t\t\tif (localesToAdd.length > 0) {\n\t\t\t\t\tawait this.createLocales(localesToAdd);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.customLocale) {\n\t\t\t\tif (!languages.find(({ id }) => id === config.customLocale?.lang.id)) {\n\t\t\t\t\tawait this.createCustomLocale(config.customLocale);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.defaultLocale && updateDefaultLocaleAtTheEnd) {\n\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"update\");\n\t\t\t}\n\t\t}\n\n\t\tif (config.slices) {\n\t\t\tawait this.createSlices(config.slices);\n\t\t}\n\n\t\tif (config.customTypes) {\n\t\t\tawait this.createCustomTypes(config.customTypes);\n\t\t}\n\n\t\tif (config.preview) {\n\t\t\tawait this.createPreview(config.preview);\n\t\t}\n\n\t\tif (config.rolePerLocal) {\n\t\t\tawait this.toggleRolePerLocal(true);\n\t\t}\n\t}\n\n\t/** @returns the repository base url, like https://my-repo.prismic.io */\n\tgetBaseURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), this.name);\n\t}\n\n\t/** @returns the repository base cdn url, like https://my-repo.cdn.prismic.io */\n\tgetBaseCdnURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), `${this.name}.cdn`);\n\t}\n\n\t/**\n\t * @returns a Content Type api client configured to target the repository CDN\n\t * url. Uses Playwright for requests so if your project uses Playwright too,\n\t * any network request will be present in Playwright test reports.\n\t */\n\tgetContentApiClient(config?: {\n\t\tversion?: \"v1\" | \"v2\";\n\t\taccessToken?: string;\n\t}): ContentApiClient {\n\t\treturn new ContentApiClient(this.getBaseCdnURL(), config);\n\t}\n\n\t/**\n\t * @returns an instance of the Migration api client, see\n\t * https://prismic.io/docs/migration-api-technical-reference\n\t */\n\tgetMigrationApiClient(): MigrationApiClient {\n\t\tif (!this.migrationApiClient) {\n\t\t\tthrow \"No client found for the migration api. Did you provide a migration api url in the configuration?\";\n\t\t}\n\n\t\treturn this.migrationApiClient;\n\t}\n\n\t/**\n\t * @returns an instance of the Asset api client, see\n\t * https://prismic.io/docs/asset-api-technical-reference\n\t */\n\tgetAssetApiClient(): AssetApiClient {\n\t\treturn this.assetApiClient;\n\t}\n\n\t/** @returns the Wroom commit hash deployed on the current repository */\n\tasync getDeployedVersion(): Promise<string | undefined> {\n\t\tconst response = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"underground/834b34f16f451e00f268dd5c8c81d16e3c020275\",\n\t\t);\n\n\t\t// Somehow axios directly parses the text response `Prismic version: <commit hash> into a version attribute\n\t\treturn response.data.version;\n\t}\n\n\t/**\n\t * Set additional standard locales for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locales - An array of all locales to be added to the repository.\n\t *\n\t * @throws Error if setting the locales fails.\n\t */\n\tasync createLocales(locales: string[]): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages\",\n\t\t\t{ languages: locales },\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t(data as string).includes(\"already existing languages\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add locales ${locales.join(\", \")}`);\n\t\t}\n\t\tprofiler.done({ message: `locales '${locales}' created` });\n\t}\n\n\t/**\n\t * Set additional custom locale for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locale - The locale to be added to the repository.\n\t *\n\t * @throws Error if setting the locale fails.\n\t */\n\tasync createCustomLocale(locale: CustomLocale): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages/custom\",\n\t\t\tlocale,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 && JSON.stringify(data).includes(\"code is already used\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not create custom locale ${locale}`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `custom locale ${JSON.stringify(locale)} created`,\n\t\t});\n\t}\n\n\tprivate failIfNot200(response: AxiosResponse, msg: string) {\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(msg);\n\t\t}\n\t}\n\n\t/**\n\t * Delete a locale from a repository.\n\t *\n\t * @param locale - locale to remove from the repository configuration.\n\t *\n\t * @throws Error if deleting the locale fails.\n\t */\n\tasync deleteLocale(locale: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/multilanguages/${locale}/delete`,\n\t\t);\n\t\tthis.failIfNot200(response, `Could not delete locale ${locale}`);\n\t\tprofiler.done({ message: `locale '${locale}' deleted` });\n\t}\n\n\t/**\n\t * Create or update the default (master) locale for a repository in Wroom, the\n\t * locale needs to exist in the repository.\n\t *\n\t * @param locale - The locale to be set as the default.\n\t * @param endpoint - \"createMasterLang\" to create it, \"defineAsMaster\" to\n\t * update it.\n\t *\n\t * @throws Error if setting the default locale fails.\n\t */\n\tasync setDefaultLocale(\n\t\tlocale: string,\n\t\taction: \"create\" | \"update\",\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst endpoint = {\n\t\t\tcreate: \"createMasterLang\",\n\t\t\tupdate: \"defineAsMaster\",\n\t\t};\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`/app/settings/multilanguages/${locale}/${endpoint[action]}`,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t// returns 400 if master lang is already set\n\t\t\t\tJSON.stringify(data).includes(\"Unable to set as master language\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not set default locale to ${locale}`);\n\t\t}\n\t\tprofiler.done({ message: `default locale set to '${locale}'` });\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\n\t *\n\t * @returns A Promise that resolves when the release is created.\n\t */\n\tasync createRelease(label: string): Promise<{ id: string }> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(this.name, \"app/releases\", {\n\t\t\tlabel,\n\t\t});\n\t\tthis.failIfNot200(response, `Could not create release ${label}`);\n\t\tprofiler.done({ message: `release '${label}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\n\t * @param repository - The name of the repository.\n\t * @param id - The ID of the release to be deleted.\n\t */\n\tasync deleteRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/releases/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete release with id ${id}`);\n\t\tprofiler.done({ message: `release '${id}' deleted` });\n\t}\n\n\t/**\n\t * Creates a preview for a repository.\n\t *\n\t * @param data - The data for creating the preview.\n\t */\n\tasync createPreview(data: Preview): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/new`,\n\t\t\tdata,\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not create preview ${data.name}`);\n\t\tprofiler.done({ message: `preview '${data.name}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a preview from a repository.\n\t *\n\t * @param id - The ID of the preview to be deleted.\n\t */\n\tasync deletePreview(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/delete/${id}`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete preview with id ${id}`);\n\t\tprofiler.done({ message: `preview '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create a webhook.\n\t *\n\t * @returns A Promise that resolves with the webhook id.\n\t */\n\tasync createWebhook(\n\t\tname: string,\n\t\turl: string,\n\t\tsecret: string,\n\t\ttriggers: {\n\t\t\tdocumentsPublished?: boolean;\n\t\t\tdocumentsUnpublished?: boolean;\n\t\t\treleasesCreated?: boolean;\n\t\t\treleasesUpdated?: boolean;\n\t\t\ttagsCreated?: boolean;\n\t\t\ttagsDeleted?: boolean;\n\t\t},\n\t\tactive: boolean,\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/webhooks/create\",\n\t\t\t{\n\t\t\t\tname,\n\t\t\t\turl,\n\t\t\t\tsecret,\n\t\t\t\tactive: active ? \"on\" : \"off\",\n\t\t\t\t...triggers,\n\t\t\t},\n\t\t);\n\t\tthis.failIfNot200(response, `Could not create webhook ${name}`);\n\t\tprofiler.done({ message: `webhook '${name}' created` });\n\n\t\treturn response.data.created;\n\t}\n\n\t/**\n\t * Deletes a webhook.\n\t *\n\t * @param id - The webhook ID.\n\t */\n\tasync deleteWebhook(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/webhooks/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete webhook with id ${id}`);\n\t\tprofiler.done({ message: `webhook '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes -\n\t */\n\tasync createCustomTypes(customTypes: CustomType[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes);\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices -\n\t */\n\tasync createSlices(slices: SharedSlice[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createSlices(slices);\n\t}\n\n\t/**\n\t * Create an access token to query private items of the Content api.\n\t *\n\t * @param appName - mandatory authorized application name\n\t * @param tokenScope - access token scope. Use \"master\" to when your content\n\t * api is fully private or \"master+releases\" to access private releases\n\t */\n\tasync createContentAPIToken(\n\t\tappName: string,\n\t\ttokenScope: \"master\" | \"master+releases\" = \"master\",\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\t\ttype AuthorizedAppResponse = {\n\t\t\tid: string;\n\t\t\tname: string;\n\t\t\twroom_auths: { token: string; scope: \"master\" | \"master+releases\" }[];\n\t\t};\n\t\tconst existingApps: AxiosResponse<AuthorizedAppResponse[]> =\n\t\t\tawait this.wroomClient.get(this.name, \"settings/security/contentapi\");\n\n\t\tthis.failIfNot200(\n\t\t\texistingApps,\n\t\t\t`Could not get status of existing applications to generate a content api token`,\n\t\t);\n\t\tlet app = existingApps.data.find(({ name, wroom_auths }) => {\n\t\t\treturn name === appName && wroom_auths.length > 0;\n\t\t});\n\n\t\tif (!app) {\n\t\t\tconst response: AxiosResponse<AuthorizedAppResponse> =\n\t\t\t\tawait this.wroomClient.post(this.name, \"settings/security/oauthapp\", {\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t});\n\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api app ${appName}`,\n\t\t\t);\n\t\t\tapp = response.data;\n\t\t}\n\n\t\tlet tokenInfo = app.wroom_auths.find(({ scope }) => scope === tokenScope);\n\t\tif (!tokenInfo) {\n\t\t\tconst response = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/authorizations\",\n\t\t\t\t{\n\t\t\t\t\tapp: app.id,\n\t\t\t\t\tscope: tokenScope,\n\t\t\t\t},\n\t\t\t);\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api access token for app ${appName} with scope ${tokenScope}`,\n\t\t\t);\n\t\t\ttokenInfo = response.data;\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `content api access token for app '${appName}' created`,\n\t\t});\n\n\t\tif (!tokenInfo?.token) {\n\t\t\tthrow `Could not create content api access token for app ${appName} with scope ${tokenScope}`;\n\t\t}\n\n\t\treturn tokenInfo.token;\n\t}\n\n\t/** Create a permanent access token to authenticate to Prismic public apis. */\n\tasync createPermanentAccessToken(): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst token = await this.authApiClient.getMachine2MachineToken(this.name);\n\n\t\tprofiler.done({\n\t\t\tmessage: `machine2machine token created`,\n\t\t});\n\n\t\treturn token;\n\t}\n\n\t/**\n\t * Toggle the Role per local feature\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleRolePerLocal(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.toggleRolePerLocal({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Role per local for ${\n\t\t\t\tthis.name\n\t\t\t}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Role per local ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t});\n\t}\n\n\t/**\n\t * Change the Repository Plan\n\t *\n\t * @param {string} newPlanId - The Id of the new Plan to apply\n\t */\n\tasync changePlan(newPlanId: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.changePlan({\n\t\t\trepository: this.name,\n\t\t\tnewPlanId: newPlanId,\n\t\t\tbypassManualBilling: true, // For now the library does not support Stripe features\n\t\t});\n\n\t\tthis.failIfNot200(response, \"Could not change the Repository Plan\");\n\t\tprofiler.done({\n\t\t\tmessage: `Repository Plan changed to ${newPlanId}`,\n\t\t});\n\t}\n\n\t/**\n\t * Add a new user to the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync addUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.addUserToRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 409 &&\n\t\t\t\tJSON.stringify(data).includes(\"already a member of the repo\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add a new user ${email} to the repository`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was added to the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Remove a user from the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync removeUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.removeUserFromRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not remove the user ${email} from the repository`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was removed from the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Update the role of a user in a repository\n\t *\n\t * @param {string} email - The email of the user\n\t * @param {string | Record<string, string>} role - The new Role of the user,\n\t * either a string for basic workflow or an object such as `{ \"lang_id\":\n\t * \"Writer\" }`\n\t *\n\t * Example of roles are\n\t *\n\t * - Administrator\n\t * - Writer\n\t * - Contributor\n\t * - Manager (publisher)\n\t */\n\tasync updateUserRole(\n\t\temail: string,\n\t\trole: string | Record<string, string>,\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response =\n\t\t\ttypeof role === \"string\"\n\t\t\t\t? await this.wroomClient.updateRole(this.name, email, role)\n\t\t\t\t: await this.wroomClient.updateRolePerLocal(this.name, email, role);\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not update the ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} of the user ${email}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Updated User's ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} for user ${email}`,\n\t\t});\n\t}\n\n\t/**\n\t * Creates a document using the core api. If the Core api format is too\n\t * specific, use the migration api client to create a document with the\n\t * MigrationApiClient. See the `getMigrationApiClient()` method.\n\t *\n\t * @example To create a document by converting it from the Page Builder to\n\t * Core api format\n\t *\n\t * ```js\n\t * import { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';\n\t *\n\t * const document = {\n\t * title: 'A new document',\n\t * custom_type_id: 'home-page',\n\t * locale: 'en-gb',\n\t * integration_field_ids: [],\n\t * tags: [],\n\t * data: DocumentLegacy.encode({\n\t * uid: {\n\t * __TYPE__: UIDContentType,\n\t * value: 'home-page',\n\t * },\n\t * })\n\t * }\n\t * await repository.createDocument(document, 'published');\n\t * \t * ```\n\t * ```\n\t *\n\t * @returns\n\t *\n\t * @param document - in the core api format.\n\t *\n\t * @param status - status of the document, if published, the function will\n\t * wait for a new content api master ref to be created\n\t */\n\tasync createDocument(\n\t\tdocument: CoreApiDocumentCreationPayload,\n\t\tstatus: \"draft\" | \"published\",\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst profiler = logger.startTimer();\n\t\tconst result = await this.coreApiClient.createDraft(document);\n\n\t\tlet message = `Document created with id '${result.id}'`;\n\t\tif (status === \"published\") {\n\t\t\tconst contentApi = this.getContentApiClient();\n\t\t\tconst masterRef = await contentApi.getMasterRef();\n\t\t\tawait this.coreApiClient.publishDraft(result.id);\n\t\t\tawait expect\n\t\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\t\ttimeout: 10_000,\n\t\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t\t})\n\t\t\t\t.not.toBe(masterRef);\n\t\t\tmessage += \", status 'published' and new master ref available\";\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage,\n\t\t});\n\n\t\treturn result;\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale;\n\tlocales?: string[];\n\tdefaultLocale?: string;\n\tslices?: SharedSlice[];\n\tcustomTypes?: CustomType[];\n\tpreview?: Preview;\n\trolePerLocal?: boolean;\n};\n\nexport type Preview = {\n\tname: string;\n\twebsiteURL: string;\n\tresolverPath: string;\n};\n\nexport type CustomLocale = {\n\tlang: {\n\t\tlabel: string;\n\t\tid: string;\n\t\tuseStandardAnalyzer?: boolean;\n\t};\n\tregion: {\n\t\tlabel: string;\n\t\tid: string;\n\t};\n};\n"],"names":["getRepositoryUrl","ContentApiClient","logger","logHttpResponse","contentApi","expect"],"mappings":";;;;;;;;;;;;MAwBa,kBAAiB;AAAA,EAC7B,YACU,MACQ,eACA,eACA,aACA,sBACA,oBACA,gBACA,gBAA8B;AAPtC;AACQ;AACA;AACA;AACA;AACA;AACA;AACA;AAPR,SAAI,OAAJ;AACQ,SAAa,gBAAb;AACA,SAAa,gBAAb;AACA,SAAW,cAAX;AACA,SAAoB,uBAApB;AACA,SAAkB,qBAAlB;AACA,SAAc,iBAAd;AACA,SAAc,iBAAd;AAAA,EACf;AAAA,EAEH,MAAM,UAAU,QAAwB;AACvC,UAAM,gBACL,OAAO,iBAAiB,OAAO,WAAW,OAAO;AAClD,QAAI,eAAe;AAClB,YAAM,YAAY,MAAM,KAAK,cAAc,aAAY;AACvD,UAAI,8BAA8B;AAElC,UAAI,OAAO,eAAe;AACnB,cAAA,SAAS,UAAU,KAAK,CAAC,EAAE,gBAAgB,cAAc,IAAI;AACnE,YAAI,CAAC,QAAQ;AACZ,gBAAM,KAAK,iBA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,EAAE;AAExB,aAAS,KAAK;AAAA,MACb,SAAS,kBACR,OAAO,SAAS,WAAW,SAAS,cACrC,aAAa,KAAK;AAAA,IAAA,CAClB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqCA,MAAM,eACL,UACA,QAA6B;AAEvB,UAAA,WAAWA,WAAO;AACxB,UAAM,SAAS,MAAM,KAAK,cAAc,YAAY,QAAQ;AAExD,QAAA,UAAU,6BAA6B,OAAO,EAAE;AACpD,QAAI,WAAW,aAAa;AACrB,YAAAE,cAAa,KAAK;AAClB,YAAA,YAAY,MAAMA,YAAW;AACnC,YAAM,KAAK,cAAc,aAAa,OAAO,EAAE;AAC/C,YAAMC,KACJ,OAAA,KAAK,YAAYD,YAAW,gBAAgB;AAAA,QAC5C,SAAS;AAAA,QACT,SAAS;AAAA,MACT,CAAA,EACA,IAAI,KAAK,SAAS;AACT,iBAAA;AAAA,IACZ;AACA,aAAS,KAAK;AAAA,MACb;AAAA,IAAA,CACA;AAEM,WAAA;AAAA,EACR;AACA;;"}
1
+ {"version":3,"file":"repository.cjs","sources":["../../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\";\nimport { AxiosResponse } from \"axios\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { AssetApiClient } from \"../clients/assetApi\";\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\";\nimport { ContentApiClient } from \"../clients/contentApi\";\nimport {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n} from \"../clients/coreApi\";\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\";\nimport { ManageV2Client } from \"../clients/manageV2\";\nimport { MigrationApiClient } from \"../clients/migrationApi\";\nimport { WroomClient } from \"../clients/wroom\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\n/** Utility to manage test data for a Prismic repository */\nexport class RepositoryManager {\n\tconstructor(\n\t\treadonly name: string,\n\t\tprivate readonly coreApiClient: CoreApiClient,\n\t\tprivate readonly authApiClient: AuthenticationApiClient,\n\t\tprivate readonly wroomClient: WroomClient,\n\t\tprivate readonly customTypesApiClient: CustomTypesApiClient,\n\t\tprivate readonly migrationApiClient: MigrationApiClient | undefined,\n\t\tprivate readonly assetApiClient: AssetApiClient,\n\t\tprivate readonly manageV2Client: ManageV2Client,\n\t) {}\n\n\tasync configure(config: RepositoryConfig): Promise<void> {\n\t\tconst hasLangConfig =\n\t\t\tconfig.defaultLocale || config.locales || config.customLocale;\n\t\tif (hasLangConfig) {\n\t\t\tconst languages = await this.coreApiClient.getLanguages();\n\t\t\tlet updateDefaultLocaleAtTheEnd = false;\n\t\t\t// if no locale exists on repo, the master locale needs to be set first\n\t\t\tif (config.defaultLocale) {\n\t\t\t\tconst master = languages.find(({ is_master }) => is_master === true);\n\t\t\t\tif (!master) {\n\t\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"create\");\n\t\t\t\t} else if (master.id !== config.defaultLocale) {\n\t\t\t\t\t// update the master lang at the end, after it is created.\n\t\t\t\t\tupdateDefaultLocaleAtTheEnd = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.locales) {\n\t\t\t\t// No need to add default locale and already existing languages\n\t\t\t\tconst localesToAdd = config.locales.filter(\n\t\t\t\t\t(id) => !languages.some((language) => language.id === id),\n\t\t\t\t);\n\t\t\t\tif (localesToAdd.length > 0) {\n\t\t\t\t\tawait this.createLocales(localesToAdd);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.customLocale) {\n\t\t\t\tif (!languages.find(({ id }) => id === config.customLocale?.lang.id)) {\n\t\t\t\t\tawait this.createCustomLocale(config.customLocale);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.defaultLocale && updateDefaultLocaleAtTheEnd) {\n\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"update\");\n\t\t\t}\n\t\t}\n\n\t\tif (config.slices) {\n\t\t\tawait this.createSlices(config.slices);\n\t\t}\n\n\t\tif (config.customTypes) {\n\t\t\tawait this.createCustomTypes(config.customTypes);\n\t\t}\n\n\t\tif (config.preview) {\n\t\t\tawait this.createPreview(config.preview);\n\t\t}\n\n\t\tif (config.rolePerLocal) {\n\t\t\tawait this.toggleRolePerLocal(true);\n\t\t}\n\n\t\tif (config.customRoles) {\n\t\t\tawait this.toggleCustomRoles(true);\n\t\t}\n\t}\n\n\t/** @returns the repository base url, like https://my-repo.prismic.io */\n\tgetBaseURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), this.name);\n\t}\n\n\t/** @returns the repository base cdn url, like https://my-repo.cdn.prismic.io */\n\tgetBaseCdnURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), `${this.name}.cdn`);\n\t}\n\n\t/**\n\t * @returns a Content Type api client configured to target the repository CDN\n\t * url. Uses Playwright for requests so if your project uses Playwright too,\n\t * any network request will be present in Playwright test reports.\n\t */\n\tgetContentApiClient(config?: {\n\t\tversion?: \"v1\" | \"v2\";\n\t\taccessToken?: string;\n\t}): ContentApiClient {\n\t\treturn new ContentApiClient(this.getBaseCdnURL(), config);\n\t}\n\n\t/**\n\t * @returns an instance of the Migration api client, see\n\t * https://prismic.io/docs/migration-api-technical-reference\n\t */\n\tgetMigrationApiClient(): MigrationApiClient {\n\t\tif (!this.migrationApiClient) {\n\t\t\tthrow \"No client found for the migration api. Did you provide a migration api url in the configuration?\";\n\t\t}\n\n\t\treturn this.migrationApiClient;\n\t}\n\n\t/**\n\t * @returns an instance of the Asset api client, see\n\t * https://prismic.io/docs/asset-api-technical-reference\n\t */\n\tgetAssetApiClient(): AssetApiClient {\n\t\treturn this.assetApiClient;\n\t}\n\n\t/** @returns the Wroom commit hash deployed on the current repository */\n\tasync getDeployedVersion(): Promise<string | undefined> {\n\t\tconst response = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"underground/834b34f16f451e00f268dd5c8c81d16e3c020275\",\n\t\t);\n\n\t\t// Somehow axios directly parses the text response `Prismic version: <commit hash> into a version attribute\n\t\treturn response.data.version;\n\t}\n\n\t/**\n\t * Set additional standard locales for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locales - An array of all locales to be added to the repository.\n\t *\n\t * @throws Error if setting the locales fails.\n\t */\n\tasync createLocales(locales: string[]): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages\",\n\t\t\t{ languages: locales },\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t(data as string).includes(\"already existing languages\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add locales ${locales.join(\", \")}`);\n\t\t}\n\t\tprofiler.done({ message: `locales '${locales}' created` });\n\t}\n\n\t/**\n\t * Set additional custom locale for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locale - The locale to be added to the repository.\n\t *\n\t * @throws Error if setting the locale fails.\n\t */\n\tasync createCustomLocale(locale: CustomLocale): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages/custom\",\n\t\t\tlocale,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 && JSON.stringify(data).includes(\"code is already used\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not create custom locale ${locale}`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `custom locale ${JSON.stringify(locale)} created`,\n\t\t});\n\t}\n\n\tprivate failIfNot200(response: AxiosResponse, msg: string) {\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(msg);\n\t\t}\n\t}\n\n\t/**\n\t * Delete a locale from a repository.\n\t *\n\t * @param locale - locale to remove from the repository configuration.\n\t *\n\t * @throws Error if deleting the locale fails.\n\t */\n\tasync deleteLocale(locale: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/multilanguages/${locale}/delete`,\n\t\t);\n\t\tthis.failIfNot200(response, `Could not delete locale ${locale}`);\n\t\tprofiler.done({ message: `locale '${locale}' deleted` });\n\t}\n\n\t/**\n\t * Create or update the default (master) locale for a repository in Wroom, the\n\t * locale needs to exist in the repository.\n\t *\n\t * @param locale - The locale to be set as the default.\n\t * @param endpoint - \"createMasterLang\" to create it, \"defineAsMaster\" to\n\t * update it.\n\t *\n\t * @throws Error if setting the default locale fails.\n\t */\n\tasync setDefaultLocale(\n\t\tlocale: string,\n\t\taction: \"create\" | \"update\",\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst endpoint = {\n\t\t\tcreate: \"createMasterLang\",\n\t\t\tupdate: \"defineAsMaster\",\n\t\t};\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`/app/settings/multilanguages/${locale}/${endpoint[action]}`,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t// returns 400 if master lang is already set\n\t\t\t\tJSON.stringify(data).includes(\"Unable to set as master language\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not set default locale to ${locale}`);\n\t\t}\n\t\tprofiler.done({ message: `default locale set to '${locale}'` });\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\n\t *\n\t * @returns A Promise that resolves when the release is created.\n\t */\n\tasync createRelease(label: string): Promise<{ id: string }> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(this.name, \"app/releases\", {\n\t\t\tlabel,\n\t\t});\n\t\tthis.failIfNot200(response, `Could not create release ${label}`);\n\t\tprofiler.done({ message: `release '${label}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\n\t * @param repository - The name of the repository.\n\t * @param id - The ID of the release to be deleted.\n\t */\n\tasync deleteRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/releases/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete release with id ${id}`);\n\t\tprofiler.done({ message: `release '${id}' deleted` });\n\t}\n\n\t/**\n\t * Creates a preview for a repository.\n\t *\n\t * @param data - The data for creating the preview.\n\t */\n\tasync createPreview(data: Preview): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/new`,\n\t\t\tdata,\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not create preview ${data.name}`);\n\t\tprofiler.done({ message: `preview '${data.name}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a preview from a repository.\n\t *\n\t * @param id - The ID of the preview to be deleted.\n\t */\n\tasync deletePreview(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/delete/${id}`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete preview with id ${id}`);\n\t\tprofiler.done({ message: `preview '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create a webhook.\n\t *\n\t * @returns A Promise that resolves with the webhook id.\n\t */\n\tasync createWebhook(\n\t\tname: string,\n\t\turl: string,\n\t\tsecret: string,\n\t\ttriggers: {\n\t\t\tdocumentsPublished?: boolean;\n\t\t\tdocumentsUnpublished?: boolean;\n\t\t\treleasesCreated?: boolean;\n\t\t\treleasesUpdated?: boolean;\n\t\t\ttagsCreated?: boolean;\n\t\t\ttagsDeleted?: boolean;\n\t\t},\n\t\tactive: boolean,\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/webhooks/create\",\n\t\t\t{\n\t\t\t\tname,\n\t\t\t\turl,\n\t\t\t\tsecret,\n\t\t\t\tactive: active ? \"on\" : \"off\",\n\t\t\t\t...triggers,\n\t\t\t},\n\t\t);\n\t\tthis.failIfNot200(response, `Could not create webhook ${name}`);\n\t\tprofiler.done({ message: `webhook '${name}' created` });\n\n\t\treturn response.data.created;\n\t}\n\n\t/**\n\t * Deletes a webhook.\n\t *\n\t * @param id - The webhook ID.\n\t */\n\tasync deleteWebhook(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/webhooks/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete webhook with id ${id}`);\n\t\tprofiler.done({ message: `webhook '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes -\n\t */\n\tasync createCustomTypes(customTypes: CustomType[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes);\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices -\n\t */\n\tasync createSlices(slices: SharedSlice[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createSlices(slices);\n\t}\n\n\t/**\n\t * Create an access token to query private items of the Content api.\n\t *\n\t * @param appName - mandatory authorized application name\n\t * @param tokenScope - access token scope. Use \"master\" to when your content\n\t * api is fully private or \"master+releases\" to access private releases\n\t */\n\tasync createContentAPIToken(\n\t\tappName: string,\n\t\ttokenScope: \"master\" | \"master+releases\" = \"master\",\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\t\ttype AuthorizedAppResponse = {\n\t\t\tid: string;\n\t\t\tname: string;\n\t\t\twroom_auths: { token: string; scope: \"master\" | \"master+releases\" }[];\n\t\t};\n\t\tconst existingApps: AxiosResponse<AuthorizedAppResponse[]> =\n\t\t\tawait this.wroomClient.get(this.name, \"settings/security/contentapi\");\n\n\t\tthis.failIfNot200(\n\t\t\texistingApps,\n\t\t\t`Could not get status of existing applications to generate a content api token`,\n\t\t);\n\t\tlet app = existingApps.data.find(({ name, wroom_auths }) => {\n\t\t\treturn name === appName && wroom_auths.length > 0;\n\t\t});\n\n\t\tif (!app) {\n\t\t\tconst response: AxiosResponse<AuthorizedAppResponse> =\n\t\t\t\tawait this.wroomClient.post(this.name, \"settings/security/oauthapp\", {\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t});\n\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api app ${appName}`,\n\t\t\t);\n\t\t\tapp = response.data;\n\t\t}\n\n\t\tlet tokenInfo = app.wroom_auths.find(({ scope }) => scope === tokenScope);\n\t\tif (!tokenInfo) {\n\t\t\tconst response = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/authorizations\",\n\t\t\t\t{\n\t\t\t\t\tapp: app.id,\n\t\t\t\t\tscope: tokenScope,\n\t\t\t\t},\n\t\t\t);\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api access token for app ${appName} with scope ${tokenScope}`,\n\t\t\t);\n\t\t\ttokenInfo = response.data;\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `content api access token for app '${appName}' created`,\n\t\t});\n\n\t\tif (!tokenInfo?.token) {\n\t\t\tthrow `Could not create content api access token for app ${appName} with scope ${tokenScope}`;\n\t\t}\n\n\t\treturn tokenInfo.token;\n\t}\n\n\t/** Create a permanent access token to authenticate to Prismic public apis. */\n\tasync createPermanentAccessToken(): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst token = await this.authApiClient.getMachine2MachineToken(this.name);\n\n\t\tprofiler.done({\n\t\t\tmessage: `machine2machine token created`,\n\t\t});\n\n\t\treturn token;\n\t}\n\n\t/**\n\t * Toggle the Role per Locale workflow\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleRolePerLocal(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.toggleRolePerLocal({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Role per local for ${\n\t\t\t\tthis.name\n\t\t\t}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Role per local ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t});\n\t}\n\n\t/**\n\t * Toggle the Custom Roles workflow\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleCustomRoles(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.toggleCustomRoles({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Custom Roles for ${\n\t\t\t\tthis.name\n\t\t\t}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Custom Roles ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t});\n\t}\n\n\t/**\n\t * Change the Repository Plan\n\t *\n\t * @param {string} newPlanId - The Id of the new Plan to apply\n\t */\n\tasync changePlan(newPlanId: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.changePlan({\n\t\t\trepository: this.name,\n\t\t\tnewPlanId: newPlanId,\n\t\t\tbypassManualBilling: true, // For now the library does not support Stripe features\n\t\t});\n\n\t\tthis.failIfNot200(response, \"Could not change the Repository Plan\");\n\t\tprofiler.done({\n\t\t\tmessage: `Repository Plan changed to ${newPlanId}`,\n\t\t});\n\t}\n\n\t/**\n\t * Add a new user to the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync addUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.addUserToRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 409 &&\n\t\t\t\tJSON.stringify(data).includes(\"already a member of the repo\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add a new user ${email} to the repository`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was added to the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Remove a user from the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync removeUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.removeUserFromRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not remove the user ${email} from the repository`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was removed from the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Update the role of a user in a repository\n\t *\n\t * @param {string} email - The email of the user\n\t * @param {string | Record<string, string>} role - The new Role of the user,\n\t * either a string for basic workflow or an object such as `{ \"lang_id\":\n\t * \"Writer\" }`\n\t *\n\t * Example of roles are\n\t *\n\t * - Administrator\n\t * - Writer\n\t * - Contributor\n\t * - Manager (publisher)\n\t */\n\tasync updateUserRole(\n\t\temail: string,\n\t\trole: string | Record<string, string>,\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response =\n\t\t\ttypeof role === \"string\"\n\t\t\t\t? await this.wroomClient.updateRole(this.name, email, role)\n\t\t\t\t: await this.wroomClient.updateRolePerLocal(this.name, email, role);\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not update the ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} of the user ${email}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Updated User's ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} for user ${email}`,\n\t\t});\n\t}\n\n\t/**\n\t * Creates a document using the core api. If the Core api format is too\n\t * specific, use the migration api client to create a document with the\n\t * MigrationApiClient. See the `getMigrationApiClient()` method.\n\t *\n\t * @example To create a document by converting it from the Page Builder to\n\t * Core api format\n\t *\n\t * ```js\n\t * import { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';\n\t *\n\t * const document = {\n\t * title: 'A new document',\n\t * custom_type_id: 'home-page',\n\t * locale: 'en-gb',\n\t * integration_field_ids: [],\n\t * tags: [],\n\t * data: DocumentLegacy.encode({\n\t * uid: {\n\t * __TYPE__: UIDContentType,\n\t * value: 'home-page',\n\t * },\n\t * })\n\t * }\n\t * await repository.createDocument(document, 'published');\n\t * \t * ```\n\t * ```\n\t *\n\t * @returns\n\t *\n\t * @param document - in the core api format.\n\t *\n\t * @param status - status of the document, if published, the function will\n\t * wait for a new content api master ref to be created\n\t */\n\tasync createDocument(\n\t\tdocument: CoreApiDocumentCreationPayload,\n\t\tstatus: \"draft\" | \"published\",\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst profiler = logger.startTimer();\n\t\tconst result = await this.coreApiClient.createDraft(document);\n\n\t\tlet message = `Document created with id '${result.id}'`;\n\t\tif (status === \"published\") {\n\t\t\tconst contentApi = this.getContentApiClient();\n\t\t\tconst masterRef = await contentApi.getMasterRef();\n\t\t\tawait this.coreApiClient.publishDraft(result.id);\n\t\t\tawait expect\n\t\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\t\ttimeout: 10_000,\n\t\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t\t})\n\t\t\t\t.not.toBe(masterRef);\n\t\t\tmessage += \", status 'published' and new master ref available\";\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage,\n\t\t});\n\n\t\treturn result;\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale;\n\tlocales?: string[];\n\tdefaultLocale?: string;\n\tslices?: SharedSlice[];\n\tcustomTypes?: CustomType[];\n\tpreview?: Preview;\n\trolePerLocal?: boolean;\n\tcustomRoles?: boolean;\n};\n\nexport type Preview = {\n\tname: string;\n\twebsiteURL: string;\n\tresolverPath: string;\n};\n\nexport type CustomLocale = {\n\tlang: {\n\t\tlabel: string;\n\t\tid: string;\n\t\tuseStandardAnalyzer?: boolean;\n\t};\n\tregion: {\n\t\tlabel: string;\n\t\tid: string;\n\t};\n};\n"],"names":["getRepositoryUrl","ContentApiClient","logger","logHttpResponse","contentApi","expect"],"mappings":";;;;;;;;;;;;MAwBa,kBAAiB;AAAA,EAC7B,YACU,MACQ,eACA,eACA,aACA,sBACA,oBACA,gBACA,gBAA8B;AAPtC;AACQ;AACA;AACA;AACA;AACA;AACA;AACA;AAPR,SAAI,OAAJ;AACQ,SAAa,gBAAb;AACA,SAAa,gBAAb;AACA,SAAW,cAAX;AACA,SAAoB,uBAApB;AACA,SAAkB,qBAAlB;AACA,SAAc,iBAAd;AACA,SAAc,iBAAd;AAAA,EACf;AAAA,EAEH,MAAM,UAAU,QAAwB;AACvC,UAAM,gBACL,OAAO,iBAAiB,OAAO,WAAW,OAAO;AAClD,Q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C/C,YAAMC,KACJ,OAAA,KAAK,YAAYD,YAAW,gBAAgB;AAAA,QAC5C,SAAS;AAAA,QACT,SAAS;AAAA,MACT,CAAA,EACA,IAAI,KAAK,SAAS;AACT,iBAAA;AAAA,IACZ;AACA,aAAS,KAAK;AAAA,MACb;AAAA,IAAA,CACA;AAEM,WAAA;AAAA,EACR;AACA;;"}
@@ -153,11 +153,17 @@ export declare class RepositoryManager {
153
153
  /** Create a permanent access token to authenticate to Prismic public apis. */
154
154
  createPermanentAccessToken(): Promise<string>;
155
155
  /**
156
- * Toggle the Role per local feature
156
+ * Toggle the Role per Locale workflow
157
157
  *
158
158
  * @param enabled - The feature new status
159
159
  */
160
160
  toggleRolePerLocal(enabled: boolean): Promise<void>;
161
+ /**
162
+ * Toggle the Custom Roles workflow
163
+ *
164
+ * @param enabled - The feature new status
165
+ */
166
+ toggleCustomRoles(enabled: boolean): Promise<void>;
161
167
  /**
162
168
  * Change the Repository Plan
163
169
  *
@@ -237,6 +243,7 @@ export type RepositoryConfig = {
237
243
  customTypes?: CustomType[];
238
244
  preview?: Preview;
239
245
  rolePerLocal?: boolean;
246
+ customRoles?: boolean;
240
247
  };
241
248
  export type Preview = {
242
249
  name: string;
@@ -70,6 +70,9 @@ class RepositoryManager {
70
70
  if (config.rolePerLocal) {
71
71
  await this.toggleRolePerLocal(true);
72
72
  }
73
+ if (config.customRoles) {
74
+ await this.toggleCustomRoles(true);
75
+ }
73
76
  }
74
77
  /** @returns the repository base url, like https://my-repo.prismic.io */
75
78
  getBaseURL() {
@@ -338,7 +341,7 @@ class RepositoryManager {
338
341
  return token;
339
342
  }
340
343
  /**
341
- * Toggle the Role per local feature
344
+ * Toggle the Role per Locale workflow
342
345
  *
343
346
  * @param enabled - The feature new status
344
347
  */
@@ -353,6 +356,22 @@ class RepositoryManager {
353
356
  message: `Role per local ${enabled ? "enabled" : "disabled"}`
354
357
  });
355
358
  }
359
+ /**
360
+ * Toggle the Custom Roles workflow
361
+ *
362
+ * @param enabled - The feature new status
363
+ */
364
+ async toggleCustomRoles(enabled) {
365
+ const profiler = logger.startTimer();
366
+ const response = await this.manageV2Client.toggleCustomRoles({
367
+ repository: this.name,
368
+ enabled
369
+ });
370
+ this.failIfNot200(response, `Could not ${enabled ? "enable" : "disable"} Custom Roles for ${this.name}`);
371
+ profiler.done({
372
+ message: `Custom Roles ${enabled ? "enabled" : "disabled"}`
373
+ });
374
+ }
356
375
  /**
357
376
  * Change the Repository Plan
358
377
  *
@@ -1 +1 @@
1
- {"version":3,"file":"repository.js","sources":["../../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\";\nimport { AxiosResponse } from \"axios\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { AssetApiClient } from \"../clients/assetApi\";\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\";\nimport { ContentApiClient } from \"../clients/contentApi\";\nimport {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n} from \"../clients/coreApi\";\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\";\nimport { ManageV2Client } from \"../clients/manageV2\";\nimport { MigrationApiClient } from \"../clients/migrationApi\";\nimport { WroomClient } from \"../clients/wroom\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\n/** Utility to manage test data for a Prismic repository */\nexport class RepositoryManager {\n\tconstructor(\n\t\treadonly name: string,\n\t\tprivate readonly coreApiClient: CoreApiClient,\n\t\tprivate readonly authApiClient: AuthenticationApiClient,\n\t\tprivate readonly wroomClient: WroomClient,\n\t\tprivate readonly customTypesApiClient: CustomTypesApiClient,\n\t\tprivate readonly migrationApiClient: MigrationApiClient | undefined,\n\t\tprivate readonly assetApiClient: AssetApiClient,\n\t\tprivate readonly manageV2Client: ManageV2Client,\n\t) {}\n\n\tasync configure(config: RepositoryConfig): Promise<void> {\n\t\tconst hasLangConfig =\n\t\t\tconfig.defaultLocale || config.locales || config.customLocale;\n\t\tif (hasLangConfig) {\n\t\t\tconst languages = await this.coreApiClient.getLanguages();\n\t\t\tlet updateDefaultLocaleAtTheEnd = false;\n\t\t\t// if no locale exists on repo, the master locale needs to be set first\n\t\t\tif (config.defaultLocale) {\n\t\t\t\tconst master = languages.find(({ is_master }) => is_master === true);\n\t\t\t\tif (!master) {\n\t\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"create\");\n\t\t\t\t} else if (master.id !== config.defaultLocale) {\n\t\t\t\t\t// update the master lang at the end, after it is created.\n\t\t\t\t\tupdateDefaultLocaleAtTheEnd = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.locales) {\n\t\t\t\t// No need to add default locale and already existing languages\n\t\t\t\tconst localesToAdd = config.locales.filter(\n\t\t\t\t\t(id) => !languages.some((language) => language.id === id),\n\t\t\t\t);\n\t\t\t\tif (localesToAdd.length > 0) {\n\t\t\t\t\tawait this.createLocales(localesToAdd);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.customLocale) {\n\t\t\t\tif (!languages.find(({ id }) => id === config.customLocale?.lang.id)) {\n\t\t\t\t\tawait this.createCustomLocale(config.customLocale);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.defaultLocale && updateDefaultLocaleAtTheEnd) {\n\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"update\");\n\t\t\t}\n\t\t}\n\n\t\tif (config.slices) {\n\t\t\tawait this.createSlices(config.slices);\n\t\t}\n\n\t\tif (config.customTypes) {\n\t\t\tawait this.createCustomTypes(config.customTypes);\n\t\t}\n\n\t\tif (config.preview) {\n\t\t\tawait this.createPreview(config.preview);\n\t\t}\n\n\t\tif (config.rolePerLocal) {\n\t\t\tawait this.toggleRolePerLocal(true);\n\t\t}\n\t}\n\n\t/** @returns the repository base url, like https://my-repo.prismic.io */\n\tgetBaseURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), this.name);\n\t}\n\n\t/** @returns the repository base cdn url, like https://my-repo.cdn.prismic.io */\n\tgetBaseCdnURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), `${this.name}.cdn`);\n\t}\n\n\t/**\n\t * @returns a Content Type api client configured to target the repository CDN\n\t * url. Uses Playwright for requests so if your project uses Playwright too,\n\t * any network request will be present in Playwright test reports.\n\t */\n\tgetContentApiClient(config?: {\n\t\tversion?: \"v1\" | \"v2\";\n\t\taccessToken?: string;\n\t}): ContentApiClient {\n\t\treturn new ContentApiClient(this.getBaseCdnURL(), config);\n\t}\n\n\t/**\n\t * @returns an instance of the Migration api client, see\n\t * https://prismic.io/docs/migration-api-technical-reference\n\t */\n\tgetMigrationApiClient(): MigrationApiClient {\n\t\tif (!this.migrationApiClient) {\n\t\t\tthrow \"No client found for the migration api. Did you provide a migration api url in the configuration?\";\n\t\t}\n\n\t\treturn this.migrationApiClient;\n\t}\n\n\t/**\n\t * @returns an instance of the Asset api client, see\n\t * https://prismic.io/docs/asset-api-technical-reference\n\t */\n\tgetAssetApiClient(): AssetApiClient {\n\t\treturn this.assetApiClient;\n\t}\n\n\t/** @returns the Wroom commit hash deployed on the current repository */\n\tasync getDeployedVersion(): Promise<string | undefined> {\n\t\tconst response = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"underground/834b34f16f451e00f268dd5c8c81d16e3c020275\",\n\t\t);\n\n\t\t// Somehow axios directly parses the text response `Prismic version: <commit hash> into a version attribute\n\t\treturn response.data.version;\n\t}\n\n\t/**\n\t * Set additional standard locales for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locales - An array of all locales to be added to the repository.\n\t *\n\t * @throws Error if setting the locales fails.\n\t */\n\tasync createLocales(locales: string[]): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages\",\n\t\t\t{ languages: locales },\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t(data as string).includes(\"already existing languages\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add locales ${locales.join(\", \")}`);\n\t\t}\n\t\tprofiler.done({ message: `locales '${locales}' created` });\n\t}\n\n\t/**\n\t * Set additional custom locale for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locale - The locale to be added to the repository.\n\t *\n\t * @throws Error if setting the locale fails.\n\t */\n\tasync createCustomLocale(locale: CustomLocale): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages/custom\",\n\t\t\tlocale,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 && JSON.stringify(data).includes(\"code is already used\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not create custom locale ${locale}`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `custom locale ${JSON.stringify(locale)} created`,\n\t\t});\n\t}\n\n\tprivate failIfNot200(response: AxiosResponse, msg: string) {\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(msg);\n\t\t}\n\t}\n\n\t/**\n\t * Delete a locale from a repository.\n\t *\n\t * @param locale - locale to remove from the repository configuration.\n\t *\n\t * @throws Error if deleting the locale fails.\n\t */\n\tasync deleteLocale(locale: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/multilanguages/${locale}/delete`,\n\t\t);\n\t\tthis.failIfNot200(response, `Could not delete locale ${locale}`);\n\t\tprofiler.done({ message: `locale '${locale}' deleted` });\n\t}\n\n\t/**\n\t * Create or update the default (master) locale for a repository in Wroom, the\n\t * locale needs to exist in the repository.\n\t *\n\t * @param locale - The locale to be set as the default.\n\t * @param endpoint - \"createMasterLang\" to create it, \"defineAsMaster\" to\n\t * update it.\n\t *\n\t * @throws Error if setting the default locale fails.\n\t */\n\tasync setDefaultLocale(\n\t\tlocale: string,\n\t\taction: \"create\" | \"update\",\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst endpoint = {\n\t\t\tcreate: \"createMasterLang\",\n\t\t\tupdate: \"defineAsMaster\",\n\t\t};\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`/app/settings/multilanguages/${locale}/${endpoint[action]}`,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t// returns 400 if master lang is already set\n\t\t\t\tJSON.stringify(data).includes(\"Unable to set as master language\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not set default locale to ${locale}`);\n\t\t}\n\t\tprofiler.done({ message: `default locale set to '${locale}'` });\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\n\t *\n\t * @returns A Promise that resolves when the release is created.\n\t */\n\tasync createRelease(label: string): Promise<{ id: string }> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(this.name, \"app/releases\", {\n\t\t\tlabel,\n\t\t});\n\t\tthis.failIfNot200(response, `Could not create release ${label}`);\n\t\tprofiler.done({ message: `release '${label}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\n\t * @param repository - The name of the repository.\n\t * @param id - The ID of the release to be deleted.\n\t */\n\tasync deleteRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/releases/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete release with id ${id}`);\n\t\tprofiler.done({ message: `release '${id}' deleted` });\n\t}\n\n\t/**\n\t * Creates a preview for a repository.\n\t *\n\t * @param data - The data for creating the preview.\n\t */\n\tasync createPreview(data: Preview): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/new`,\n\t\t\tdata,\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not create preview ${data.name}`);\n\t\tprofiler.done({ message: `preview '${data.name}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a preview from a repository.\n\t *\n\t * @param id - The ID of the preview to be deleted.\n\t */\n\tasync deletePreview(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/delete/${id}`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete preview with id ${id}`);\n\t\tprofiler.done({ message: `preview '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create a webhook.\n\t *\n\t * @returns A Promise that resolves with the webhook id.\n\t */\n\tasync createWebhook(\n\t\tname: string,\n\t\turl: string,\n\t\tsecret: string,\n\t\ttriggers: {\n\t\t\tdocumentsPublished?: boolean;\n\t\t\tdocumentsUnpublished?: boolean;\n\t\t\treleasesCreated?: boolean;\n\t\t\treleasesUpdated?: boolean;\n\t\t\ttagsCreated?: boolean;\n\t\t\ttagsDeleted?: boolean;\n\t\t},\n\t\tactive: boolean,\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/webhooks/create\",\n\t\t\t{\n\t\t\t\tname,\n\t\t\t\turl,\n\t\t\t\tsecret,\n\t\t\t\tactive: active ? \"on\" : \"off\",\n\t\t\t\t...triggers,\n\t\t\t},\n\t\t);\n\t\tthis.failIfNot200(response, `Could not create webhook ${name}`);\n\t\tprofiler.done({ message: `webhook '${name}' created` });\n\n\t\treturn response.data.created;\n\t}\n\n\t/**\n\t * Deletes a webhook.\n\t *\n\t * @param id - The webhook ID.\n\t */\n\tasync deleteWebhook(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/webhooks/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete webhook with id ${id}`);\n\t\tprofiler.done({ message: `webhook '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes -\n\t */\n\tasync createCustomTypes(customTypes: CustomType[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes);\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices -\n\t */\n\tasync createSlices(slices: SharedSlice[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createSlices(slices);\n\t}\n\n\t/**\n\t * Create an access token to query private items of the Content api.\n\t *\n\t * @param appName - mandatory authorized application name\n\t * @param tokenScope - access token scope. Use \"master\" to when your content\n\t * api is fully private or \"master+releases\" to access private releases\n\t */\n\tasync createContentAPIToken(\n\t\tappName: string,\n\t\ttokenScope: \"master\" | \"master+releases\" = \"master\",\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\t\ttype AuthorizedAppResponse = {\n\t\t\tid: string;\n\t\t\tname: string;\n\t\t\twroom_auths: { token: string; scope: \"master\" | \"master+releases\" }[];\n\t\t};\n\t\tconst existingApps: AxiosResponse<AuthorizedAppResponse[]> =\n\t\t\tawait this.wroomClient.get(this.name, \"settings/security/contentapi\");\n\n\t\tthis.failIfNot200(\n\t\t\texistingApps,\n\t\t\t`Could not get status of existing applications to generate a content api token`,\n\t\t);\n\t\tlet app = existingApps.data.find(({ name, wroom_auths }) => {\n\t\t\treturn name === appName && wroom_auths.length > 0;\n\t\t});\n\n\t\tif (!app) {\n\t\t\tconst response: AxiosResponse<AuthorizedAppResponse> =\n\t\t\t\tawait this.wroomClient.post(this.name, \"settings/security/oauthapp\", {\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t});\n\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api app ${appName}`,\n\t\t\t);\n\t\t\tapp = response.data;\n\t\t}\n\n\t\tlet tokenInfo = app.wroom_auths.find(({ scope }) => scope === tokenScope);\n\t\tif (!tokenInfo) {\n\t\t\tconst response = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/authorizations\",\n\t\t\t\t{\n\t\t\t\t\tapp: app.id,\n\t\t\t\t\tscope: tokenScope,\n\t\t\t\t},\n\t\t\t);\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api access token for app ${appName} with scope ${tokenScope}`,\n\t\t\t);\n\t\t\ttokenInfo = response.data;\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `content api access token for app '${appName}' created`,\n\t\t});\n\n\t\tif (!tokenInfo?.token) {\n\t\t\tthrow `Could not create content api access token for app ${appName} with scope ${tokenScope}`;\n\t\t}\n\n\t\treturn tokenInfo.token;\n\t}\n\n\t/** Create a permanent access token to authenticate to Prismic public apis. */\n\tasync createPermanentAccessToken(): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst token = await this.authApiClient.getMachine2MachineToken(this.name);\n\n\t\tprofiler.done({\n\t\t\tmessage: `machine2machine token created`,\n\t\t});\n\n\t\treturn token;\n\t}\n\n\t/**\n\t * Toggle the Role per local feature\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleRolePerLocal(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.toggleRolePerLocal({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Role per local for ${\n\t\t\t\tthis.name\n\t\t\t}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Role per local ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t});\n\t}\n\n\t/**\n\t * Change the Repository Plan\n\t *\n\t * @param {string} newPlanId - The Id of the new Plan to apply\n\t */\n\tasync changePlan(newPlanId: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.changePlan({\n\t\t\trepository: this.name,\n\t\t\tnewPlanId: newPlanId,\n\t\t\tbypassManualBilling: true, // For now the library does not support Stripe features\n\t\t});\n\n\t\tthis.failIfNot200(response, \"Could not change the Repository Plan\");\n\t\tprofiler.done({\n\t\t\tmessage: `Repository Plan changed to ${newPlanId}`,\n\t\t});\n\t}\n\n\t/**\n\t * Add a new user to the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync addUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.addUserToRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 409 &&\n\t\t\t\tJSON.stringify(data).includes(\"already a member of the repo\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add a new user ${email} to the repository`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was added to the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Remove a user from the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync removeUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.removeUserFromRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not remove the user ${email} from the repository`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was removed from the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Update the role of a user in a repository\n\t *\n\t * @param {string} email - The email of the user\n\t * @param {string | Record<string, string>} role - The new Role of the user,\n\t * either a string for basic workflow or an object such as `{ \"lang_id\":\n\t * \"Writer\" }`\n\t *\n\t * Example of roles are\n\t *\n\t * - Administrator\n\t * - Writer\n\t * - Contributor\n\t * - Manager (publisher)\n\t */\n\tasync updateUserRole(\n\t\temail: string,\n\t\trole: string | Record<string, string>,\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response =\n\t\t\ttypeof role === \"string\"\n\t\t\t\t? await this.wroomClient.updateRole(this.name, email, role)\n\t\t\t\t: await this.wroomClient.updateRolePerLocal(this.name, email, role);\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not update the ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} of the user ${email}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Updated User's ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} for user ${email}`,\n\t\t});\n\t}\n\n\t/**\n\t * Creates a document using the core api. If the Core api format is too\n\t * specific, use the migration api client to create a document with the\n\t * MigrationApiClient. See the `getMigrationApiClient()` method.\n\t *\n\t * @example To create a document by converting it from the Page Builder to\n\t * Core api format\n\t *\n\t * ```js\n\t * import { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';\n\t *\n\t * const document = {\n\t * title: 'A new document',\n\t * custom_type_id: 'home-page',\n\t * locale: 'en-gb',\n\t * integration_field_ids: [],\n\t * tags: [],\n\t * data: DocumentLegacy.encode({\n\t * uid: {\n\t * __TYPE__: UIDContentType,\n\t * value: 'home-page',\n\t * },\n\t * })\n\t * }\n\t * await repository.createDocument(document, 'published');\n\t * \t * ```\n\t * ```\n\t *\n\t * @returns\n\t *\n\t * @param document - in the core api format.\n\t *\n\t * @param status - status of the document, if published, the function will\n\t * wait for a new content api master ref to be created\n\t */\n\tasync createDocument(\n\t\tdocument: CoreApiDocumentCreationPayload,\n\t\tstatus: \"draft\" | \"published\",\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst profiler = logger.startTimer();\n\t\tconst result = await this.coreApiClient.createDraft(document);\n\n\t\tlet message = `Document created with id '${result.id}'`;\n\t\tif (status === \"published\") {\n\t\t\tconst contentApi = this.getContentApiClient();\n\t\t\tconst masterRef = await contentApi.getMasterRef();\n\t\t\tawait this.coreApiClient.publishDraft(result.id);\n\t\t\tawait expect\n\t\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\t\ttimeout: 10_000,\n\t\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t\t})\n\t\t\t\t.not.toBe(masterRef);\n\t\t\tmessage += \", status 'published' and new master ref available\";\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage,\n\t\t});\n\n\t\treturn result;\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale;\n\tlocales?: string[];\n\tdefaultLocale?: string;\n\tslices?: SharedSlice[];\n\tcustomTypes?: CustomType[];\n\tpreview?: Preview;\n\trolePerLocal?: boolean;\n};\n\nexport type Preview = {\n\tname: string;\n\twebsiteURL: string;\n\tresolverPath: string;\n};\n\nexport type CustomLocale = {\n\tlang: {\n\t\tlabel: string;\n\t\tid: string;\n\t\tuseStandardAnalyzer?: boolean;\n\t};\n\tregion: {\n\t\tlabel: string;\n\t\tid: string;\n\t};\n};\n"],"names":[],"mappings":";;;;;;;;;;MAwBa,kBAAiB;AAAA,EAC7B,YACU,MACQ,eACA,eACA,aACA,sBACA,oBACA,gBACA,gBAA8B;AAPtC;AACQ;AACA;AACA;AACA;AACA;AACA;AACA;AAPR,SAAI,OAAJ;AACQ,SAAa,gBAAb;AACA,SAAa,gBAAb;AACA,SAAW,cAAX;AACA,SAAoB,uB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AA;AAAA;AAAA;AAAA,EAiBA,MAAM,eACL,OACA,MAAqC;AAE/B,UAAA,WAAW,OAAO;AAElB,UAAA,WACL,OAAO,SAAS,WACb,MAAM,KAAK,YAAY,WAAW,KAAK,MAAM,OAAO,IAAI,IACxD,MAAM,KAAK,YAAY,mBAAmB,KAAK,MAAM,OAAO,IAAI;AAE/D,SAAA,aACJ,UACA,wBACC,OAAO,SAAS,WAAW,SAAS,cACrC,gBAAgB,KAAK,EAAE;AAExB,aAAS,KAAK;AAAA,MACb,SAAS,kBACR,OAAO,SAAS,WAAW,SAAS,cACrC,aAAa,KAAK;AAAA,IAAA,CAClB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqCA,MAAM,eACL,UACA,QAA6B;AAEvB,UAAA,WAAW,OAAO;AACxB,UAAM,SAAS,MAAM,KAAK,cAAc,YAAY,QAAQ;AAExD,QAAA,UAAU,6BAA6B,OAAO,EAAE;AACpD,QAAI,WAAW,aAAa;AACrB,YAAA,aAAa,KAAK;AAClB,YAAA,YAAY,MAAM,WAAW;AACnC,YAAM,KAAK,cAAc,aAAa,OAAO,EAAE;AAC/C,YAAM,OACJ,KAAK,YAAY,WAAW,gBAAgB;AAAA,QAC5C,SAAS;AAAA,QACT,SAAS;AAAA,MACT,CAAA,EACA,IAAI,KAAK,SAAS;AACT,iBAAA;AAAA,IACZ;AACA,aAAS,KAAK;AAAA,MACb;AAAA,IAAA,CACA;AAEM,WAAA;AAAA,EACR;AACA;"}
1
+ {"version":3,"file":"repository.js","sources":["../../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\";\nimport { AxiosResponse } from \"axios\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { AssetApiClient } from \"../clients/assetApi\";\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\";\nimport { ContentApiClient } from \"../clients/contentApi\";\nimport {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n} from \"../clients/coreApi\";\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\";\nimport { ManageV2Client } from \"../clients/manageV2\";\nimport { MigrationApiClient } from \"../clients/migrationApi\";\nimport { WroomClient } from \"../clients/wroom\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\n/** Utility to manage test data for a Prismic repository */\nexport class RepositoryManager {\n\tconstructor(\n\t\treadonly name: string,\n\t\tprivate readonly coreApiClient: CoreApiClient,\n\t\tprivate readonly authApiClient: AuthenticationApiClient,\n\t\tprivate readonly wroomClient: WroomClient,\n\t\tprivate readonly customTypesApiClient: CustomTypesApiClient,\n\t\tprivate readonly migrationApiClient: MigrationApiClient | undefined,\n\t\tprivate readonly assetApiClient: AssetApiClient,\n\t\tprivate readonly manageV2Client: ManageV2Client,\n\t) {}\n\n\tasync configure(config: RepositoryConfig): Promise<void> {\n\t\tconst hasLangConfig =\n\t\t\tconfig.defaultLocale || config.locales || config.customLocale;\n\t\tif (hasLangConfig) {\n\t\t\tconst languages = await this.coreApiClient.getLanguages();\n\t\t\tlet updateDefaultLocaleAtTheEnd = false;\n\t\t\t// if no locale exists on repo, the master locale needs to be set first\n\t\t\tif (config.defaultLocale) {\n\t\t\t\tconst master = languages.find(({ is_master }) => is_master === true);\n\t\t\t\tif (!master) {\n\t\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"create\");\n\t\t\t\t} else if (master.id !== config.defaultLocale) {\n\t\t\t\t\t// update the master lang at the end, after it is created.\n\t\t\t\t\tupdateDefaultLocaleAtTheEnd = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.locales) {\n\t\t\t\t// No need to add default locale and already existing languages\n\t\t\t\tconst localesToAdd = config.locales.filter(\n\t\t\t\t\t(id) => !languages.some((language) => language.id === id),\n\t\t\t\t);\n\t\t\t\tif (localesToAdd.length > 0) {\n\t\t\t\t\tawait this.createLocales(localesToAdd);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.customLocale) {\n\t\t\t\tif (!languages.find(({ id }) => id === config.customLocale?.lang.id)) {\n\t\t\t\t\tawait this.createCustomLocale(config.customLocale);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.defaultLocale && updateDefaultLocaleAtTheEnd) {\n\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"update\");\n\t\t\t}\n\t\t}\n\n\t\tif (config.slices) {\n\t\t\tawait this.createSlices(config.slices);\n\t\t}\n\n\t\tif (config.customTypes) {\n\t\t\tawait this.createCustomTypes(config.customTypes);\n\t\t}\n\n\t\tif (config.preview) {\n\t\t\tawait this.createPreview(config.preview);\n\t\t}\n\n\t\tif (config.rolePerLocal) {\n\t\t\tawait this.toggleRolePerLocal(true);\n\t\t}\n\n\t\tif (config.customRoles) {\n\t\t\tawait this.toggleCustomRoles(true);\n\t\t}\n\t}\n\n\t/** @returns the repository base url, like https://my-repo.prismic.io */\n\tgetBaseURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), this.name);\n\t}\n\n\t/** @returns the repository base cdn url, like https://my-repo.cdn.prismic.io */\n\tgetBaseCdnURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), `${this.name}.cdn`);\n\t}\n\n\t/**\n\t * @returns a Content Type api client configured to target the repository CDN\n\t * url. Uses Playwright for requests so if your project uses Playwright too,\n\t * any network request will be present in Playwright test reports.\n\t */\n\tgetContentApiClient(config?: {\n\t\tversion?: \"v1\" | \"v2\";\n\t\taccessToken?: string;\n\t}): ContentApiClient {\n\t\treturn new ContentApiClient(this.getBaseCdnURL(), config);\n\t}\n\n\t/**\n\t * @returns an instance of the Migration api client, see\n\t * https://prismic.io/docs/migration-api-technical-reference\n\t */\n\tgetMigrationApiClient(): MigrationApiClient {\n\t\tif (!this.migrationApiClient) {\n\t\t\tthrow \"No client found for the migration api. Did you provide a migration api url in the configuration?\";\n\t\t}\n\n\t\treturn this.migrationApiClient;\n\t}\n\n\t/**\n\t * @returns an instance of the Asset api client, see\n\t * https://prismic.io/docs/asset-api-technical-reference\n\t */\n\tgetAssetApiClient(): AssetApiClient {\n\t\treturn this.assetApiClient;\n\t}\n\n\t/** @returns the Wroom commit hash deployed on the current repository */\n\tasync getDeployedVersion(): Promise<string | undefined> {\n\t\tconst response = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"underground/834b34f16f451e00f268dd5c8c81d16e3c020275\",\n\t\t);\n\n\t\t// Somehow axios directly parses the text response `Prismic version: <commit hash> into a version attribute\n\t\treturn response.data.version;\n\t}\n\n\t/**\n\t * Set additional standard locales for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locales - An array of all locales to be added to the repository.\n\t *\n\t * @throws Error if setting the locales fails.\n\t */\n\tasync createLocales(locales: string[]): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages\",\n\t\t\t{ languages: locales },\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t(data as string).includes(\"already existing languages\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add locales ${locales.join(\", \")}`);\n\t\t}\n\t\tprofiler.done({ message: `locales '${locales}' created` });\n\t}\n\n\t/**\n\t * Set additional custom locale for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locale - The locale to be added to the repository.\n\t *\n\t * @throws Error if setting the locale fails.\n\t */\n\tasync createCustomLocale(locale: CustomLocale): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages/custom\",\n\t\t\tlocale,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 && JSON.stringify(data).includes(\"code is already used\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not create custom locale ${locale}`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `custom locale ${JSON.stringify(locale)} created`,\n\t\t});\n\t}\n\n\tprivate failIfNot200(response: AxiosResponse, msg: string) {\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(msg);\n\t\t}\n\t}\n\n\t/**\n\t * Delete a locale from a repository.\n\t *\n\t * @param locale - locale to remove from the repository configuration.\n\t *\n\t * @throws Error if deleting the locale fails.\n\t */\n\tasync deleteLocale(locale: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/multilanguages/${locale}/delete`,\n\t\t);\n\t\tthis.failIfNot200(response, `Could not delete locale ${locale}`);\n\t\tprofiler.done({ message: `locale '${locale}' deleted` });\n\t}\n\n\t/**\n\t * Create or update the default (master) locale for a repository in Wroom, the\n\t * locale needs to exist in the repository.\n\t *\n\t * @param locale - The locale to be set as the default.\n\t * @param endpoint - \"createMasterLang\" to create it, \"defineAsMaster\" to\n\t * update it.\n\t *\n\t * @throws Error if setting the default locale fails.\n\t */\n\tasync setDefaultLocale(\n\t\tlocale: string,\n\t\taction: \"create\" | \"update\",\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst endpoint = {\n\t\t\tcreate: \"createMasterLang\",\n\t\t\tupdate: \"defineAsMaster\",\n\t\t};\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`/app/settings/multilanguages/${locale}/${endpoint[action]}`,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t// returns 400 if master lang is already set\n\t\t\t\tJSON.stringify(data).includes(\"Unable to set as master language\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not set default locale to ${locale}`);\n\t\t}\n\t\tprofiler.done({ message: `default locale set to '${locale}'` });\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\n\t *\n\t * @returns A Promise that resolves when the release is created.\n\t */\n\tasync createRelease(label: string): Promise<{ id: string }> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(this.name, \"app/releases\", {\n\t\t\tlabel,\n\t\t});\n\t\tthis.failIfNot200(response, `Could not create release ${label}`);\n\t\tprofiler.done({ message: `release '${label}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\n\t * @param repository - The name of the repository.\n\t * @param id - The ID of the release to be deleted.\n\t */\n\tasync deleteRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/releases/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete release with id ${id}`);\n\t\tprofiler.done({ message: `release '${id}' deleted` });\n\t}\n\n\t/**\n\t * Creates a preview for a repository.\n\t *\n\t * @param data - The data for creating the preview.\n\t */\n\tasync createPreview(data: Preview): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/new`,\n\t\t\tdata,\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not create preview ${data.name}`);\n\t\tprofiler.done({ message: `preview '${data.name}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a preview from a repository.\n\t *\n\t * @param id - The ID of the preview to be deleted.\n\t */\n\tasync deletePreview(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/delete/${id}`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete preview with id ${id}`);\n\t\tprofiler.done({ message: `preview '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create a webhook.\n\t *\n\t * @returns A Promise that resolves with the webhook id.\n\t */\n\tasync createWebhook(\n\t\tname: string,\n\t\turl: string,\n\t\tsecret: string,\n\t\ttriggers: {\n\t\t\tdocumentsPublished?: boolean;\n\t\t\tdocumentsUnpublished?: boolean;\n\t\t\treleasesCreated?: boolean;\n\t\t\treleasesUpdated?: boolean;\n\t\t\ttagsCreated?: boolean;\n\t\t\ttagsDeleted?: boolean;\n\t\t},\n\t\tactive: boolean,\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/webhooks/create\",\n\t\t\t{\n\t\t\t\tname,\n\t\t\t\turl,\n\t\t\t\tsecret,\n\t\t\t\tactive: active ? \"on\" : \"off\",\n\t\t\t\t...triggers,\n\t\t\t},\n\t\t);\n\t\tthis.failIfNot200(response, `Could not create webhook ${name}`);\n\t\tprofiler.done({ message: `webhook '${name}' created` });\n\n\t\treturn response.data.created;\n\t}\n\n\t/**\n\t * Deletes a webhook.\n\t *\n\t * @param id - The webhook ID.\n\t */\n\tasync deleteWebhook(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/webhooks/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete webhook with id ${id}`);\n\t\tprofiler.done({ message: `webhook '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes -\n\t */\n\tasync createCustomTypes(customTypes: CustomType[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes);\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices -\n\t */\n\tasync createSlices(slices: SharedSlice[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createSlices(slices);\n\t}\n\n\t/**\n\t * Create an access token to query private items of the Content api.\n\t *\n\t * @param appName - mandatory authorized application name\n\t * @param tokenScope - access token scope. Use \"master\" to when your content\n\t * api is fully private or \"master+releases\" to access private releases\n\t */\n\tasync createContentAPIToken(\n\t\tappName: string,\n\t\ttokenScope: \"master\" | \"master+releases\" = \"master\",\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\t\ttype AuthorizedAppResponse = {\n\t\t\tid: string;\n\t\t\tname: string;\n\t\t\twroom_auths: { token: string; scope: \"master\" | \"master+releases\" }[];\n\t\t};\n\t\tconst existingApps: AxiosResponse<AuthorizedAppResponse[]> =\n\t\t\tawait this.wroomClient.get(this.name, \"settings/security/contentapi\");\n\n\t\tthis.failIfNot200(\n\t\t\texistingApps,\n\t\t\t`Could not get status of existing applications to generate a content api token`,\n\t\t);\n\t\tlet app = existingApps.data.find(({ name, wroom_auths }) => {\n\t\t\treturn name === appName && wroom_auths.length > 0;\n\t\t});\n\n\t\tif (!app) {\n\t\t\tconst response: AxiosResponse<AuthorizedAppResponse> =\n\t\t\t\tawait this.wroomClient.post(this.name, \"settings/security/oauthapp\", {\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t});\n\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api app ${appName}`,\n\t\t\t);\n\t\t\tapp = response.data;\n\t\t}\n\n\t\tlet tokenInfo = app.wroom_auths.find(({ scope }) => scope === tokenScope);\n\t\tif (!tokenInfo) {\n\t\t\tconst response = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/authorizations\",\n\t\t\t\t{\n\t\t\t\t\tapp: app.id,\n\t\t\t\t\tscope: tokenScope,\n\t\t\t\t},\n\t\t\t);\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api access token for app ${appName} with scope ${tokenScope}`,\n\t\t\t);\n\t\t\ttokenInfo = response.data;\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `content api access token for app '${appName}' created`,\n\t\t});\n\n\t\tif (!tokenInfo?.token) {\n\t\t\tthrow `Could not create content api access token for app ${appName} with scope ${tokenScope}`;\n\t\t}\n\n\t\treturn tokenInfo.token;\n\t}\n\n\t/** Create a permanent access token to authenticate to Prismic public apis. */\n\tasync createPermanentAccessToken(): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst token = await this.authApiClient.getMachine2MachineToken(this.name);\n\n\t\tprofiler.done({\n\t\t\tmessage: `machine2machine token created`,\n\t\t});\n\n\t\treturn token;\n\t}\n\n\t/**\n\t * Toggle the Role per Locale workflow\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleRolePerLocal(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.toggleRolePerLocal({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Role per local for ${\n\t\t\t\tthis.name\n\t\t\t}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Role per local ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t});\n\t}\n\n\t/**\n\t * Toggle the Custom Roles workflow\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleCustomRoles(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.toggleCustomRoles({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Custom Roles for ${\n\t\t\t\tthis.name\n\t\t\t}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Custom Roles ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t});\n\t}\n\n\t/**\n\t * Change the Repository Plan\n\t *\n\t * @param {string} newPlanId - The Id of the new Plan to apply\n\t */\n\tasync changePlan(newPlanId: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.changePlan({\n\t\t\trepository: this.name,\n\t\t\tnewPlanId: newPlanId,\n\t\t\tbypassManualBilling: true, // For now the library does not support Stripe features\n\t\t});\n\n\t\tthis.failIfNot200(response, \"Could not change the Repository Plan\");\n\t\tprofiler.done({\n\t\t\tmessage: `Repository Plan changed to ${newPlanId}`,\n\t\t});\n\t}\n\n\t/**\n\t * Add a new user to the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync addUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.addUserToRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 409 &&\n\t\t\t\tJSON.stringify(data).includes(\"already a member of the repo\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add a new user ${email} to the repository`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was added to the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Remove a user from the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync removeUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.removeUserFromRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not remove the user ${email} from the repository`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was removed from the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Update the role of a user in a repository\n\t *\n\t * @param {string} email - The email of the user\n\t * @param {string | Record<string, string>} role - The new Role of the user,\n\t * either a string for basic workflow or an object such as `{ \"lang_id\":\n\t * \"Writer\" }`\n\t *\n\t * Example of roles are\n\t *\n\t * - Administrator\n\t * - Writer\n\t * - Contributor\n\t * - Manager (publisher)\n\t */\n\tasync updateUserRole(\n\t\temail: string,\n\t\trole: string | Record<string, string>,\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response =\n\t\t\ttypeof role === \"string\"\n\t\t\t\t? await this.wroomClient.updateRole(this.name, email, role)\n\t\t\t\t: await this.wroomClient.updateRolePerLocal(this.name, email, role);\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not update the ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} of the user ${email}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Updated User's ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} for user ${email}`,\n\t\t});\n\t}\n\n\t/**\n\t * Creates a document using the core api. If the Core api format is too\n\t * specific, use the migration api client to create a document with the\n\t * MigrationApiClient. See the `getMigrationApiClient()` method.\n\t *\n\t * @example To create a document by converting it from the Page Builder to\n\t * Core api format\n\t *\n\t * ```js\n\t * import { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';\n\t *\n\t * const document = {\n\t * title: 'A new document',\n\t * custom_type_id: 'home-page',\n\t * locale: 'en-gb',\n\t * integration_field_ids: [],\n\t * tags: [],\n\t * data: DocumentLegacy.encode({\n\t * uid: {\n\t * __TYPE__: UIDContentType,\n\t * value: 'home-page',\n\t * },\n\t * })\n\t * }\n\t * await repository.createDocument(document, 'published');\n\t * \t * ```\n\t * ```\n\t *\n\t * @returns\n\t *\n\t * @param document - in the core api format.\n\t *\n\t * @param status - status of the document, if published, the function will\n\t * wait for a new content api master ref to be created\n\t */\n\tasync createDocument(\n\t\tdocument: CoreApiDocumentCreationPayload,\n\t\tstatus: \"draft\" | \"published\",\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst profiler = logger.startTimer();\n\t\tconst result = await this.coreApiClient.createDraft(document);\n\n\t\tlet message = `Document created with id '${result.id}'`;\n\t\tif (status === \"published\") {\n\t\t\tconst contentApi = this.getContentApiClient();\n\t\t\tconst masterRef = await contentApi.getMasterRef();\n\t\t\tawait this.coreApiClient.publishDraft(result.id);\n\t\t\tawait expect\n\t\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\t\ttimeout: 10_000,\n\t\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t\t})\n\t\t\t\t.not.toBe(masterRef);\n\t\t\tmessage += \", status 'published' and new master ref available\";\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage,\n\t\t});\n\n\t\treturn result;\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale;\n\tlocales?: string[];\n\tdefaultLocale?: string;\n\tslices?: SharedSlice[];\n\tcustomTypes?: CustomType[];\n\tpreview?: Preview;\n\trolePerLocal?: boolean;\n\tcustomRoles?: boolean;\n};\n\nexport type Preview = {\n\tname: string;\n\twebsiteURL: string;\n\tresolverPath: string;\n};\n\nexport type CustomLocale = {\n\tlang: {\n\t\tlabel: string;\n\t\tid: string;\n\t\tuseStandardAnalyzer?: boolean;\n\t};\n\tregion: {\n\t\tlabel: string;\n\t\tid: string;\n\t};\n};\n"],"names":[],"mappings":";;;;;;;;;;MAwBa,kBAAiB;AAAA,EAC7B,YACU,MACQ,eACA,eACA,aACA,sBACA,oBACA,gBACA,gBAA8B;AAPtC;AACQ;AACA;AACA;AACA;AACA;AACA;AACA;AAPR,SAAI,OAAJ;AACQ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AA6B,OAAO,EAAE;AACpD,QAAI,WAAW,aAAa;AACrB,YAAA,aAAa,KAAK;AAClB,YAAA,YAAY,MAAM,WAAW;AACnC,YAAM,KAAK,cAAc,aAAa,OAAO,EAAE;AAC/C,YAAM,OACJ,KAAK,YAAY,WAAW,gBAAgB;AAAA,QAC5C,SAAS;AAAA,QACT,SAAS;AAAA,MACT,CAAA,EACA,IAAI,KAAK,SAAS;AACT,iBAAA;AAAA,IACZ;AACA,aAAS,KAAK;AAAA,MACb;AAAA,IAAA,CACA;AAEM,WAAA;AAAA,EACR;AACA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/e2e-tests-utils",
3
- "version": "1.10.0-alpha.0",
3
+ "version": "1.10.0-alpha.1",
4
4
  "description": "A collection of utilities for to manage Prismic test data",
5
5
  "keywords": [
6
6
  "typescript",
@@ -97,8 +97,8 @@ export class ManageV2Client {
97
97
  }
98
98
 
99
99
  /**
100
- * The function `toggleRolePerLocal` enable or disable the role per local
101
- * feature
100
+ * The function `toggleRolePerLocal` enables or disables the RolesPerLocale
101
+ * workflow
102
102
  *
103
103
  * @param repository - The Repository name
104
104
  * @param enabled - The feature new status
@@ -113,6 +113,23 @@ export class ManageV2Client {
113
113
  },
114
114
  );
115
115
 
116
+ /**
117
+ * The function `toggleCustomRoles` enables or disables the CustomRoles
118
+ * workflow
119
+ *
120
+ * @param repository - The Repository name
121
+ * @param enabled - The feature new status
122
+ */
123
+ toggleCustomRoles = this.assertTokenExist(
124
+ (params: { repository: string; enabled: boolean }) => {
125
+ return this.client.post("/repository/toggleCustomRoles", {
126
+ domain: params.repository,
127
+ enabled: params.enabled,
128
+ author: ManageV2StaticAuthor,
129
+ });
130
+ },
131
+ );
132
+
116
133
  /**
117
134
  * The function `changePlan` changes the plan of a repository the database
118
135
  *
@@ -137,7 +137,7 @@ export class RepositoriesManager {
137
137
  "authentication/newrepository",
138
138
  {
139
139
  domain: repositoryName,
140
- framework: "next",
140
+ framework: "vue",
141
141
  plan: "personal",
142
142
  isAnnual: "false",
143
143
  role: "developer",
@@ -87,6 +87,10 @@ export class RepositoryManager {
87
87
  if (config.rolePerLocal) {
88
88
  await this.toggleRolePerLocal(true);
89
89
  }
90
+
91
+ if (config.customRoles) {
92
+ await this.toggleCustomRoles(true);
93
+ }
90
94
  }
91
95
 
92
96
  /** @returns the repository base url, like https://my-repo.prismic.io */
@@ -497,7 +501,7 @@ export class RepositoryManager {
497
501
  }
498
502
 
499
503
  /**
500
- * Toggle the Role per local feature
504
+ * Toggle the Role per Locale workflow
501
505
  *
502
506
  * @param enabled - The feature new status
503
507
  */
@@ -520,6 +524,30 @@ export class RepositoryManager {
520
524
  });
521
525
  }
522
526
 
527
+ /**
528
+ * Toggle the Custom Roles workflow
529
+ *
530
+ * @param enabled - The feature new status
531
+ */
532
+ async toggleCustomRoles(enabled: boolean): Promise<void> {
533
+ const profiler = logger.startTimer();
534
+
535
+ const response = await this.manageV2Client.toggleCustomRoles({
536
+ repository: this.name,
537
+ enabled: enabled,
538
+ });
539
+
540
+ this.failIfNot200(
541
+ response,
542
+ `Could not ${enabled ? "enable" : "disable"} Custom Roles for ${
543
+ this.name
544
+ }`,
545
+ );
546
+ profiler.done({
547
+ message: `Custom Roles ${enabled ? "enabled" : "disabled"}`,
548
+ });
549
+ }
550
+
523
551
  /**
524
552
  * Change the Repository Plan
525
553
  *
@@ -699,6 +727,7 @@ export type RepositoryConfig = {
699
727
  customTypes?: CustomType[];
700
728
  preview?: Preview;
701
729
  rolePerLocal?: boolean;
730
+ customRoles?: boolean;
702
731
  };
703
732
 
704
733
  export type Preview = {