@prismicio/e2e-tests-utils 1.18.0-canary.ad3047b → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/clients/authenticationApi.cjs +1 -0
- package/dist/clients/authenticationApi.cjs.map +1 -1
- package/dist/clients/authenticationApi.d.cts.map +1 -1
- package/dist/clients/authenticationApi.d.ts.map +1 -1
- package/dist/clients/authenticationApi.js +1 -0
- package/dist/clients/authenticationApi.js.map +1 -1
- package/dist/clients/customTypesApi.cjs.map +1 -1
- package/dist/clients/customTypesApi.d.cts +3 -3
- package/dist/clients/customTypesApi.d.cts.map +1 -1
- package/dist/clients/customTypesApi.d.ts +3 -3
- package/dist/clients/customTypesApi.d.ts.map +1 -1
- package/dist/clients/customTypesApi.js.map +1 -1
- package/dist/managers/repository.cjs.map +1 -1
- package/dist/managers/repository.d.cts +3 -3
- package/dist/managers/repository.d.cts.map +1 -1
- package/dist/managers/repository.d.ts +3 -3
- package/dist/managers/repository.d.ts.map +1 -1
- package/dist/managers/repository.js.map +1 -1
- package/package.json +1 -1
- package/src/clients/authenticationApi.ts +3 -0
- package/src/clients/customTypesApi.ts +7 -7
- package/src/managers/repository.ts +3 -3
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ If the custom types already exists on the repository, they will be updated.
|
|
|
47
47
|
```typescript
|
|
48
48
|
import { createRepositoriesManager } from "@prismicio/e2e-tests-utils"
|
|
49
49
|
|
|
50
|
-
import {
|
|
50
|
+
import { DynamicCustomTypeModel, SharedSliceModel } from "@prismicio/types-internal"
|
|
51
51
|
|
|
52
52
|
const slice: SharedSliceModel = {
|
|
53
53
|
id: "test_slice",
|
|
@@ -55,7 +55,7 @@ const slice: SharedSliceModel = {
|
|
|
55
55
|
name: "A slice demo",
|
|
56
56
|
// ...
|
|
57
57
|
}
|
|
58
|
-
const customType:
|
|
58
|
+
const customType: DynamicCustomTypeModel = {
|
|
59
59
|
id: "test_ct",
|
|
60
60
|
label: "A custom type",
|
|
61
61
|
// ...
|
|
@@ -23,6 +23,7 @@ var AuthenticationApiClient = class {
|
|
|
23
23
|
this.baseURL = baseURL;
|
|
24
24
|
this.auth = auth;
|
|
25
25
|
this.authToken = getAuthApiTokenFromEnv(auth.email);
|
|
26
|
+
if (this.authToken) require_log.logger.info(`using user token for ${auth.email} from ${AUTH_API_TOKENS_ENV}`);
|
|
26
27
|
}
|
|
27
28
|
async getContext() {
|
|
28
29
|
if (!this._context) this._context = await _playwright_test.request.newContext({ baseURL: this.baseURL });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticationApi.cjs","names":["request","logger"],"sources":["../../src/clients/authenticationApi.ts"],"sourcesContent":["import type { APIRequestContext } from \"@playwright/test\"\nimport { request } from \"@playwright/test\"\n\nimport type { AuthConfig } from \"../types\"\nimport { logPlaywrightApiResponse, logger } from \"../utils/log\"\n\nconst AUTH_API_TOKENS_ENV = \"PRISMIC_E2E_TEST_UTILS_AUTH_API_TOKENS\"\n\nfunction getAuthApiTokenFromEnv(email: string): string | undefined {\n\tconst value = process.env[AUTH_API_TOKENS_ENV]\n\tif (!value) {\n\t\treturn undefined\n\t}\n\n\tfor (const entry of value.split(\",\")) {\n\t\tconst separatorIndex = entry.indexOf(\":\")\n\t\tif (separatorIndex === -1) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst entryEmail = entry.slice(0, separatorIndex).trim()\n\t\tconst token = entry.slice(separatorIndex + 1).trim()\n\t\tif (entryEmail === email && token) {\n\t\t\treturn token\n\t\t}\n\t}\n\n\treturn undefined\n}\n\n/** Client for interacting with the authentication service to manage tokens */\nexport class AuthenticationApiClient {\n\tprivate authToken?: string\n\tprivate _context?: APIRequestContext\n\n\tconstructor(\n\t\tprivate readonly baseURL: string,\n\t\tprivate readonly auth: AuthConfig,\n\t) {\n\t\tthis.authToken = getAuthApiTokenFromEnv(auth.email)\n\t}\n\n\tprivate async getContext(): Promise<APIRequestContext> {\n\t\tif (!this._context) {\n\t\t\tthis._context = await request.newContext({\n\t\t\t\tbaseURL: this.baseURL,\n\t\t\t})\n\t\t}\n\n\t\treturn this._context\n\t}\n\n\tprivate async login(): Promise<string> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(\"login\", {\n\t\t\tdata: {\n\t\t\t\temail: this.auth.email,\n\t\t\t\tpassword: this.auth.password,\n\t\t\t},\n\t\t})\n\n\t\tconst token = await result.text()\n\t\tif (!result.ok() || !token) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Authentication failed, no token received.\")\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `generated user token for ${this.auth.email} from auth service`,\n\t\t})\n\n\t\treturn token\n\t}\n\n\t/** Return an api user token. Creates one if needed. */\n\tasync getToken(): Promise<string> {\n\t\tif (!this.authToken) {\n\t\t\tthis.authToken = await this.login()\n\t\t}\n\n\t\treturn this.authToken\n\t}\n\n\t/** Return an api user token. Creates one if needed. */\n\tasync getMachine2MachineToken(repository: string): Promise<string> {\n\t\tif (!this.authToken) {\n\t\t\tthis.authToken = await this.login()\n\t\t}\n\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(\"machine2machine\", {\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${this.authToken}`,\n\t\t\t\trepository,\n\t\t\t},\n\t\t})\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Machine2Machine token generation failed, no token received.\")\n\t\t}\n\t\tconst token = (await result.json()).token\n\n\t\treturn token\n\t}\n}\n"],"mappings":";;;AAMA,MAAM,sBAAsB;AAE5B,SAAS,uBAAuB,OAAmC;CAClE,MAAM,QAAQ,QAAQ,IAAI;CAC1B,IAAI,CAAC,OACJ;CAGD,KAAK,MAAM,SAAS,MAAM,MAAM,GAAG,GAAG;EACrC,MAAM,iBAAiB,MAAM,QAAQ,GAAG;EACxC,IAAI,mBAAmB,IACtB;EAGD,MAAM,aAAa,MAAM,MAAM,GAAG,cAAc,CAAC,CAAC,KAAK;EACvD,MAAM,QAAQ,MAAM,MAAM,iBAAiB,CAAC,CAAC,CAAC,KAAK;EACnD,IAAI,eAAe,SAAS,OAC3B,OAAO;CAET;AAGD;;AAGA,IAAa,0BAAb,MAAqC;CAKlB;CACA;CALlB;CACA;CAEA,YACC,SACA,MACC;EAFgB,KAAA,UAAA;EACA,KAAA,OAAA;EAEjB,KAAK,YAAY,uBAAuB,KAAK,KAAK;
|
|
1
|
+
{"version":3,"file":"authenticationApi.cjs","names":["request","logger"],"sources":["../../src/clients/authenticationApi.ts"],"sourcesContent":["import type { APIRequestContext } from \"@playwright/test\"\nimport { request } from \"@playwright/test\"\n\nimport type { AuthConfig } from \"../types\"\nimport { logPlaywrightApiResponse, logger } from \"../utils/log\"\n\nconst AUTH_API_TOKENS_ENV = \"PRISMIC_E2E_TEST_UTILS_AUTH_API_TOKENS\"\n\nfunction getAuthApiTokenFromEnv(email: string): string | undefined {\n\tconst value = process.env[AUTH_API_TOKENS_ENV]\n\tif (!value) {\n\t\treturn undefined\n\t}\n\n\tfor (const entry of value.split(\",\")) {\n\t\tconst separatorIndex = entry.indexOf(\":\")\n\t\tif (separatorIndex === -1) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst entryEmail = entry.slice(0, separatorIndex).trim()\n\t\tconst token = entry.slice(separatorIndex + 1).trim()\n\t\tif (entryEmail === email && token) {\n\t\t\treturn token\n\t\t}\n\t}\n\n\treturn undefined\n}\n\n/** Client for interacting with the authentication service to manage tokens */\nexport class AuthenticationApiClient {\n\tprivate authToken?: string\n\tprivate _context?: APIRequestContext\n\n\tconstructor(\n\t\tprivate readonly baseURL: string,\n\t\tprivate readonly auth: AuthConfig,\n\t) {\n\t\tthis.authToken = getAuthApiTokenFromEnv(auth.email)\n\t\tif (this.authToken) {\n\t\t\tlogger.info(`using user token for ${auth.email} from ${AUTH_API_TOKENS_ENV}`)\n\t\t}\n\t}\n\n\tprivate async getContext(): Promise<APIRequestContext> {\n\t\tif (!this._context) {\n\t\t\tthis._context = await request.newContext({\n\t\t\t\tbaseURL: this.baseURL,\n\t\t\t})\n\t\t}\n\n\t\treturn this._context\n\t}\n\n\tprivate async login(): Promise<string> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(\"login\", {\n\t\t\tdata: {\n\t\t\t\temail: this.auth.email,\n\t\t\t\tpassword: this.auth.password,\n\t\t\t},\n\t\t})\n\n\t\tconst token = await result.text()\n\t\tif (!result.ok() || !token) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Authentication failed, no token received.\")\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `generated user token for ${this.auth.email} from auth service`,\n\t\t})\n\n\t\treturn token\n\t}\n\n\t/** Return an api user token. Creates one if needed. */\n\tasync getToken(): Promise<string> {\n\t\tif (!this.authToken) {\n\t\t\tthis.authToken = await this.login()\n\t\t}\n\n\t\treturn this.authToken\n\t}\n\n\t/** Return an api user token. Creates one if needed. */\n\tasync getMachine2MachineToken(repository: string): Promise<string> {\n\t\tif (!this.authToken) {\n\t\t\tthis.authToken = await this.login()\n\t\t}\n\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(\"machine2machine\", {\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${this.authToken}`,\n\t\t\t\trepository,\n\t\t\t},\n\t\t})\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Machine2Machine token generation failed, no token received.\")\n\t\t}\n\t\tconst token = (await result.json()).token\n\n\t\treturn token\n\t}\n}\n"],"mappings":";;;AAMA,MAAM,sBAAsB;AAE5B,SAAS,uBAAuB,OAAmC;CAClE,MAAM,QAAQ,QAAQ,IAAI;CAC1B,IAAI,CAAC,OACJ;CAGD,KAAK,MAAM,SAAS,MAAM,MAAM,GAA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M,KAAK,MAAM;EAInC,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,IAAI,mBAAmB,EACnD,SAAS;GACR,eAAe,UAAU,KAAK;GAC9B;EACD,EACD,CAAC;EAED,IAAI,CAAC,OAAO,GAAG,GAAG;GACjB,YAAA,yBAAyB,MAAM;GAC/B,MAAM,IAAI,MAAM,6DAA6D;EAC9E;EAGA,QAFe,MAAM,OAAO,KAAK,EAAA,CAAG;CAGrC;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticationApi.d.cts","names":[],"sources":["../../src/clients/authenticationApi.ts"],"mappings":";;;;cA+Ba,uBAAA;EAAA,iBAKM,OAAA;EAAA,iBACA,IAAA;EAAA,QALV,SAAA;EAAA,QACA,QAAA;cAGU,OAAA,UACA,IAAA,EAAM,UAAA;EAAA,
|
|
1
|
+
{"version":3,"file":"authenticationApi.d.cts","names":[],"sources":["../../src/clients/authenticationApi.ts"],"mappings":";;;;cA+Ba,uBAAA;EAAA,iBAKM,OAAA;EAAA,iBACA,IAAA;EAAA,QALV,SAAA;EAAA,QACA,QAAA;cAGU,OAAA,UACA,IAAA,EAAM,UAAA;EAAA,QAQV,UAAA;EAAA,QAUA,KAAA;EAkC4C;EATpD,QAAA,IAAY,OAAA;EA3CA;EAoDZ,uBAAA,CAAwB,UAAA,WAAqB,OAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticationApi.d.ts","names":[],"sources":["../../src/clients/authenticationApi.ts"],"mappings":";;;;cA+Ba,uBAAA;EAAA,iBAKM,OAAA;EAAA,iBACA,IAAA;EAAA,QALV,SAAA;EAAA,QACA,QAAA;cAGU,OAAA,UACA,IAAA,EAAM,UAAA;EAAA,
|
|
1
|
+
{"version":3,"file":"authenticationApi.d.ts","names":[],"sources":["../../src/clients/authenticationApi.ts"],"mappings":";;;;cA+Ba,uBAAA;EAAA,iBAKM,OAAA;EAAA,iBACA,IAAA;EAAA,QALV,SAAA;EAAA,QACA,QAAA;cAGU,OAAA,UACA,IAAA,EAAM,UAAA;EAAA,QAQV,UAAA;EAAA,QAUA,KAAA;EAkC4C;EATpD,QAAA,IAAY,OAAA;EA3CA;EAoDZ,uBAAA,CAAwB,UAAA,WAAqB,OAAA;AAAA"}
|
|
@@ -23,6 +23,7 @@ var AuthenticationApiClient = class {
|
|
|
23
23
|
this.baseURL = baseURL;
|
|
24
24
|
this.auth = auth;
|
|
25
25
|
this.authToken = getAuthApiTokenFromEnv(auth.email);
|
|
26
|
+
if (this.authToken) logger.info(`using user token for ${auth.email} from ${AUTH_API_TOKENS_ENV}`);
|
|
26
27
|
}
|
|
27
28
|
async getContext() {
|
|
28
29
|
if (!this._context) this._context = await request.newContext({ baseURL: this.baseURL });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticationApi.js","names":[],"sources":["../../src/clients/authenticationApi.ts"],"sourcesContent":["import type { APIRequestContext } from \"@playwright/test\"\nimport { request } from \"@playwright/test\"\n\nimport type { AuthConfig } from \"../types\"\nimport { logPlaywrightApiResponse, logger } from \"../utils/log\"\n\nconst AUTH_API_TOKENS_ENV = \"PRISMIC_E2E_TEST_UTILS_AUTH_API_TOKENS\"\n\nfunction getAuthApiTokenFromEnv(email: string): string | undefined {\n\tconst value = process.env[AUTH_API_TOKENS_ENV]\n\tif (!value) {\n\t\treturn undefined\n\t}\n\n\tfor (const entry of value.split(\",\")) {\n\t\tconst separatorIndex = entry.indexOf(\":\")\n\t\tif (separatorIndex === -1) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst entryEmail = entry.slice(0, separatorIndex).trim()\n\t\tconst token = entry.slice(separatorIndex + 1).trim()\n\t\tif (entryEmail === email && token) {\n\t\t\treturn token\n\t\t}\n\t}\n\n\treturn undefined\n}\n\n/** Client for interacting with the authentication service to manage tokens */\nexport class AuthenticationApiClient {\n\tprivate authToken?: string\n\tprivate _context?: APIRequestContext\n\n\tconstructor(\n\t\tprivate readonly baseURL: string,\n\t\tprivate readonly auth: AuthConfig,\n\t) {\n\t\tthis.authToken = getAuthApiTokenFromEnv(auth.email)\n\t}\n\n\tprivate async getContext(): Promise<APIRequestContext> {\n\t\tif (!this._context) {\n\t\t\tthis._context = await request.newContext({\n\t\t\t\tbaseURL: this.baseURL,\n\t\t\t})\n\t\t}\n\n\t\treturn this._context\n\t}\n\n\tprivate async login(): Promise<string> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(\"login\", {\n\t\t\tdata: {\n\t\t\t\temail: this.auth.email,\n\t\t\t\tpassword: this.auth.password,\n\t\t\t},\n\t\t})\n\n\t\tconst token = await result.text()\n\t\tif (!result.ok() || !token) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Authentication failed, no token received.\")\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `generated user token for ${this.auth.email} from auth service`,\n\t\t})\n\n\t\treturn token\n\t}\n\n\t/** Return an api user token. Creates one if needed. */\n\tasync getToken(): Promise<string> {\n\t\tif (!this.authToken) {\n\t\t\tthis.authToken = await this.login()\n\t\t}\n\n\t\treturn this.authToken\n\t}\n\n\t/** Return an api user token. Creates one if needed. */\n\tasync getMachine2MachineToken(repository: string): Promise<string> {\n\t\tif (!this.authToken) {\n\t\t\tthis.authToken = await this.login()\n\t\t}\n\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(\"machine2machine\", {\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${this.authToken}`,\n\t\t\t\trepository,\n\t\t\t},\n\t\t})\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Machine2Machine token generation failed, no token received.\")\n\t\t}\n\t\tconst token = (await result.json()).token\n\n\t\treturn token\n\t}\n}\n"],"mappings":";;;AAMA,MAAM,sBAAsB;AAE5B,SAAS,uBAAuB,OAAmC;CAClE,MAAM,QAAQ,QAAQ,IAAI;CAC1B,IAAI,CAAC,OACJ;CAGD,KAAK,MAAM,SAAS,MAAM,MAAM,GAAG,GAAG;EACrC,MAAM,iBAAiB,MAAM,QAAQ,GAAG;EACxC,IAAI,mBAAmB,IACtB;EAGD,MAAM,aAAa,MAAM,MAAM,GAAG,cAAc,CAAC,CAAC,KAAK;EACvD,MAAM,QAAQ,MAAM,MAAM,iBAAiB,CAAC,CAAC,CAAC,KAAK;EACnD,IAAI,eAAe,SAAS,OAC3B,OAAO;CAET;AAGD;;AAGA,IAAa,0BAAb,MAAqC;CAKlB;CACA;CALlB;CACA;CAEA,YACC,SACA,MACC;EAFgB,KAAA,UAAA;EACA,KAAA,OAAA;EAEjB,KAAK,YAAY,uBAAuB,KAAK,KAAK;
|
|
1
|
+
{"version":3,"file":"authenticationApi.js","names":[],"sources":["../../src/clients/authenticationApi.ts"],"sourcesContent":["import type { APIRequestContext } from \"@playwright/test\"\nimport { request } from \"@playwright/test\"\n\nimport type { AuthConfig } from \"../types\"\nimport { logPlaywrightApiResponse, logger } from \"../utils/log\"\n\nconst AUTH_API_TOKENS_ENV = \"PRISMIC_E2E_TEST_UTILS_AUTH_API_TOKENS\"\n\nfunction getAuthApiTokenFromEnv(email: string): string | undefined {\n\tconst value = process.env[AUTH_API_TOKENS_ENV]\n\tif (!value) {\n\t\treturn undefined\n\t}\n\n\tfor (const entry of value.split(\",\")) {\n\t\tconst separatorIndex = entry.indexOf(\":\")\n\t\tif (separatorIndex === -1) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst entryEmail = entry.slice(0, separatorIndex).trim()\n\t\tconst token = entry.slice(separatorIndex + 1).trim()\n\t\tif (entryEmail === email && token) {\n\t\t\treturn token\n\t\t}\n\t}\n\n\treturn undefined\n}\n\n/** Client for interacting with the authentication service to manage tokens */\nexport class AuthenticationApiClient {\n\tprivate authToken?: string\n\tprivate _context?: APIRequestContext\n\n\tconstructor(\n\t\tprivate readonly baseURL: string,\n\t\tprivate readonly auth: AuthConfig,\n\t) {\n\t\tthis.authToken = getAuthApiTokenFromEnv(auth.email)\n\t\tif (this.authToken) {\n\t\t\tlogger.info(`using user token for ${auth.email} from ${AUTH_API_TOKENS_ENV}`)\n\t\t}\n\t}\n\n\tprivate async getContext(): Promise<APIRequestContext> {\n\t\tif (!this._context) {\n\t\t\tthis._context = await request.newContext({\n\t\t\t\tbaseURL: this.baseURL,\n\t\t\t})\n\t\t}\n\n\t\treturn this._context\n\t}\n\n\tprivate async login(): Promise<string> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(\"login\", {\n\t\t\tdata: {\n\t\t\t\temail: this.auth.email,\n\t\t\t\tpassword: this.auth.password,\n\t\t\t},\n\t\t})\n\n\t\tconst token = await result.text()\n\t\tif (!result.ok() || !token) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Authentication failed, no token received.\")\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `generated user token for ${this.auth.email} from auth service`,\n\t\t})\n\n\t\treturn token\n\t}\n\n\t/** Return an api user token. Creates one if needed. */\n\tasync getToken(): Promise<string> {\n\t\tif (!this.authToken) {\n\t\t\tthis.authToken = await this.login()\n\t\t}\n\n\t\treturn this.authToken\n\t}\n\n\t/** Return an api user token. Creates one if needed. */\n\tasync getMachine2MachineToken(repository: string): Promise<string> {\n\t\tif (!this.authToken) {\n\t\t\tthis.authToken = await this.login()\n\t\t}\n\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(\"machine2machine\", {\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${this.authToken}`,\n\t\t\t\trepository,\n\t\t\t},\n\t\t})\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Machine2Machine token generation failed, no token received.\")\n\t\t}\n\t\tconst token = (await result.json()).token\n\n\t\treturn token\n\t}\n}\n"],"mappings":";;;AAMA,MAAM,sBAAsB;AAE5B,SAA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,KAAK;CACb;;CAGA,MAAM,wBAAwB,YAAqC;EAClE,IAAI,CAAC,KAAK,WACT,KAAK,YAAY,MAAM,KAAK,MAAM;EAInC,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,IAAI,mBAAmB,EACnD,SAAS;GACR,eAAe,UAAU,KAAK;GAC9B;EACD,EACD,CAAC;EAED,IAAI,CAAC,OAAO,GAAG,GAAG;GACjB,yBAAyB,MAAM;GAC/B,MAAM,IAAI,MAAM,6DAA6D;EAC9E;EAGA,QAFe,MAAM,OAAO,KAAK,EAAA,CAAG;CAGrC;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customTypesApi.cjs","names":["AuthenticatedApiClient","logger"],"sources":["../../src/clients/customTypesApi.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"customTypesApi.cjs","names":["AuthenticatedApiClient","logger"],"sources":["../../src/clients/customTypesApi.ts"],"sourcesContent":["import type { DynamicCustomTypeModel, SharedSliceModel } from \"@prismicio/types-internal\"\nimport isEqual from \"lodash.isequal\"\n\nimport { logPlaywrightApiResponse, logger } from \"../utils/log\"\nimport type { AuthServerToken } from \"./apiClient\"\nimport { AuthenticatedApiClient } from \"./apiClient\"\n\ntype ItemType = DynamicCustomTypeModel | SharedSliceModel\ntype ItemTypePath = \"customtypes\" | \"slices\"\ntype ItemOperation = \"insert\" | \"update\"\n\n/** Client for interacting with the Custom Types API to create/update custom types and slices. */\nexport class CustomTypesApiClient extends AuthenticatedApiClient {\n\tconstructor(baseURL: string, config: { authToken: AuthServerToken; repository: string }) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository })\n\t}\n\n\t/**\n\t * Create or update a custom type or slice.\n\t *\n\t * @param endpoint - - The API endpoint for custom types or slices ('customtypes' or 'slices').\n\t * @param data - - The data representing the custom type or slice.\n\t * @throws Error if the item status cannot be retrieved or the item cannot be\n\t * created/updated.\n\t */\n\tprivate async upsert(endpoint: ItemTypePath, operation: ItemOperation, data: ItemType) {\n\t\tconst profiler = logger.startTimer()\n\t\tconst path = `${endpoint}/${operation}`\n\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(path, { data })\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not ${operation} item`)\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `called customtypes api /${path} for item with id '${data.id}'`,\n\t\t})\n\t}\n\n\tprivate async getRemoteItems(endpoint: ItemTypePath): Promise<DynamicCustomTypeModel[] | SharedSliceModel[]> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(endpoint)\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not get items status from the Custom Type api.\")\n\t\t}\n\n\t\treturn result.json()\n\t}\n\n\tprivate async getDifference(\n\t\tremoteItems: DynamicCustomTypeModel[] | SharedSliceModel[],\n\t\tlocal: ItemType,\n\t): Promise<ItemOperation | undefined> {\n\t\tconst remoteItem = remoteItems.find(\n\t\t\t(remote: DynamicCustomTypeModel | SharedSliceModel) => remote.id === local.id,\n\t\t)\n\t\tif (!remoteItem) {\n\t\t\treturn \"insert\"\n\t\t}\n\t\tif (!isEqual(local, remoteItem)) {\n\t\t\treturn \"update\"\n\t\t}\n\n\t\treturn\n\t}\n\n\t/** Create items only if they have changed compared to their remote status */\n\tprivate async upsertIfChanged(\n\t\titemType: ItemTypePath,\n\t\tlocalItems: ItemType[] = [],\n\t): Promise<void> {\n\t\tconst remoteItems = await this.getRemoteItems(itemType)\n\t\tawait Promise.all(\n\t\t\tlocalItems.map(async (localItem) => {\n\t\t\t\tconst operation = await this.getDifference(remoteItems, localItem)\n\n\t\t\t\treturn operation && this.upsert(itemType, operation, localItem)\n\t\t\t}),\n\t\t)\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: DynamicCustomTypeModel[] = []): Promise<void> {\n\t\tawait this.upsertIfChanged(\"customtypes\", customTypes)\n\t}\n\n\tasync deleteCustomType(customTypeId: string): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.delete(`customtypes/${customTypeId}`)\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not delete ${customTypeId} from the Custom Type api.`)\n\t\t}\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: SharedSliceModel[] = []): Promise<void> {\n\t\tawait this.upsertIfChanged(\"slices\", slices)\n\t}\n\n\t/**\n\t * Get a custom type by its id.\n\t *\n\t * @param customTypeId - The id of the custom type to get.\n\t */\n\tasync getTypeById(customTypeId: string): Promise<DynamicCustomTypeModel> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(`customtypes/${customTypeId}`)\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not get ${customTypeId} type from the Custom Type api.`)\n\t\t}\n\n\t\treturn result.json()\n\t}\n}\n"],"mappings":";;;;;;;AAYA,IAAa,uBAAb,cAA0CA,kBAAAA,uBAAuB;CAChE,YAAY,SAAiB,QAA4D;EACxF,MAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,WAAW,CAAC;CACnE;;;;;;;;;CAUA,MAAc,OAAO,UAAwB,WAA0B,MAAgB;EACtF,MAAM,WAAWC,YAAAA,OAAO,WAAW;EACnC,MAAM,OAAO,GAAG,SAAS,GAAG;EAG5B,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,KAAK,MAAM,EAAE,KAAK,CAAC;EAChD,IAAI,CAAC,OAAO,GAAG,GAAG;GACjB,YAAA,yBAAyB,MAAM;GAC/B,MAAM,IAAI,MAAM,aAAa,UAAU,MAAM;EAC9C;EACA,SAAS,KAAK,EACb,SAAS,2BAA2B,KAAK,qBAAqB,KAAK,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AAG;GACjB,YAAA,yBAAyB,MAAM;GAC/B,MAAM,IAAI,MAAM,iBAAiB,aAAa,gCAAgC;EAC/E;EAEA,OAAO,OAAO,KAAK;CACpB;AACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AuthServerToken, AuthenticatedApiClient } from "./apiClient.cjs";
|
|
2
|
-
import {
|
|
2
|
+
import { DynamicCustomTypeModel, SharedSliceModel } from "@prismicio/types-internal";
|
|
3
3
|
|
|
4
4
|
//#region src/clients/customTypesApi.d.ts
|
|
5
5
|
/** Client for interacting with the Custom Types API to create/update custom types and slices. */
|
|
@@ -26,7 +26,7 @@ declare class CustomTypesApiClient extends AuthenticatedApiClient {
|
|
|
26
26
|
*
|
|
27
27
|
* @param customTypes
|
|
28
28
|
*/
|
|
29
|
-
createCustomTypes(customTypes?:
|
|
29
|
+
createCustomTypes(customTypes?: DynamicCustomTypeModel[]): Promise<void>;
|
|
30
30
|
deleteCustomType(customTypeId: string): Promise<void>;
|
|
31
31
|
/**
|
|
32
32
|
* Create slices using the Custom types api.
|
|
@@ -39,7 +39,7 @@ declare class CustomTypesApiClient extends AuthenticatedApiClient {
|
|
|
39
39
|
*
|
|
40
40
|
* @param customTypeId - The id of the custom type to get.
|
|
41
41
|
*/
|
|
42
|
-
getTypeById(customTypeId: string): Promise<
|
|
42
|
+
getTypeById(customTypeId: string): Promise<DynamicCustomTypeModel>;
|
|
43
43
|
}
|
|
44
44
|
//#endregion
|
|
45
45
|
export { CustomTypesApiClient };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customTypesApi.d.cts","names":[],"sources":["../../src/clients/customTypesApi.ts"],"mappings":";;;;;cAYa,oBAAA,SAA6B,sBAAA;cAC7B,OAAA,UAAiB,MAAA;IAAU,SAAA,EAAW,eAAA;IAAiB,UAAA;EAAA;
|
|
1
|
+
{"version":3,"file":"customTypesApi.d.cts","names":[],"sources":["../../src/clients/customTypesApi.ts"],"mappings":";;;;;cAYa,oBAAA,SAA6B,sBAAA;cAC7B,OAAA,UAAiB,MAAA;IAAU,SAAA,EAAW,eAAA;IAAiB,UAAA;EAAA;EA4EE;;;;;;;;EAAA,QAhEvD,MAAA;EAAA,QAeA,cAAA;EAAA,QAYA,aAAA;EAvCF;EAAA,QAyDE,eAAA;EAzDoC;;;;;EA4E5C,iBAAA,CAAkB,WAAA,GAAa,sBAAA,KAAgC,OAAA;EAI/D,gBAAA,CAAiB,YAAA,WAAuB,OAAA;EAJxC;;;;;EAmBA,YAAA,CAAa,MAAA,GAAQ,gBAAA,KAA0B,OAAA;EAfP;;;;;EAwBxC,WAAA,CAAY,YAAA,WAAuB,OAAA,CAAQ,sBAAA;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AuthServerToken, AuthenticatedApiClient } from "./apiClient.js";
|
|
2
|
-
import {
|
|
2
|
+
import { DynamicCustomTypeModel, SharedSliceModel } from "@prismicio/types-internal";
|
|
3
3
|
|
|
4
4
|
//#region src/clients/customTypesApi.d.ts
|
|
5
5
|
/** Client for interacting with the Custom Types API to create/update custom types and slices. */
|
|
@@ -26,7 +26,7 @@ declare class CustomTypesApiClient extends AuthenticatedApiClient {
|
|
|
26
26
|
*
|
|
27
27
|
* @param customTypes
|
|
28
28
|
*/
|
|
29
|
-
createCustomTypes(customTypes?:
|
|
29
|
+
createCustomTypes(customTypes?: DynamicCustomTypeModel[]): Promise<void>;
|
|
30
30
|
deleteCustomType(customTypeId: string): Promise<void>;
|
|
31
31
|
/**
|
|
32
32
|
* Create slices using the Custom types api.
|
|
@@ -39,7 +39,7 @@ declare class CustomTypesApiClient extends AuthenticatedApiClient {
|
|
|
39
39
|
*
|
|
40
40
|
* @param customTypeId - The id of the custom type to get.
|
|
41
41
|
*/
|
|
42
|
-
getTypeById(customTypeId: string): Promise<
|
|
42
|
+
getTypeById(customTypeId: string): Promise<DynamicCustomTypeModel>;
|
|
43
43
|
}
|
|
44
44
|
//#endregion
|
|
45
45
|
export { CustomTypesApiClient };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customTypesApi.d.ts","names":[],"sources":["../../src/clients/customTypesApi.ts"],"mappings":";;;;;cAYa,oBAAA,SAA6B,sBAAA;cAC7B,OAAA,UAAiB,MAAA;IAAU,SAAA,EAAW,eAAA;IAAiB,UAAA;EAAA;
|
|
1
|
+
{"version":3,"file":"customTypesApi.d.ts","names":[],"sources":["../../src/clients/customTypesApi.ts"],"mappings":";;;;;cAYa,oBAAA,SAA6B,sBAAA;cAC7B,OAAA,UAAiB,MAAA;IAAU,SAAA,EAAW,eAAA;IAAiB,UAAA;EAAA;EA4EE;;;;;;;;EAAA,QAhEvD,MAAA;EAAA,QAeA,cAAA;EAAA,QAYA,aAAA;EAvCF;EAAA,QAyDE,eAAA;EAzDoC;;;;;EA4E5C,iBAAA,CAAkB,WAAA,GAAa,sBAAA,KAAgC,OAAA;EAI/D,gBAAA,CAAiB,YAAA,WAAuB,OAAA;EAJxC;;;;;EAmBA,YAAA,CAAa,MAAA,GAAQ,gBAAA,KAA0B,OAAA;EAfP;;;;;EAwBxC,WAAA,CAAY,YAAA,WAAuB,OAAA,CAAQ,sBAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customTypesApi.js","names":[],"sources":["../../src/clients/customTypesApi.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"customTypesApi.js","names":[],"sources":["../../src/clients/customTypesApi.ts"],"sourcesContent":["import type { DynamicCustomTypeModel, SharedSliceModel } from \"@prismicio/types-internal\"\nimport isEqual from \"lodash.isequal\"\n\nimport { logPlaywrightApiResponse, logger } from \"../utils/log\"\nimport type { AuthServerToken } from \"./apiClient\"\nimport { AuthenticatedApiClient } from \"./apiClient\"\n\ntype ItemType = DynamicCustomTypeModel | SharedSliceModel\ntype ItemTypePath = \"customtypes\" | \"slices\"\ntype ItemOperation = \"insert\" | \"update\"\n\n/** Client for interacting with the Custom Types API to create/update custom types and slices. */\nexport class CustomTypesApiClient extends AuthenticatedApiClient {\n\tconstructor(baseURL: string, config: { authToken: AuthServerToken; repository: string }) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository })\n\t}\n\n\t/**\n\t * Create or update a custom type or slice.\n\t *\n\t * @param endpoint - - The API endpoint for custom types or slices ('customtypes' or 'slices').\n\t * @param data - - The data representing the custom type or slice.\n\t * @throws Error if the item status cannot be retrieved or the item cannot be\n\t * created/updated.\n\t */\n\tprivate async upsert(endpoint: ItemTypePath, operation: ItemOperation, data: ItemType) {\n\t\tconst profiler = logger.startTimer()\n\t\tconst path = `${endpoint}/${operation}`\n\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(path, { data })\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not ${operation} item`)\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `called customtypes api /${path} for item with id '${data.id}'`,\n\t\t})\n\t}\n\n\tprivate async getRemoteItems(endpoint: ItemTypePath): Promise<DynamicCustomTypeModel[] | SharedSliceModel[]> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(endpoint)\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not get items status from the Custom Type api.\")\n\t\t}\n\n\t\treturn result.json()\n\t}\n\n\tprivate async getDifference(\n\t\tremoteItems: DynamicCustomTypeModel[] | SharedSliceModel[],\n\t\tlocal: ItemType,\n\t): Promise<ItemOperation | undefined> {\n\t\tconst remoteItem = remoteItems.find(\n\t\t\t(remote: DynamicCustomTypeModel | SharedSliceModel) => remote.id === local.id,\n\t\t)\n\t\tif (!remoteItem) {\n\t\t\treturn \"insert\"\n\t\t}\n\t\tif (!isEqual(local, remoteItem)) {\n\t\t\treturn \"update\"\n\t\t}\n\n\t\treturn\n\t}\n\n\t/** Create items only if they have changed compared to their remote status */\n\tprivate async upsertIfChanged(\n\t\titemType: ItemTypePath,\n\t\tlocalItems: ItemType[] = [],\n\t): Promise<void> {\n\t\tconst remoteItems = await this.getRemoteItems(itemType)\n\t\tawait Promise.all(\n\t\t\tlocalItems.map(async (localItem) => {\n\t\t\t\tconst operation = await this.getDifference(remoteItems, localItem)\n\n\t\t\t\treturn operation && this.upsert(itemType, operation, localItem)\n\t\t\t}),\n\t\t)\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: DynamicCustomTypeModel[] = []): Promise<void> {\n\t\tawait this.upsertIfChanged(\"customtypes\", customTypes)\n\t}\n\n\tasync deleteCustomType(customTypeId: string): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.delete(`customtypes/${customTypeId}`)\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not delete ${customTypeId} from the Custom Type api.`)\n\t\t}\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: SharedSliceModel[] = []): Promise<void> {\n\t\tawait this.upsertIfChanged(\"slices\", slices)\n\t}\n\n\t/**\n\t * Get a custom type by its id.\n\t *\n\t * @param customTypeId - The id of the custom type to get.\n\t */\n\tasync getTypeById(customTypeId: string): Promise<DynamicCustomTypeModel> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(`customtypes/${customTypeId}`)\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not get ${customTypeId} type from the Custom Type api.`)\n\t\t}\n\n\t\treturn result.json()\n\t}\n}\n"],"mappings":";;;;;AAYA,IAAa,uBAAb,cAA0C,uBAAuB;CAChE,YAAY,SAAiB,QAA4D;EACxF,MAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,WAAW,CAAC;CACnE;;;;;;;;;CAUA,MAAc,OAAO,UAAwB,WAA0B,MAAgB;EACtF,MAAM,WAAW,OAA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AM,oBAAoB,aAAa,2BAA2B;EAC7E;CACD;;;;;;CAOA,MAAM,aAAa,SAA6B,CAAC,GAAkB;EAClE,MAAM,KAAK,gBAAgB,UAAU,MAAM;CAC5C;;;;;;CAOA,MAAM,YAAY,cAAuD;EAExE,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,IAAI,eAAe,cAAc;EAE9D,IAAI,CAAC,OAAO,GAAG,GAAG;GACjB,yBAAyB,MAAM;GAC/B,MAAM,IAAI,MAAM,iBAAiB,aAAa,gCAAgC;EAC/E;EAEA,OAAO,OAAO,KAAK;CACpB;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.cjs","names":["getRepositoryUrl","ContentApiClient","logger","expect"],"sources":["../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\"\nimport type { StaticCustomTypeModel, SharedSliceModel } from \"@prismicio/types-internal\"\nimport type { AxiosResponse } from \"axios\"\n\nimport type { AssetApiClient } from \"../clients/assetApi\"\nimport type { AuthenticationApiClient } from \"../clients/authenticationApi\"\nimport { ContentApiClient } from \"../clients/contentApi\"\nimport type {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n\tCoreApiDocumentData,\n\tCoreApiDocumentsPayload,\n\tCoreApiDocumentsResponse,\n\tRelease,\n} from \"../clients/coreApi\"\nimport type { CustomTypesApiClient } from \"../clients/customTypesApi\"\nimport type { IntegrationFieldsClient } from \"../clients/integrationFields\"\nimport type { ManageV2Client } from \"../clients/manageV2\"\nimport type { MigrationApiClient } from \"../clients/migrationApi\"\nimport type { WroomClient } from \"../clients/wroom\"\nimport type { IntegrationFieldConfig } from \"../types\"\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\tprivate readonly integrationFieldsClient: IntegrationFieldsClient | undefined,\n\t) {}\n\n\tasync configure(config: RepositoryConfig): Promise<void> {\n\t\tconst hasLangConfig = config.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.simulatorURL) {\n\t\t\tawait this.setSimulatorURL(config.simulatorURL)\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\n\t\tif (config.integrationFields) {\n\t\t\tawait this.toggleIntegrationFields(true)\n\t\t\tawait this.setupIntegrationFields(config.integrationFields)\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 url. Uses Playwright\n\t * for requests so if your project uses Playwright too, any network request will be present in\n\t * Playwright test reports.\n\t */\n\tgetContentApiClient(config?: { version?: \"v1\" | \"v2\"; accessToken?: string }): 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 the locales already\n\t * exist.\n\t *\n\t * @param locales - An array of all locales to be added to the repository.\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(this.name, \"app/settings/multilanguages\", {\n\t\t\tlanguages: locales,\n\t\t})\n\n\t\tconst { data, status } = response\n\t\tconst success =\n\t\t\tstatus === 200 || (status === 400 && (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 the locales already\n\t * exist.\n\t *\n\t * @param locale - The locale to be added to the repository.\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 || (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 * @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 locale needs to\n\t * 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 update it.\n\t * @throws Error if setting the default locale fails.\n\t */\n\tasync setDefaultLocale(locale: string, action: \"create\" | \"update\"): 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 * Retrieves documents.\n\t *\n\t * @param args - Configure which documents are retrieved.\n\t * @returns A paginated set of documents.\n\t */\n\tasync getDocuments(args: CoreApiDocumentsPayload): Promise<CoreApiDocumentsResponse> {\n\t\treturn this.coreApiClient.getDocuments(args)\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\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 * Retrieves the migration release.\n\t *\n\t * @returns The migration relese metadata.\n\t */\n\tasync getMigrationRelease(): Promise<Release> {\n\t\tconst releases = await this.coreApiClient.getReleases()\n\t\tconst migrationRelease = releases.find((release) => release.migration)\n\t\tif (!migrationRelease) {\n\t\t\tthrow new Error(`The repository does not have a migration release`)\n\t\t}\n\n\t\treturn migrationRelease\n\t}\n\n\t/**\n\t * Publishes a release.\n\t *\n\t * @param id - The ID of the release.\n\t * @returns A Promise that resolves when the release is published and a new master ref is\n\t * available.\n\t */\n\tasync publishRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst contentApi = this.getContentApiClient()\n\t\tconst masterRef = await contentApi.getMasterRef()\n\t\tawait this.coreApiClient.publishRelease(id)\n\t\tawait expect\n\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\ttimeout: 10_000,\n\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t})\n\t\t\t.not.toBe(masterRef)\n\n\t\tprofiler.done({\n\t\t\tmessage: `release '${id}' published and new master ref available`,\n\t\t})\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\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(this.name, `app/releases/${id}/delete`, {})\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(this.name, `previews/new`, data)\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 * Set the simulator URL (table of slices) for a repository.\n\t *\n\t * @param data - The simulator URL to set.\n\t */\n\tasync setSimulatorURL(simulatorURL: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst repository = await this.coreApiClient.getRepository()\n\t\tawait this.coreApiClient.updateRepository({\n\t\t\t...repository,\n\t\t\tsimulator_url: simulatorURL,\n\t\t})\n\n\t\tprofiler.done({\n\t\t\tmessage: `simulator preview '${simulatorURL}' created`,\n\t\t})\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(this.name, `previews/delete/${id}`, {})\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(this.name, \"app/settings/webhooks/create\", {\n\t\t\tname,\n\t\t\turl,\n\t\t\tsecret,\n\t\t\tactive: active ? \"on\" : \"off\",\n\t\t\t...triggers,\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: StaticCustomTypeModel[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes)\n\t}\n\n\tasync deleteCustomType(customTypeId: string): Promise<void> {\n\t\tawait this.customTypesApiClient.deleteCustomType(customTypeId)\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: SharedSliceModel[]): 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 api is fully private\n\t * 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[]> = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"settings/security/contentapi\",\n\t\t)\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> = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/oauthapp\",\n\t\t\t\t{\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tthis.failIfNot200(response, `Could not create content api app ${appName}`)\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(this.name, \"settings/security/authorizations\", {\n\t\t\t\tapp: app.id,\n\t\t\t\tscope: tokenScope,\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 ${this.name}`,\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 ${this.name}`,\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 * Toggle the Integration Fields feature\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleIntegrationFields(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.toggleIntegrationFields({\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\"} Integration Fields for ${this.name}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Integration Fields ${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 && JSON.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(response, `Could not remove the user ${email} from the repository`)\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, either a string for\n\t * basic workflow or an object such as `{ \"lang_id\": \"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(email: string, role: string | Record<string, string>): 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 specific, use the\n\t * migration api client to create a document with the MigrationApiClient. See the\n\t * `getMigrationApiClient()` method.\n\t *\n\t * @example\n\t * \tTo create a document by converting it from the Page Builder to\n\t * \tCore api format\n\t *\n\t * \t```js\n\t * \timport { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';\n\t *\n\t * \tconst document = {\n\t * \ttitle: 'A new document',\n\t * \tcustom_type_id: 'home-page',\n\t * \tlocale: 'en-gb',\n\t * \tintegration_field_ids: [],\n\t * \ttags: [],\n\t * \tdata: DocumentLegacy.encode({\n\t * \tuid: {\n\t * \t__TYPE__: UIDContentType,\n\t * \tvalue: 'home-page',\n\t * \t},\n\t * \t})\n\t * \t}\n\t * \tawait repository.createDocument(document, 'published');\n\t * \t* ```\n\t * \t```\n\t *\n\t * \t@returns\n\t *\n\t * \t@param document - in the core api format.\n\t *\n\t * \t@param status - status of the document, if published, the function will\n\t * \twait 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\t/**\n\t * Retrieves data for a specific document version.\n\t *\n\t * @param versionId - The document's version ID.\n\t * @returns The document's version data.\n\t */\n\tasync getDocumentData(versionId: string): Promise<CoreApiDocumentData> {\n\t\treturn await this.coreApiClient.getDocumentData(versionId)\n\t}\n\n\tasync setupIntegrationFields(integrationFields: IntegrationFieldConfig[]): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tif (!this.integrationFieldsClient) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Integration Fields client not found. Did you provide a integration fields api url in the configuration?\",\n\t\t\t)\n\t\t}\n\n\t\tawait this.integrationFieldsClient.setupIntegrationFields(integrationFields)\n\t\tprofiler.done({\n\t\t\tmessage: `Integration Fields setup`,\n\t\t})\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale\n\tlocales?: string[]\n\tdefaultLocale?: string\n\tslices?: SharedSliceModel[]\n\tcustomTypes?: StaticCustomTypeModel[]\n\tpreview?: Preview\n\tsimulatorURL?: string\n\trolePerLocal?: boolean\n\tcustomRoles?: boolean\n\tintegrationFields?: IntegrationFieldConfig[]\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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a;GAChD,MAAM,KAAK,cAAc,aAAa,OAAO,EAAE;GAC/C,MAAMC,iBAAAA,OACJ,KAAK,YAAY,WAAW,aAAa,GAAG;IAC5C,SAAS;IACT,SAAS;GACV,CAAC,CAAC,CACD,IAAI,KAAK,SAAS;GACpB,WAAW;EACZ;EACA,SAAS,KAAK,EACb,QACD,CAAC;EAED,OAAO;CACR;;;;;;;CAQA,MAAM,gBAAgB,WAAiD;EACtE,OAAO,MAAM,KAAK,cAAc,gBAAgB,SAAS;CAC1D;CAEA,MAAM,uBAAuB,mBAA4D;EACxF,MAAM,WAAWD,YAAAA,OAAO,WAAW;EAEnC,IAAI,CAAC,KAAK,yBACT,MAAM,IAAI,MACT,yGACD;EAGD,MAAM,KAAK,wBAAwB,uBAAuB,iBAAiB;EAC3E,SAAS,KAAK,EACb,SAAS,2BACV,CAAC;CACF;AACD"}
|
|
1
|
+
{"version":3,"file":"repository.cjs","names":["getRepositoryUrl","ContentApiClient","logger","expect"],"sources":["../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\"\nimport type { DynamicCustomTypeModel, SharedSliceModel } from \"@prismicio/types-internal\"\nimport type { AxiosResponse } from \"axios\"\n\nimport type { AssetApiClient } from \"../clients/assetApi\"\nimport type { AuthenticationApiClient } from \"../clients/authenticationApi\"\nimport { ContentApiClient } from \"../clients/contentApi\"\nimport type {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n\tCoreApiDocumentData,\n\tCoreApiDocumentsPayload,\n\tCoreApiDocumentsResponse,\n\tRelease,\n} from \"../clients/coreApi\"\nimport type { CustomTypesApiClient } from \"../clients/customTypesApi\"\nimport type { IntegrationFieldsClient } from \"../clients/integrationFields\"\nimport type { ManageV2Client } from \"../clients/manageV2\"\nimport type { MigrationApiClient } from \"../clients/migrationApi\"\nimport type { WroomClient } from \"../clients/wroom\"\nimport type { IntegrationFieldConfig } from \"../types\"\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\tprivate readonly integrationFieldsClient: IntegrationFieldsClient | undefined,\n\t) {}\n\n\tasync configure(config: RepositoryConfig): Promise<void> {\n\t\tconst hasLangConfig = config.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.simulatorURL) {\n\t\t\tawait this.setSimulatorURL(config.simulatorURL)\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\n\t\tif (config.integrationFields) {\n\t\t\tawait this.toggleIntegrationFields(true)\n\t\t\tawait this.setupIntegrationFields(config.integrationFields)\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 url. Uses Playwright\n\t * for requests so if your project uses Playwright too, any network request will be present in\n\t * Playwright test reports.\n\t */\n\tgetContentApiClient(config?: { version?: \"v1\" | \"v2\"; accessToken?: string }): 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 the locales already\n\t * exist.\n\t *\n\t * @param locales - An array of all locales to be added to the repository.\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(this.name, \"app/settings/multilanguages\", {\n\t\t\tlanguages: locales,\n\t\t})\n\n\t\tconst { data, status } = response\n\t\tconst success =\n\t\t\tstatus === 200 || (status === 400 && (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 the locales already\n\t * exist.\n\t *\n\t * @param locale - The locale to be added to the repository.\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 || (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 * @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 locale needs to\n\t * 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 update it.\n\t * @throws Error if setting the default locale fails.\n\t */\n\tasync setDefaultLocale(locale: string, action: \"create\" | \"update\"): 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 * Retrieves documents.\n\t *\n\t * @param args - Configure which documents are retrieved.\n\t * @returns A paginated set of documents.\n\t */\n\tasync getDocuments(args: CoreApiDocumentsPayload): Promise<CoreApiDocumentsResponse> {\n\t\treturn this.coreApiClient.getDocuments(args)\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\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 * Retrieves the migration release.\n\t *\n\t * @returns The migration relese metadata.\n\t */\n\tasync getMigrationRelease(): Promise<Release> {\n\t\tconst releases = await this.coreApiClient.getReleases()\n\t\tconst migrationRelease = releases.find((release) => release.migration)\n\t\tif (!migrationRelease) {\n\t\t\tthrow new Error(`The repository does not have a migration release`)\n\t\t}\n\n\t\treturn migrationRelease\n\t}\n\n\t/**\n\t * Publishes a release.\n\t *\n\t * @param id - The ID of the release.\n\t * @returns A Promise that resolves when the release is published and a new master ref is\n\t * available.\n\t */\n\tasync publishRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst contentApi = this.getContentApiClient()\n\t\tconst masterRef = await contentApi.getMasterRef()\n\t\tawait this.coreApiClient.publishRelease(id)\n\t\tawait expect\n\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\ttimeout: 10_000,\n\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t})\n\t\t\t.not.toBe(masterRef)\n\n\t\tprofiler.done({\n\t\t\tmessage: `release '${id}' published and new master ref available`,\n\t\t})\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\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(this.name, `app/releases/${id}/delete`, {})\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(this.name, `previews/new`, data)\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 * Set the simulator URL (table of slices) for a repository.\n\t *\n\t * @param data - The simulator URL to set.\n\t */\n\tasync setSimulatorURL(simulatorURL: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst repository = await this.coreApiClient.getRepository()\n\t\tawait this.coreApiClient.updateRepository({\n\t\t\t...repository,\n\t\t\tsimulator_url: simulatorURL,\n\t\t})\n\n\t\tprofiler.done({\n\t\t\tmessage: `simulator preview '${simulatorURL}' created`,\n\t\t})\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(this.name, `previews/delete/${id}`, {})\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(this.name, \"app/settings/webhooks/create\", {\n\t\t\tname,\n\t\t\turl,\n\t\t\tsecret,\n\t\t\tactive: active ? \"on\" : \"off\",\n\t\t\t...triggers,\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: DynamicCustomTypeModel[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes)\n\t}\n\n\tasync deleteCustomType(customTypeId: string): Promise<void> {\n\t\tawait this.customTypesApiClient.deleteCustomType(customTypeId)\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: SharedSliceModel[]): 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 api is fully private\n\t * 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[]> = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"settings/security/contentapi\",\n\t\t)\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> = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/oauthapp\",\n\t\t\t\t{\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tthis.failIfNot200(response, `Could not create content api app ${appName}`)\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(this.name, \"settings/security/authorizations\", {\n\t\t\t\tapp: app.id,\n\t\t\t\tscope: tokenScope,\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 ${this.name}`,\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 ${this.name}`,\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 * Toggle the Integration Fields feature\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleIntegrationFields(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.toggleIntegrationFields({\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\"} Integration Fields for ${this.name}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Integration Fields ${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 && JSON.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(response, `Could not remove the user ${email} from the repository`)\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, either a string for\n\t * basic workflow or an object such as `{ \"lang_id\": \"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(email: string, role: string | Record<string, string>): 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 specific, use the\n\t * migration api client to create a document with the MigrationApiClient. See the\n\t * `getMigrationApiClient()` method.\n\t *\n\t * @example\n\t * \tTo create a document by converting it from the Page Builder to\n\t * \tCore api format\n\t *\n\t * \t```js\n\t * \timport { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';\n\t *\n\t * \tconst document = {\n\t * \ttitle: 'A new document',\n\t * \tcustom_type_id: 'home-page',\n\t * \tlocale: 'en-gb',\n\t * \tintegration_field_ids: [],\n\t * \ttags: [],\n\t * \tdata: DocumentLegacy.encode({\n\t * \tuid: {\n\t * \t__TYPE__: UIDContentType,\n\t * \tvalue: 'home-page',\n\t * \t},\n\t * \t})\n\t * \t}\n\t * \tawait repository.createDocument(document, 'published');\n\t * \t* ```\n\t * \t```\n\t *\n\t * \t@returns\n\t *\n\t * \t@param document - in the core api format.\n\t *\n\t * \t@param status - status of the document, if published, the function will\n\t * \twait 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\t/**\n\t * Retrieves data for a specific document version.\n\t *\n\t * @param versionId - The document's version ID.\n\t * @returns The document's version data.\n\t */\n\tasync getDocumentData(versionId: string): Promise<CoreApiDocumentData> {\n\t\treturn await this.coreApiClient.getDocumentData(versionId)\n\t}\n\n\tasync setupIntegrationFields(integrationFields: IntegrationFieldConfig[]): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tif (!this.integrationFieldsClient) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Integration Fields client not found. Did you provide a integration fields api url in the configuration?\",\n\t\t\t)\n\t\t}\n\n\t\tawait this.integrationFieldsClient.setupIntegrationFields(integrationFields)\n\t\tprofiler.done({\n\t\t\tmessage: `Integration Fields setup`,\n\t\t})\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale\n\tlocales?: string[]\n\tdefaultLocale?: string\n\tslices?: SharedSliceModel[]\n\tcustomTypes?: DynamicCustomTypeModel[]\n\tpreview?: Preview\n\tsimulatorURL?: string\n\trolePerLocal?: boolean\n\tcustomRoles?: boolean\n\tintegrationFields?: IntegrationFieldConfig[]\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"],"mappings":";;;;;;AA0BA,IAAa,oBAAb,MAA+B;CAEpB;CACQ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CATlB,YACC,MACA,eACA,eACA,aACA,sBACA,oBACA,gBACA,gBACA,yBACC;EATQ,KAAA,OAAA;EACQ,KAAA,gBAAA;EACA,KAAA,gBAAA;EACA,KAAA,cAAA;EACA,KAAA,uBAAA;EACA,KAAA,qBAAA;EACA,KAAA,iBAAA;EACA,KAAA,iBAAA;EACA,KAAA,0BAAA;CACf;CAEH,MAAM,UAAU,QAAyC;EAExD,IADsB,OAAO,iBAAiB,OAAO,WAAW,OAAO,cACpD;GAClB,MAAM,YAAY,MAAM,KAAK,cAAc,aAAa;GACxD,IAAI,8BAA8B;GAElC,IAAI,OAAO,eAAe;IACzB,MAAM,SAAS,UAAU,MAAM,EAAE,gBAAgB,cAAc,IAAI;IACnE,IAAI,CAAC,QACJ,MAAM,KAAK,iBAAiB,OAAO,eAAe,QAAQ;SACpD,IAAI,OAAO,OAAO,OAAO,eAE/B,8BAA8B;GAEhC;GAEA,IAAI,OAAO,SAAS;IAEnB,MAAM,eAAe,OAAO,QAAQ,QAClC,OAAO,CAAC,UAAU,MAAM,aAAa,SAAS,OAAO,EAAE,CACzD;IACA,IAAI,aAAa,SAAS,GACzB,MAAM,KAAK,cAAc,YAAY;GAEvC;GAEA,IAAI,OAAO;QACN,CAAC,UAAU,MAAM,EAAE,SAAS,OAAO,OAAO,cAAc,KAAK,EAAE,GAClE,MAAM,KAAK,mBAAmB,OAAO,YAAY;GAAA;GAInD,IAAI,OAAO,iBAAiB,6BAC3B,MAAM,KAAK,iBAAiB,OAAO,eAAe,QAAQ;EAE5D;EAEA,IAAI,OAAO,QACV,MAAM,KAAK,aAAa,OAAO,M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,QAAQ;EAE5D,IAAI,UAAU,6BAA6B,OAAO,GAAG;EACrD,IAAI,WAAW,aAAa;GAC3B,MAAM,aAAa,KAAK,oBAAoB;GAC5C,MAAM,YAAY,MAAM,WAAW,aAAa;GAChD,MAAM,KAAK,cAAc,aAAa,OAAO,EAAE;GAC/C,MAAMC,iBAAAA,OACJ,KAAK,YAAY,WAAW,aAAa,GAAG;IAC5C,SAAS;IACT,SAAS;GACV,CAAC,CAAC,CACD,IAAI,KAAK,SAAS;GACpB,WAAW;EACZ;EACA,SAAS,KAAK,EACb,QACD,CAAC;EAED,OAAO;CACR;;;;;;;CAQA,MAAM,gBAAgB,WAAiD;EACtE,OAAO,MAAM,KAAK,cAAc,gBAAgB,SAAS;CAC1D;CAEA,MAAM,uBAAuB,mBAA4D;EACxF,MAAM,WAAWD,YAAAA,OAAO,WAAW;EAEnC,IAAI,CAAC,KAAK,yBACT,MAAM,IAAI,MACT,yGACD;EAGD,MAAM,KAAK,wBAAwB,uBAAuB,iBAAiB;EAC3E,SAAS,KAAK,EACb,SAAS,2BACV,CAAC;CACF;AACD"}
|
|
@@ -8,7 +8,7 @@ import { WroomClient } from "../clients/wroom.cjs";
|
|
|
8
8
|
import { IntegrationFieldsClient } from "../clients/integrationFields.cjs";
|
|
9
9
|
import { ManageV2Client } from "../clients/manageV2.cjs";
|
|
10
10
|
import { MigrationApiClient } from "../clients/migrationApi.cjs";
|
|
11
|
-
import {
|
|
11
|
+
import { DynamicCustomTypeModel, SharedSliceModel } from "@prismicio/types-internal";
|
|
12
12
|
|
|
13
13
|
//#region src/managers/repository.d.ts
|
|
14
14
|
/** Utility to manage test data for a Prismic repository */
|
|
@@ -160,7 +160,7 @@ declare class RepositoryManager {
|
|
|
160
160
|
*
|
|
161
161
|
* @param customTypes
|
|
162
162
|
*/
|
|
163
|
-
createCustomTypes(customTypes:
|
|
163
|
+
createCustomTypes(customTypes: DynamicCustomTypeModel[]): Promise<void>;
|
|
164
164
|
deleteCustomType(customTypeId: string): Promise<void>;
|
|
165
165
|
/**
|
|
166
166
|
* Create slices using the Custom types api.
|
|
@@ -280,7 +280,7 @@ type RepositoryConfig = {
|
|
|
280
280
|
locales?: string[];
|
|
281
281
|
defaultLocale?: string;
|
|
282
282
|
slices?: SharedSliceModel[];
|
|
283
|
-
customTypes?:
|
|
283
|
+
customTypes?: DynamicCustomTypeModel[];
|
|
284
284
|
preview?: Preview;
|
|
285
285
|
simulatorURL?: string;
|
|
286
286
|
rolePerLocal?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.cts","names":[],"sources":["../../src/managers/repository.ts"],"mappings":";;;;;;;;;;;;;;cA0Ba,iBAAA;EAAA,SAEF,IAAA;EAAA,iBACQ,aAAA;EAAA,iBACA,aAAA;EAAA,iBACA,WAAA;EAAA,iBACA,oBAAA;EAAA,iBACA,kBAAA;EAAA,iBACA,cAAA;EAAA,iBACA,cAAA;EAAA,iBACA,uBAAA;cARR,IAAA,UACQ,aAAA,EAAe,aAAA,EACf,aAAA,EAAe,uBAAA,EACf,WAAA,EAAa,WAAA,EACb,oBAAA,EAAsB,oBAAA,EACtB,kBAAA,EAAoB,kBAAA,cACpB,cAAA,EAAgB,cAAA,EAChB,cAAA,EAAgB,cAAA,EAChB,uBAAA,EAAyB,uBAAA;EAGrC,SAAA,CAAU,MAAA,EAAQ,gBAAA,GAAmB,OAAA;EAAnB;EAoExB,UAAA;EAc+E;EAT/E,aAAA;EA6BqB;;;;;EApBrB,mBAAA,CAAoB,MAAA;IAAW,OAAA;IAAuB,WAAA;EAAA,IAAyB,gBAAA;EAsJ5B;;;;EA9InD,qBAAA,IAAyB,kBAAA;EAiNQ;;;;EArMjC,iBAAA,IAAqB,cAAA;EAiRlB;EA5QG,kBAAA,IAAsB,OAAA;EAmTS;;;;;;;EAlS/B,aAAA,CAAc,OAAA,aAAoB,OAAA;EA8ZG;;;;;;;EAtYrC,kBAAA,CAAmB,MAAA,EAAQ,YAAA,GAAe,OAAA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BAAA;EACd,OAAA,GAAU,OAAA;EACV,YAAA;EACA,YAAA;EACA,WAAA;EACA,iBAAA,GAAoB,sBAAA;AAAA;AAAA,KAGT,OAAA;EACX,IAAA;EACA,UAAA;EACA,YAAA;AAAA;AAAA,KAGW,YAAA;EACX,IAAA;IACC,KAAA;IACA,EAAA;IACA,mBAAA;EAAA;EAED,MAAA;IACC,KAAA;IACA,EAAA;EAAA;AAAA"}
|
|
@@ -8,7 +8,7 @@ import { WroomClient } from "../clients/wroom.js";
|
|
|
8
8
|
import { IntegrationFieldsClient } from "../clients/integrationFields.js";
|
|
9
9
|
import { ManageV2Client } from "../clients/manageV2.js";
|
|
10
10
|
import { MigrationApiClient } from "../clients/migrationApi.js";
|
|
11
|
-
import {
|
|
11
|
+
import { DynamicCustomTypeModel, SharedSliceModel } from "@prismicio/types-internal";
|
|
12
12
|
|
|
13
13
|
//#region src/managers/repository.d.ts
|
|
14
14
|
/** Utility to manage test data for a Prismic repository */
|
|
@@ -160,7 +160,7 @@ declare class RepositoryManager {
|
|
|
160
160
|
*
|
|
161
161
|
* @param customTypes
|
|
162
162
|
*/
|
|
163
|
-
createCustomTypes(customTypes:
|
|
163
|
+
createCustomTypes(customTypes: DynamicCustomTypeModel[]): Promise<void>;
|
|
164
164
|
deleteCustomType(customTypeId: string): Promise<void>;
|
|
165
165
|
/**
|
|
166
166
|
* Create slices using the Custom types api.
|
|
@@ -280,7 +280,7 @@ type RepositoryConfig = {
|
|
|
280
280
|
locales?: string[];
|
|
281
281
|
defaultLocale?: string;
|
|
282
282
|
slices?: SharedSliceModel[];
|
|
283
|
-
customTypes?:
|
|
283
|
+
customTypes?: DynamicCustomTypeModel[];
|
|
284
284
|
preview?: Preview;
|
|
285
285
|
simulatorURL?: string;
|
|
286
286
|
rolePerLocal?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","names":[],"sources":["../../src/managers/repository.ts"],"mappings":";;;;;;;;;;;;;;cA0Ba,i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B,OAAA;EArFZ;;;;;EAsGlB,kBAAA,CAAmB,OAAA,YAAmB,OAAA;EAzFjB;;;;;EA+GrB,iBAAA,CAAkB,OAAA,YAAmB,OAAA;EAjGxC;;;;;EAuHG,uBAAA,CAAwB,OAAA,YAAmB,OAAA;EAtB3C;;;;;EA4CA,UAAA,CAAW,SAAA,WAAoB,OAAA;EAA/B;;;;;EAoBA,OAAA,CAAQ,KAAA,WAAgB,OAAA;EA0BxB;;;;;EAAA,UAAA,CAAW,KAAA,WAAgB,OAAA;EA4BG;;;;;;;;;;;;;;EAA9B,cAAA,CAAe,KAAA,UAAe,IAAA,WAAe,MAAA,mBAAyB,OAAA;EA8FD;;AAAO;AAgBnF;;;;;;;;;;;;;;;;;;;;;;;;;;AAU2C;AAG3C;;;;;;EAlEO,cAAA,CACL,QAAA,EAAU,8BAAA,EACV,MAAA,0BACE,OAAA,CAAQ,+BAAA;EAkEC;AAAA;AAGb;;;;EAvCO,eAAA,CAAgB,SAAA,WAAoB,OAAA,CAAQ,mBAAA;EAI5C,sBAAA,CAAuB,iBAAA,EAAmB,sBAAA,KAA2B,OAAA;AAAA;AAAA,KAgBhE,gBAAA;EACX,YAAA,GAAe,YAAA;EACf,OAAA;EACA,aAAA;EACA,MAAA,GAAS,gBAAA;EACT,WAAA,GAAc,sBAAA;EACd,OAAA,GAAU,OAAA;EACV,YAAA;EACA,YAAA;EACA,WAAA;EACA,iBAAA,GAAoB,sBAAA;AAAA;AAAA,KAGT,OAAA;EACX,IAAA;EACA,UAAA;EACA,YAAA;AAAA;AAAA,KAGW,YAAA;EACX,IAAA;IACC,KAAA;IACA,EAAA;IACA,mBAAA;EAAA;EAED,MAAA;IACC,KAAA;IACA,EAAA;EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.js","names":[],"sources":["../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\"\nimport type { StaticCustomTypeModel, SharedSliceModel } from \"@prismicio/types-internal\"\nimport type { AxiosResponse } from \"axios\"\n\nimport type { AssetApiClient } from \"../clients/assetApi\"\nimport type { AuthenticationApiClient } from \"../clients/authenticationApi\"\nimport { ContentApiClient } from \"../clients/contentApi\"\nimport type {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n\tCoreApiDocumentData,\n\tCoreApiDocumentsPayload,\n\tCoreApiDocumentsResponse,\n\tRelease,\n} from \"../clients/coreApi\"\nimport type { CustomTypesApiClient } from \"../clients/customTypesApi\"\nimport type { IntegrationFieldsClient } from \"../clients/integrationFields\"\nimport type { ManageV2Client } from \"../clients/manageV2\"\nimport type { MigrationApiClient } from \"../clients/migrationApi\"\nimport type { WroomClient } from \"../clients/wroom\"\nimport type { IntegrationFieldConfig } from \"../types\"\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\tprivate readonly integrationFieldsClient: IntegrationFieldsClient | undefined,\n\t) {}\n\n\tasync configure(config: RepositoryConfig): Promise<void> {\n\t\tconst hasLangConfig = config.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.simulatorURL) {\n\t\t\tawait this.setSimulatorURL(config.simulatorURL)\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\n\t\tif (config.integrationFields) {\n\t\t\tawait this.toggleIntegrationFields(true)\n\t\t\tawait this.setupIntegrationFields(config.integrationFields)\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 url. Uses Playwright\n\t * for requests so if your project uses Playwright too, any network request will be present in\n\t * Playwright test reports.\n\t */\n\tgetContentApiClient(config?: { version?: \"v1\" | \"v2\"; accessToken?: string }): 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 the locales already\n\t * exist.\n\t *\n\t * @param locales - An array of all locales to be added to the repository.\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(this.name, \"app/settings/multilanguages\", {\n\t\t\tlanguages: locales,\n\t\t})\n\n\t\tconst { data, status } = response\n\t\tconst success =\n\t\t\tstatus === 200 || (status === 400 && (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 the locales already\n\t * exist.\n\t *\n\t * @param locale - The locale to be added to the repository.\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 || (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 * @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 locale needs to\n\t * 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 update it.\n\t * @throws Error if setting the default locale fails.\n\t */\n\tasync setDefaultLocale(locale: string, action: \"create\" | \"update\"): 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 * Retrieves documents.\n\t *\n\t * @param args - Configure which documents are retrieved.\n\t * @returns A paginated set of documents.\n\t */\n\tasync getDocuments(args: CoreApiDocumentsPayload): Promise<CoreApiDocumentsResponse> {\n\t\treturn this.coreApiClient.getDocuments(args)\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\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 * Retrieves the migration release.\n\t *\n\t * @returns The migration relese metadata.\n\t */\n\tasync getMigrationRelease(): Promise<Release> {\n\t\tconst releases = await this.coreApiClient.getReleases()\n\t\tconst migrationRelease = releases.find((release) => release.migration)\n\t\tif (!migrationRelease) {\n\t\t\tthrow new Error(`The repository does not have a migration release`)\n\t\t}\n\n\t\treturn migrationRelease\n\t}\n\n\t/**\n\t * Publishes a release.\n\t *\n\t * @param id - The ID of the release.\n\t * @returns A Promise that resolves when the release is published and a new master ref is\n\t * available.\n\t */\n\tasync publishRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst contentApi = this.getContentApiClient()\n\t\tconst masterRef = await contentApi.getMasterRef()\n\t\tawait this.coreApiClient.publishRelease(id)\n\t\tawait expect\n\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\ttimeout: 10_000,\n\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t})\n\t\t\t.not.toBe(masterRef)\n\n\t\tprofiler.done({\n\t\t\tmessage: `release '${id}' published and new master ref available`,\n\t\t})\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\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(this.name, `app/releases/${id}/delete`, {})\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(this.name, `previews/new`, data)\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 * Set the simulator URL (table of slices) for a repository.\n\t *\n\t * @param data - The simulator URL to set.\n\t */\n\tasync setSimulatorURL(simulatorURL: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst repository = await this.coreApiClient.getRepository()\n\t\tawait this.coreApiClient.updateRepository({\n\t\t\t...repository,\n\t\t\tsimulator_url: simulatorURL,\n\t\t})\n\n\t\tprofiler.done({\n\t\t\tmessage: `simulator preview '${simulatorURL}' created`,\n\t\t})\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(this.name, `previews/delete/${id}`, {})\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(this.name, \"app/settings/webhooks/create\", {\n\t\t\tname,\n\t\t\turl,\n\t\t\tsecret,\n\t\t\tactive: active ? \"on\" : \"off\",\n\t\t\t...triggers,\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: StaticCustomTypeModel[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes)\n\t}\n\n\tasync deleteCustomType(customTypeId: string): Promise<void> {\n\t\tawait this.customTypesApiClient.deleteCustomType(customTypeId)\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: SharedSliceModel[]): 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 api is fully private\n\t * 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[]> = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"settings/security/contentapi\",\n\t\t)\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> = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/oauthapp\",\n\t\t\t\t{\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tthis.failIfNot200(response, `Could not create content api app ${appName}`)\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(this.name, \"settings/security/authorizations\", {\n\t\t\t\tapp: app.id,\n\t\t\t\tscope: tokenScope,\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 ${this.name}`,\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 ${this.name}`,\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 * Toggle the Integration Fields feature\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleIntegrationFields(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.toggleIntegrationFields({\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\"} Integration Fields for ${this.name}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Integration Fields ${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 && JSON.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(response, `Could not remove the user ${email} from the repository`)\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, either a string for\n\t * basic workflow or an object such as `{ \"lang_id\": \"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(email: string, role: string | Record<string, string>): 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 specific, use the\n\t * migration api client to create a document with the MigrationApiClient. See the\n\t * `getMigrationApiClient()` method.\n\t *\n\t * @example\n\t * \tTo create a document by converting it from the Page Builder to\n\t * \tCore api format\n\t *\n\t * \t```js\n\t * \timport { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';\n\t *\n\t * \tconst document = {\n\t * \ttitle: 'A new document',\n\t * \tcustom_type_id: 'home-page',\n\t * \tlocale: 'en-gb',\n\t * \tintegration_field_ids: [],\n\t * \ttags: [],\n\t * \tdata: DocumentLegacy.encode({\n\t * \tuid: {\n\t * \t__TYPE__: UIDContentType,\n\t * \tvalue: 'home-page',\n\t * \t},\n\t * \t})\n\t * \t}\n\t * \tawait repository.createDocument(document, 'published');\n\t * \t* ```\n\t * \t```\n\t *\n\t * \t@returns\n\t *\n\t * \t@param document - in the core api format.\n\t *\n\t * \t@param status - status of the document, if published, the function will\n\t * \twait 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\t/**\n\t * Retrieves data for a specific document version.\n\t *\n\t * @param versionId - The document's version ID.\n\t * @returns The document's version data.\n\t */\n\tasync getDocumentData(versionId: string): Promise<CoreApiDocumentData> {\n\t\treturn await this.coreApiClient.getDocumentData(versionId)\n\t}\n\n\tasync setupIntegrationFields(integrationFields: IntegrationFieldConfig[]): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tif (!this.integrationFieldsClient) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Integration Fields client not found. Did you provide a integration fields api url in the configuration?\",\n\t\t\t)\n\t\t}\n\n\t\tawait this.integrationFieldsClient.setupIntegrationFields(integrationFields)\n\t\tprofiler.done({\n\t\t\tmessage: `Integration Fields setup`,\n\t\t})\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale\n\tlocales?: string[]\n\tdefaultLocale?: string\n\tslices?: SharedSliceModel[]\n\tcustomTypes?: StaticCustomTypeModel[]\n\tpreview?: Preview\n\tsimulatorURL?: string\n\trolePerLocal?: boolean\n\tcustomRoles?: boolean\n\tintegrationFields?: IntegrationFieldConfig[]\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"],"mappings":";;;;;;AA0BA,IAAa,oBAAb,MAA+B;CAEpB;CACQ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CATlB,YACC,MACA,eACA,eACA,aACA,sBACA,oBACA,gBACA,gBACA,yBACC;EATQ,KAAA,OAAA;EACQ,KAAA,gBAAA;EACA,KAAA,gBAAA;EACA,KAAA,cAAA;EACA,KAAA,uBAAA;EACA,KAAA,qBAAA;EACA,KAAA,iBAAA;EACA,KAAA,iBAAA;EACA,KAAA,0BAAA;CACf;CAEH,MAAM,UAAU,QAAyC;EAExD,IADsB,OAAO,iBAAiB,OAAO,WAAW,OAAO,cACpD;GAClB,MAAM,YAAY,MAAM,KAAK,cAAc,aAAa;GACxD,IAAI,8BAA8B;GAElC,IAAI,OAAO,eAAe;IACzB,MAAM,SAAS,UAAU,MAAM,EAAE,gBAAgB,cAAc,IAAI;IACnE,IAAI,CAAC,QACJ,MAAM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AO,SAAS,WAAW,SAAS,eACpC,eAAe,OACjB;EACA,SAAS,KAAK,EACb,SAAS,kBACR,OAAO,SAAS,WAAW,SAAS,eACpC,YAAY,QACd,CAAC;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCA,MAAM,eACL,UACA,QAC2C;EAC3C,MAAM,WAAW,OAAO,WAAW;EACnC,MAAM,SAAS,MAAM,KAAK,cAAc,YAAY,QAAQ;EAE5D,IAAI,UAAU,6BAA6B,OAAO,GAAG;EACrD,IAAI,WAAW,aAAa;GAC3B,MAAM,aAAa,KAAK,oBAAoB;GAC5C,MAAM,YAAY,MAAM,WAAW,aAAa;GAChD,MAAM,KAAK,cAAc,aAAa,OAAO,EAAE;GAC/C,MAAM,OACJ,KAAK,YAAY,WAAW,aAAa,GAAG;IAC5C,SAAS;IACT,SAAS;GACV,CAAC,CAAC,CACD,IAAI,KAAK,SAAS;GACpB,WAAW;EACZ;EACA,SAAS,KAAK,EACb,QACD,CAAC;EAED,OAAO;CACR;;;;;;;CAQA,MAAM,gBAAgB,WAAiD;EACtE,OAAO,MAAM,KAAK,cAAc,gBAAgB,SAAS;CAC1D;CAEA,MAAM,uBAAuB,mBAA4D;EACxF,MAAM,WAAW,OAAO,WAAW;EAEnC,IAAI,CAAC,KAAK,yBACT,MAAM,IAAI,MACT,yGACD;EAGD,MAAM,KAAK,wBAAwB,uBAAuB,iBAAiB;EAC3E,SAAS,KAAK,EACb,SAAS,2BACV,CAAC;CACF;AACD"}
|
|
1
|
+
{"version":3,"file":"repository.js","names":[],"sources":["../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\"\nimport type { DynamicCustomTypeModel, SharedSliceModel } from \"@prismicio/types-internal\"\nimport type { AxiosResponse } from \"axios\"\n\nimport type { AssetApiClient } from \"../clients/assetApi\"\nimport type { AuthenticationApiClient } from \"../clients/authenticationApi\"\nimport { ContentApiClient } from \"../clients/contentApi\"\nimport type {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n\tCoreApiDocumentData,\n\tCoreApiDocumentsPayload,\n\tCoreApiDocumentsResponse,\n\tRelease,\n} from \"../clients/coreApi\"\nimport type { CustomTypesApiClient } from \"../clients/customTypesApi\"\nimport type { IntegrationFieldsClient } from \"../clients/integrationFields\"\nimport type { ManageV2Client } from \"../clients/manageV2\"\nimport type { MigrationApiClient } from \"../clients/migrationApi\"\nimport type { WroomClient } from \"../clients/wroom\"\nimport type { IntegrationFieldConfig } from \"../types\"\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\tprivate readonly integrationFieldsClient: IntegrationFieldsClient | undefined,\n\t) {}\n\n\tasync configure(config: RepositoryConfig): Promise<void> {\n\t\tconst hasLangConfig = config.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.simulatorURL) {\n\t\t\tawait this.setSimulatorURL(config.simulatorURL)\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\n\t\tif (config.integrationFields) {\n\t\t\tawait this.toggleIntegrationFields(true)\n\t\t\tawait this.setupIntegrationFields(config.integrationFields)\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 url. Uses Playwright\n\t * for requests so if your project uses Playwright too, any network request will be present in\n\t * Playwright test reports.\n\t */\n\tgetContentApiClient(config?: { version?: \"v1\" | \"v2\"; accessToken?: string }): 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 the locales already\n\t * exist.\n\t *\n\t * @param locales - An array of all locales to be added to the repository.\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(this.name, \"app/settings/multilanguages\", {\n\t\t\tlanguages: locales,\n\t\t})\n\n\t\tconst { data, status } = response\n\t\tconst success =\n\t\t\tstatus === 200 || (status === 400 && (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 the locales already\n\t * exist.\n\t *\n\t * @param locale - The locale to be added to the repository.\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 || (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 * @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 locale needs to\n\t * 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 update it.\n\t * @throws Error if setting the default locale fails.\n\t */\n\tasync setDefaultLocale(locale: string, action: \"create\" | \"update\"): 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 * Retrieves documents.\n\t *\n\t * @param args - Configure which documents are retrieved.\n\t * @returns A paginated set of documents.\n\t */\n\tasync getDocuments(args: CoreApiDocumentsPayload): Promise<CoreApiDocumentsResponse> {\n\t\treturn this.coreApiClient.getDocuments(args)\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\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 * Retrieves the migration release.\n\t *\n\t * @returns The migration relese metadata.\n\t */\n\tasync getMigrationRelease(): Promise<Release> {\n\t\tconst releases = await this.coreApiClient.getReleases()\n\t\tconst migrationRelease = releases.find((release) => release.migration)\n\t\tif (!migrationRelease) {\n\t\t\tthrow new Error(`The repository does not have a migration release`)\n\t\t}\n\n\t\treturn migrationRelease\n\t}\n\n\t/**\n\t * Publishes a release.\n\t *\n\t * @param id - The ID of the release.\n\t * @returns A Promise that resolves when the release is published and a new master ref is\n\t * available.\n\t */\n\tasync publishRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst contentApi = this.getContentApiClient()\n\t\tconst masterRef = await contentApi.getMasterRef()\n\t\tawait this.coreApiClient.publishRelease(id)\n\t\tawait expect\n\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\ttimeout: 10_000,\n\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t})\n\t\t\t.not.toBe(masterRef)\n\n\t\tprofiler.done({\n\t\t\tmessage: `release '${id}' published and new master ref available`,\n\t\t})\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\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(this.name, `app/releases/${id}/delete`, {})\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(this.name, `previews/new`, data)\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 * Set the simulator URL (table of slices) for a repository.\n\t *\n\t * @param data - The simulator URL to set.\n\t */\n\tasync setSimulatorURL(simulatorURL: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst repository = await this.coreApiClient.getRepository()\n\t\tawait this.coreApiClient.updateRepository({\n\t\t\t...repository,\n\t\t\tsimulator_url: simulatorURL,\n\t\t})\n\n\t\tprofiler.done({\n\t\t\tmessage: `simulator preview '${simulatorURL}' created`,\n\t\t})\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(this.name, `previews/delete/${id}`, {})\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(this.name, \"app/settings/webhooks/create\", {\n\t\t\tname,\n\t\t\turl,\n\t\t\tsecret,\n\t\t\tactive: active ? \"on\" : \"off\",\n\t\t\t...triggers,\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: DynamicCustomTypeModel[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes)\n\t}\n\n\tasync deleteCustomType(customTypeId: string): Promise<void> {\n\t\tawait this.customTypesApiClient.deleteCustomType(customTypeId)\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: SharedSliceModel[]): 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 api is fully private\n\t * 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[]> = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"settings/security/contentapi\",\n\t\t)\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> = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/oauthapp\",\n\t\t\t\t{\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tthis.failIfNot200(response, `Could not create content api app ${appName}`)\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(this.name, \"settings/security/authorizations\", {\n\t\t\t\tapp: app.id,\n\t\t\t\tscope: tokenScope,\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 ${this.name}`,\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 ${this.name}`,\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 * Toggle the Integration Fields feature\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleIntegrationFields(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.toggleIntegrationFields({\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\"} Integration Fields for ${this.name}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Integration Fields ${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 && JSON.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(response, `Could not remove the user ${email} from the repository`)\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, either a string for\n\t * basic workflow or an object such as `{ \"lang_id\": \"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(email: string, role: string | Record<string, string>): 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 specific, use the\n\t * migration api client to create a document with the MigrationApiClient. See the\n\t * `getMigrationApiClient()` method.\n\t *\n\t * @example\n\t * \tTo create a document by converting it from the Page Builder to\n\t * \tCore api format\n\t *\n\t * \t```js\n\t * \timport { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';\n\t *\n\t * \tconst document = {\n\t * \ttitle: 'A new document',\n\t * \tcustom_type_id: 'home-page',\n\t * \tlocale: 'en-gb',\n\t * \tintegration_field_ids: [],\n\t * \ttags: [],\n\t * \tdata: DocumentLegacy.encode({\n\t * \tuid: {\n\t * \t__TYPE__: UIDContentType,\n\t * \tvalue: 'home-page',\n\t * \t},\n\t * \t})\n\t * \t}\n\t * \tawait repository.createDocument(document, 'published');\n\t * \t* ```\n\t * \t```\n\t *\n\t * \t@returns\n\t *\n\t * \t@param document - in the core api format.\n\t *\n\t * \t@param status - status of the document, if published, the function will\n\t * \twait 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\t/**\n\t * Retrieves data for a specific document version.\n\t *\n\t * @param versionId - The document's version ID.\n\t * @returns The document's version data.\n\t */\n\tasync getDocumentData(versionId: string): Promise<CoreApiDocumentData> {\n\t\treturn await this.coreApiClient.getDocumentData(versionId)\n\t}\n\n\tasync setupIntegrationFields(integrationFields: IntegrationFieldConfig[]): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tif (!this.integrationFieldsClient) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Integration Fields client not found. Did you provide a integration fields api url in the configuration?\",\n\t\t\t)\n\t\t}\n\n\t\tawait this.integrationFieldsClient.setupIntegrationFields(integrationFields)\n\t\tprofiler.done({\n\t\t\tmessage: `Integration Fields setup`,\n\t\t})\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale\n\tlocales?: string[]\n\tdefaultLocale?: string\n\tslices?: SharedSliceModel[]\n\tcustomTypes?: DynamicCustomTypeModel[]\n\tpreview?: Preview\n\tsimulatorURL?: string\n\trolePerLocal?: boolean\n\tcustomRoles?: boolean\n\tintegrationFields?: IntegrationFieldConfig[]\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"],"mappings":";;;;;;AA0BA,IAAa,oBAAb,MAA+B;CAEpB;CACQ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CATlB,YACC,MACA,eACA,eACA,aACA,sBACA,oBACA,gBACA,gBACA,yBACC;EATQ,KAAA,OAAA;EACQ,KAAA,gBAAA;EACA,KAAA,gBAAA;EACA,KAAA,cAAA;EACA,KAAA,uBAAA;EACA,KAAA,qBAAA;EACA,KAAA,iBAAA;EACA,KAAA,iBAAA;EACA,KAAA,0BAAA;CACf;CAEH,MAAM,UAAU,QAAyC;EAExD,IADsB,OAAO,iBAAiB,OAAO,WAAW,OAAO,cACpD;GAClB,MAAM,YAAY,MAAM,KAAK,cAAc,aAAa;GACxD,IAAI,8BAA8B;GAElC,IAAI,OAAO,eAAe;IACzB,MAAM,SAAS,UAAU,MAAM,EAAE,gBAAgB,cAAc,IAAI;IACnE,IAAI,CAAC,QACJ,MAAM,KAAK,iBAAiB,OAAO,eAAe,QAAQ;SACpD,IAAI,OAAO,OAAO,OAAO,eAE/B,8BAA8B;GAEhC;GAEA,IAAI,OAAO,SAAS;IAEnB,MAAM,eAAe,OAAO,QAAQ,QAClC,OAAO,CAA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;;;;;;;CAsCA,MAAM,eACL,UACA,QAC2C;EAC3C,MAAM,WAAW,OAAO,WAAW;EACnC,MAAM,SAAS,MAAM,KAAK,cAAc,YAAY,QAAQ;EAE5D,IAAI,UAAU,6BAA6B,OAAO,GAAG;EACrD,IAAI,WAAW,aAAa;GAC3B,MAAM,aAAa,KAAK,oBAAoB;GAC5C,MAAM,YAAY,MAAM,WAAW,aAAa;GAChD,MAAM,KAAK,cAAc,aAAa,OAAO,EAAE;GAC/C,MAAM,OACJ,KAAK,YAAY,WAAW,aAAa,GAAG;IAC5C,SAAS;IACT,SAAS;GACV,CAAC,CAAC,CACD,IAAI,KAAK,SAAS;GACpB,WAAW;EACZ;EACA,SAAS,KAAK,EACb,QACD,CAAC;EAED,OAAO;CACR;;;;;;;CAQA,MAAM,gBAAgB,WAAiD;EACtE,OAAO,MAAM,KAAK,cAAc,gBAAgB,SAAS;CAC1D;CAEA,MAAM,uBAAuB,mBAA4D;EACxF,MAAM,WAAW,OAAO,WAAW;EAEnC,IAAI,CAAC,KAAK,yBACT,MAAM,IAAI,MACT,yGACD;EAGD,MAAM,KAAK,wBAAwB,uBAAuB,iBAAiB;EAC3E,SAAS,KAAK,EACb,SAAS,2BACV,CAAC;CACF;AACD"}
|
package/package.json
CHANGED
|
@@ -38,6 +38,9 @@ export class AuthenticationApiClient {
|
|
|
38
38
|
private readonly auth: AuthConfig,
|
|
39
39
|
) {
|
|
40
40
|
this.authToken = getAuthApiTokenFromEnv(auth.email)
|
|
41
|
+
if (this.authToken) {
|
|
42
|
+
logger.info(`using user token for ${auth.email} from ${AUTH_API_TOKENS_ENV}`)
|
|
43
|
+
}
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
private async getContext(): Promise<APIRequestContext> {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DynamicCustomTypeModel, SharedSliceModel } from "@prismicio/types-internal"
|
|
2
2
|
import isEqual from "lodash.isequal"
|
|
3
3
|
|
|
4
4
|
import { logPlaywrightApiResponse, logger } from "../utils/log"
|
|
5
5
|
import type { AuthServerToken } from "./apiClient"
|
|
6
6
|
import { AuthenticatedApiClient } from "./apiClient"
|
|
7
7
|
|
|
8
|
-
type ItemType =
|
|
8
|
+
type ItemType = DynamicCustomTypeModel | SharedSliceModel
|
|
9
9
|
type ItemTypePath = "customtypes" | "slices"
|
|
10
10
|
type ItemOperation = "insert" | "update"
|
|
11
11
|
|
|
@@ -38,7 +38,7 @@ export class CustomTypesApiClient extends AuthenticatedApiClient {
|
|
|
38
38
|
})
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
private async getRemoteItems(endpoint: ItemTypePath): Promise<
|
|
41
|
+
private async getRemoteItems(endpoint: ItemTypePath): Promise<DynamicCustomTypeModel[] | SharedSliceModel[]> {
|
|
42
42
|
const context = await this.getContext()
|
|
43
43
|
const result = await context.get(endpoint)
|
|
44
44
|
|
|
@@ -51,11 +51,11 @@ export class CustomTypesApiClient extends AuthenticatedApiClient {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
private async getDifference(
|
|
54
|
-
remoteItems:
|
|
54
|
+
remoteItems: DynamicCustomTypeModel[] | SharedSliceModel[],
|
|
55
55
|
local: ItemType,
|
|
56
56
|
): Promise<ItemOperation | undefined> {
|
|
57
57
|
const remoteItem = remoteItems.find(
|
|
58
|
-
(remote:
|
|
58
|
+
(remote: DynamicCustomTypeModel | SharedSliceModel) => remote.id === local.id,
|
|
59
59
|
)
|
|
60
60
|
if (!remoteItem) {
|
|
61
61
|
return "insert"
|
|
@@ -87,7 +87,7 @@ export class CustomTypesApiClient extends AuthenticatedApiClient {
|
|
|
87
87
|
*
|
|
88
88
|
* @param customTypes
|
|
89
89
|
*/
|
|
90
|
-
async createCustomTypes(customTypes:
|
|
90
|
+
async createCustomTypes(customTypes: DynamicCustomTypeModel[] = []): Promise<void> {
|
|
91
91
|
await this.upsertIfChanged("customtypes", customTypes)
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -115,7 +115,7 @@ export class CustomTypesApiClient extends AuthenticatedApiClient {
|
|
|
115
115
|
*
|
|
116
116
|
* @param customTypeId - The id of the custom type to get.
|
|
117
117
|
*/
|
|
118
|
-
async getTypeById(customTypeId: string): Promise<
|
|
118
|
+
async getTypeById(customTypeId: string): Promise<DynamicCustomTypeModel> {
|
|
119
119
|
const context = await this.getContext()
|
|
120
120
|
const result = await context.get(`customtypes/${customTypeId}`)
|
|
121
121
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expect } from "@playwright/test"
|
|
2
|
-
import type {
|
|
2
|
+
import type { DynamicCustomTypeModel, SharedSliceModel } from "@prismicio/types-internal"
|
|
3
3
|
import type { AxiosResponse } from "axios"
|
|
4
4
|
|
|
5
5
|
import type { AssetApiClient } from "../clients/assetApi"
|
|
@@ -451,7 +451,7 @@ export class RepositoryManager {
|
|
|
451
451
|
*
|
|
452
452
|
* @param customTypes
|
|
453
453
|
*/
|
|
454
|
-
async createCustomTypes(customTypes:
|
|
454
|
+
async createCustomTypes(customTypes: DynamicCustomTypeModel[]): Promise<void> {
|
|
455
455
|
await this.customTypesApiClient.createCustomTypes(customTypes)
|
|
456
456
|
}
|
|
457
457
|
|
|
@@ -808,7 +808,7 @@ export type RepositoryConfig = {
|
|
|
808
808
|
locales?: string[]
|
|
809
809
|
defaultLocale?: string
|
|
810
810
|
slices?: SharedSliceModel[]
|
|
811
|
-
customTypes?:
|
|
811
|
+
customTypes?: DynamicCustomTypeModel[]
|
|
812
812
|
preview?: Preview
|
|
813
813
|
simulatorURL?: string
|
|
814
814
|
rolePerLocal?: boolean
|