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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/clients/apiClient.cjs +1 -4
  2. package/dist/clients/apiClient.cjs.map +1 -1
  3. package/dist/clients/apiClient.js +1 -4
  4. package/dist/clients/apiClient.js.map +1 -1
  5. package/dist/clients/assetApi.cjs +48 -0
  6. package/dist/clients/assetApi.cjs.map +1 -0
  7. package/dist/clients/assetApi.d.ts +53 -0
  8. package/dist/clients/assetApi.js +48 -0
  9. package/dist/clients/assetApi.js.map +1 -0
  10. package/dist/clients/authenticationApi.cjs +1 -4
  11. package/dist/clients/authenticationApi.cjs.map +1 -1
  12. package/dist/clients/authenticationApi.js +1 -4
  13. package/dist/clients/authenticationApi.js.map +1 -1
  14. package/dist/clients/contentApi.cjs +1 -4
  15. package/dist/clients/contentApi.cjs.map +1 -1
  16. package/dist/clients/contentApi.js +1 -4
  17. package/dist/clients/contentApi.js.map +1 -1
  18. package/dist/clients/coreApi.cjs.map +1 -1
  19. package/dist/clients/coreApi.js.map +1 -1
  20. package/dist/clients/customTypesApi.cjs.map +1 -1
  21. package/dist/clients/customTypesApi.js.map +1 -1
  22. package/dist/clients/manageV2.cjs +2 -5
  23. package/dist/clients/manageV2.cjs.map +1 -1
  24. package/dist/clients/manageV2.d.ts +1 -1
  25. package/dist/clients/manageV2.js +2 -5
  26. package/dist/clients/manageV2.js.map +1 -1
  27. package/dist/clients/migrationApi.cjs.map +1 -1
  28. package/dist/clients/migrationApi.js.map +1 -1
  29. package/dist/clients/wroom.cjs +2 -5
  30. package/dist/clients/wroom.cjs.map +1 -1
  31. package/dist/clients/wroom.js +2 -5
  32. package/dist/clients/wroom.js.map +1 -1
  33. package/dist/managers/repositories.cjs +10 -6
  34. package/dist/managers/repositories.cjs.map +1 -1
  35. package/dist/managers/repositories.js +10 -6
  36. package/dist/managers/repositories.js.map +1 -1
  37. package/dist/managers/repository.cjs +40 -5
  38. package/dist/managers/repository.cjs.map +1 -1
  39. package/dist/managers/repository.d.ts +27 -1
  40. package/dist/managers/repository.js +40 -5
  41. package/dist/managers/repository.js.map +1 -1
  42. package/dist/types.d.ts +3 -0
  43. package/dist/utils/cookies.cjs.map +1 -1
  44. package/dist/utils/cookies.js.map +1 -1
  45. package/dist/utils/envVariableManager.cjs +1 -4
  46. package/dist/utils/envVariableManager.cjs.map +1 -1
  47. package/dist/utils/envVariableManager.js +1 -4
  48. package/dist/utils/envVariableManager.js.map +1 -1
  49. package/dist/utils/log.cjs.map +1 -1
  50. package/dist/utils/log.js +1 -1
  51. package/dist/utils/log.js.map +1 -1
  52. package/dist/utils/urls.cjs.map +1 -1
  53. package/dist/utils/urls.js.map +1 -1
  54. package/package.json +1 -1
  55. package/src/clients/assetApi.ts +76 -0
  56. package/src/clients/manageV2.ts +1 -1
  57. package/src/clients/wroom.ts +1 -1
  58. package/src/managers/repositories.ts +16 -0
  59. package/src/managers/repository.ts +66 -0
  60. package/src/types.ts +3 -0
@@ -1 +1 @@
1
- {"version":3,"file":"repository.cjs","sources":["../../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\";\nimport { AxiosResponse } from \"axios\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\";\nimport { ContentApiClient } from \"../clients/contentApi\";\nimport {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n} from \"../clients/coreApi\";\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\";\nimport { ManageV2Client } from \"../clients/manageV2\";\nimport { MigrationApiClient } from \"../clients/migrationApi\";\nimport { WroomClient } from \"../clients/wroom\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\n/** Utility to manage test data for a Prismic repository */\nexport class RepositoryManager {\n\tconstructor(\n\t\treadonly name: string,\n\t\tprivate readonly coreApiClient: CoreApiClient,\n\t\tprivate readonly authApiClient: AuthenticationApiClient,\n\t\tprivate readonly wroomClient: WroomClient,\n\t\tprivate readonly customTypesApiClient: CustomTypesApiClient,\n\t\tprivate readonly migrationApiClient: MigrationApiClient | undefined,\n\t\tprivate readonly manageV2Client: ManageV2Client,\n\t) {}\n\n\tasync configure(config: RepositoryConfig): Promise<void> {\n\t\tconst hasLangConfig =\n\t\t\tconfig.defaultLocale || config.locales || config.customLocale;\n\t\tif (hasLangConfig) {\n\t\t\tconst languages = await this.coreApiClient.getLanguages();\n\t\t\tlet updateDefaultLocaleAtTheEnd = false;\n\t\t\t// if no locale exists on repo, the master locale needs to be set first\n\t\t\tif (config.defaultLocale) {\n\t\t\t\tconst master = languages.find(({ is_master }) => is_master === true);\n\t\t\t\tif (!master) {\n\t\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"create\");\n\t\t\t\t} else if (master.id !== config.defaultLocale) {\n\t\t\t\t\t// update the master lang at the end, after it is created.\n\t\t\t\t\tupdateDefaultLocaleAtTheEnd = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.locales) {\n\t\t\t\t// No need to add default locale and already existing languages\n\t\t\t\tconst localesToAdd = config.locales.filter(\n\t\t\t\t\t(id) => !languages.some((language) => language.id === id),\n\t\t\t\t);\n\t\t\t\tif (localesToAdd.length > 0) {\n\t\t\t\t\tawait this.createLocales(localesToAdd);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.customLocale) {\n\t\t\t\tif (!languages.find(({ id }) => id === config.customLocale?.lang.id)) {\n\t\t\t\t\tawait this.createCustomLocale(config.customLocale);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.defaultLocale && updateDefaultLocaleAtTheEnd) {\n\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"update\");\n\t\t\t}\n\t\t}\n\n\t\tif (config.slices) {\n\t\t\tawait this.createSlices(config.slices);\n\t\t}\n\n\t\tif (config.customTypes) {\n\t\t\tawait this.createCustomTypes(config.customTypes);\n\t\t}\n\n\t\tif (config.preview) {\n\t\t\tawait this.createPreview(config.preview);\n\t\t}\n\n\t\tif (config.rolePerLocal) {\n\t\t\tawait this.toggleRolePerLocal(true);\n\t\t}\n\t}\n\n\t/** @returns the repository base url, like https://my-repo.prismic.io */\n\tgetBaseURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), this.name);\n\t}\n\n\t/** @returns the repository base cdn url, like https://my-repo.cdn.prismic.io */\n\tgetBaseCdnURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), `${this.name}.cdn`);\n\t}\n\n\t/**\n\t * @returns a Content Type api client configured to target the repository CDN\n\t * url. Uses Playwright for requests so if your project uses Playwright too,\n\t * any network request will be present in Playwright test reports.\n\t */\n\tgetContentApiClient(config?: {\n\t\tversion?: \"v1\" | \"v2\";\n\t\taccessToken?: string;\n\t}): ContentApiClient {\n\t\treturn new ContentApiClient(this.getBaseCdnURL(), config);\n\t}\n\n\t/**\n\t * @returns an instance of the Migration api client, see\n\t * https://prismic.io/docs/migration-api-technical-reference\n\t */\n\tgetMigrationApiClient(): MigrationApiClient {\n\t\tif (!this.migrationApiClient) {\n\t\t\tthrow \"No client found for the migration api. Did you provide a migration api url in the configuration?\";\n\t\t}\n\n\t\treturn this.migrationApiClient;\n\t}\n\n\t/** @returns the Wroom commit hash deployed on the current repository */\n\tasync getDeployedVersion(): Promise<string | undefined> {\n\t\tconst response = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"underground/834b34f16f451e00f268dd5c8c81d16e3c020275\",\n\t\t);\n\n\t\t// Somehow axios directly parses the text response `Prismic version: <commit hash> into a version attribute\n\t\treturn response.data.version;\n\t}\n\n\t/**\n\t * Set additional standard locales for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locales - An array of all locales to be added to the repository.\n\t *\n\t * @throws Error if setting the locales fails.\n\t */\n\tasync createLocales(locales: string[]): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages\",\n\t\t\t{ languages: locales },\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t(data as string).includes(\"already existing languages\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add locales ${locales.join(\", \")}`);\n\t\t}\n\t\tprofiler.done({ message: `locales '${locales}' created` });\n\t}\n\n\t/**\n\t * Set additional custom locale for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locale - The locale to be added to the repository.\n\t *\n\t * @throws Error if setting the locale fails.\n\t */\n\tasync createCustomLocale(locale: CustomLocale): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages/custom\",\n\t\t\tlocale,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 && JSON.stringify(data).includes(\"code is already used\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not create custom locale ${locale}`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `custom locale ${JSON.stringify(locale)} created`,\n\t\t});\n\t}\n\n\tprivate failIfNot200(response: AxiosResponse, msg: string) {\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(msg);\n\t\t}\n\t}\n\n\t/**\n\t * Delete a locale from a repository.\n\t *\n\t * @param locale - locale to remove from the repository configuration.\n\t *\n\t * @throws Error if deleting the locale fails.\n\t */\n\tasync deleteLocale(locale: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/multilanguages/${locale}/delete`,\n\t\t);\n\t\tthis.failIfNot200(response, `Could not delete locale ${locale}`);\n\t\tprofiler.done({ message: `locale '${locale}' deleted` });\n\t}\n\n\t/**\n\t * Create or update the default (master) locale for a repository in Wroom, the\n\t * locale needs to exist in the repository.\n\t *\n\t * @param locale - The locale to be set as the default.\n\t * @param endpoint - \"createMasterLang\" to create it, \"defineAsMaster\" to\n\t * update it.\n\t *\n\t * @throws Error if setting the default locale fails.\n\t */\n\tasync setDefaultLocale(\n\t\tlocale: string,\n\t\taction: \"create\" | \"update\",\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst endpoint = {\n\t\t\tcreate: \"createMasterLang\",\n\t\t\tupdate: \"defineAsMaster\",\n\t\t};\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`/app/settings/multilanguages/${locale}/${endpoint[action]}`,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t// returns 400 if master lang is already set\n\t\t\t\tJSON.stringify(data).includes(\"Unable to set as master language\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not set default locale to ${locale}`);\n\t\t}\n\t\tprofiler.done({ message: `default locale set to '${locale}'` });\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\n\t *\n\t * @returns A Promise that resolves when the release is created.\n\t */\n\tasync createRelease(label: string): Promise<{ id: string }> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(this.name, \"app/releases\", {\n\t\t\tlabel,\n\t\t});\n\t\tthis.failIfNot200(response, `Could not create release ${label}`);\n\t\tprofiler.done({ message: `release '${label}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\n\t * @param repository - The name of the repository.\n\t * @param id - The ID of the release to be deleted.\n\t */\n\tasync deleteRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/releases/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete release with id ${id}`);\n\t\tprofiler.done({ message: `release '${id}' deleted` });\n\t}\n\n\t/**\n\t * Creates a preview for a repository.\n\t *\n\t * @param data - The data for creating the preview.\n\t */\n\tasync createPreview(data: Preview): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/new`,\n\t\t\tdata,\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not create preview ${data.name}`);\n\t\tprofiler.done({ message: `preview '${data.name}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a preview from a repository.\n\t *\n\t * @param id - The ID of the preview to be deleted.\n\t */\n\tasync deletePreview(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/delete/${id}`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete preview with id ${id}`);\n\t\tprofiler.done({ message: `preview '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes -\n\t */\n\tasync createCustomTypes(customTypes: CustomType[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes);\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices -\n\t */\n\tasync createSlices(slices: SharedSlice[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createSlices(slices);\n\t}\n\n\t/**\n\t * Create an access token to query private items of the Content api.\n\t *\n\t * @param appName - mandatory authorized application name\n\t * @param tokenScope - access token scope. Use \"master\" to when your content\n\t * api is fully private or \"master+releases\" to access private releases\n\t */\n\tasync createContentAPIToken(\n\t\tappName: string,\n\t\ttokenScope: \"master\" | \"master+releases\" = \"master\",\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\t\ttype AuthorizedAppResponse = {\n\t\t\tid: string;\n\t\t\tname: string;\n\t\t\twroom_auths: { token: string; scope: \"master\" | \"master+releases\" }[];\n\t\t};\n\t\tconst existingApps: AxiosResponse<AuthorizedAppResponse[]> =\n\t\t\tawait this.wroomClient.get(this.name, \"settings/security/contentapi\");\n\n\t\tthis.failIfNot200(\n\t\t\texistingApps,\n\t\t\t`Could not get status of existing applications to generate a content api token`,\n\t\t);\n\t\tlet app = existingApps.data.find(({ name, wroom_auths }) => {\n\t\t\treturn name === appName && wroom_auths.length > 0;\n\t\t});\n\n\t\tif (!app) {\n\t\t\tconst response: AxiosResponse<AuthorizedAppResponse> =\n\t\t\t\tawait this.wroomClient.post(this.name, \"settings/security/oauthapp\", {\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t});\n\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api app ${appName}`,\n\t\t\t);\n\t\t\tapp = response.data;\n\t\t}\n\n\t\tlet tokenInfo = app.wroom_auths.find(({ scope }) => scope === tokenScope);\n\t\tif (!tokenInfo) {\n\t\t\tconst response = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/authorizations\",\n\t\t\t\t{\n\t\t\t\t\tapp: app.id,\n\t\t\t\t\tscope: tokenScope,\n\t\t\t\t},\n\t\t\t);\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api access token for app ${appName} with scope ${tokenScope}`,\n\t\t\t);\n\t\t\ttokenInfo = response.data;\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `content api access token for app '${appName}' created`,\n\t\t});\n\n\t\tif (!tokenInfo?.token) {\n\t\t\tthrow `Could not create content api access token for app ${appName} with scope ${tokenScope}`;\n\t\t}\n\n\t\treturn tokenInfo.token;\n\t}\n\n\t/** Create a permanent access token to authenticate to Prismic public apis. */\n\tasync createPermanentAccessToken(): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst token = await this.authApiClient.getMachine2MachineToken(this.name);\n\n\t\tprofiler.done({\n\t\t\tmessage: `machine2machine token created`,\n\t\t});\n\n\t\treturn token;\n\t}\n\n\t/**\n\t * Toggle the Role per local feature\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleRolePerLocal(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.toggleRolePerLocal({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Role per local for ${\n\t\t\t\tthis.name\n\t\t\t}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Role per local ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t});\n\t}\n\n\t/**\n\t * Change the Repository Plan\n\t *\n\t * @param {string} newPlanId - The Id of the new Plan to apply\n\t */\n\tasync changePlan(newPlanId: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.changePlan({\n\t\t\trepository: this.name,\n\t\t\tnewPlanId: newPlanId,\n\t\t\tbypassManualBilling: true, // For now the library does not support Stripe features\n\t\t});\n\n\t\tthis.failIfNot200(response, \"Could not change the Repository Plan\");\n\t\tprofiler.done({\n\t\t\tmessage: `Repository Plan changed to ${newPlanId}`,\n\t\t});\n\t}\n\n\t/**\n\t * Add a new user to the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync addUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.addUserToRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 409 &&\n\t\t\t\tJSON.stringify(data).includes(\"already a member of the repo\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add a new user ${email} to the repository`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was added to the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Remove a user from the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync removeUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.removeUserFromRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not remove the user ${email} from the repository`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was removed from the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Update the role of a user in a repository\n\t *\n\t * @param {string} email - The email of the user\n\t * @param {string | Record<string, string>} role - The new Role of the user,\n\t * either a string for basic workflow or an object such as `{ \"lang_id\":\n\t * \"Writer\" }`\n\t *\n\t * Example of roles are\n\t *\n\t * - Administrator\n\t * - Writer\n\t * - Contributor\n\t * - Manager (publisher)\n\t */\n\tasync updateUserRole(\n\t\temail: string,\n\t\trole: string | Record<string, string>,\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response =\n\t\t\ttypeof role === \"string\"\n\t\t\t\t? await this.wroomClient.updateRole(this.name, email, role)\n\t\t\t\t: await this.wroomClient.updateRolePerLocal(this.name, email, role);\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not update the ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} of the user ${email}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Updated User's ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} for user ${email}`,\n\t\t});\n\t}\n\n\t/**\n\t * Creates a document using the core api. If the Core api format is too\n\t * specific, use the migration api client to create a document with the\n\t * MigrationApiClient. See the `getMigrationApiClient()` method.\n\t *\n\t * @example To create a document by converting it from the Page Builder to\n\t * Core api format\n\t *\n\t * ```js\n\t * import { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';\n\t *\n\t * const document = {\n\t * title: 'A new document',\n\t * custom_type_id: 'home-page',\n\t * locale: 'en-gb',\n\t * integration_field_ids: [],\n\t * tags: [],\n\t * data: DocumentLegacy.encode({\n\t * uid: {\n\t * __TYPE__: UIDContentType,\n\t * value: 'home-page',\n\t * },\n\t * })\n\t * }\n\t * await repository.createDocument(document, 'published');\n\t * \t * ```\n\t * ```\n\t *\n\t * @returns\n\t *\n\t * @param document - in the core api format.\n\t *\n\t * @param status - status of the document, if published, the function will\n\t * wait for a new content api master ref to be created\n\t */\n\tasync createDocument(\n\t\tdocument: CoreApiDocumentCreationPayload,\n\t\tstatus: \"draft\" | \"published\",\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst profiler = logger.startTimer();\n\t\tconst result = await this.coreApiClient.createDraft(document);\n\n\t\tlet message = `Document created with id '${result.id}'`;\n\t\tif (status === \"published\") {\n\t\t\tconst contentApi = this.getContentApiClient();\n\t\t\tconst masterRef = await contentApi.getMasterRef();\n\t\t\tawait this.coreApiClient.publishDraft(result.id);\n\t\t\tawait expect\n\t\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\t\ttimeout: 10_000,\n\t\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t\t})\n\t\t\t\t.not.toBe(masterRef);\n\t\t\tmessage += \", status 'published' and new master ref available\";\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage,\n\t\t});\n\n\t\treturn result;\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale;\n\tlocales?: string[];\n\tdefaultLocale?: string;\n\tslices?: SharedSlice[];\n\tcustomTypes?: CustomType[];\n\tpreview?: Preview;\n\trolePerLocal?: boolean;\n};\n\nexport type Preview = {\n\tname: string;\n\twebsiteURL: string;\n\tresolverPath: string;\n};\n\nexport type CustomLocale = {\n\tlang: {\n\t\tlabel: string;\n\t\tid: string;\n\t\tuseStandardAnalyzer?: boolean;\n\t};\n\tregion: {\n\t\tlabel: string;\n\t\tid: string;\n\t};\n};\n"],"names":["getRepositoryUrl","ContentApiClient","logger","logHttpResponse","contentApi","expect"],"mappings":";;;;;;;;;;;;MAuBa,kBAAiB;AAAA,EAC7B,YACU,MACQ,eACA,eACA,aACA,sBACA,oBACA,gBAA8B;AANtC;AACQ;AACA;AACA;AACA;AACA;AACA;AANR,SAAI,OAAJ;AACQ,SAAa,gBAAb;AACA,SAAa,gBAAb;AACA,SAAW,cAAX;AACA,SAAoB,uBAApB;AACA,SAAkB,qBAAlB;AACA,SAAc,iBAAd;AAAA,EACf;AAAA,EAEH,MAAM,UAAU,QAAwB;AACvC,UAAM,gBACL,OAAO,iBAAiB,OAAO,WAAW,OAAO;AAClD,QAAI,eAAe;AAClB,YAAM,YAAY,MAAM,KAAK,cAAc,aAAY;AACvD,UAAI,8BAA8B;AAElC,UAAI,OAAO,eAAe;AACnB,cAAA,SAAS,UAAU,KAAK,CAAC,EAAE,gBAAgB,cAAc,IAAI;AACnE,YAAI,CAAC,QAAQ;AACZ,gBAAM,KAAK,iBAAiB,OAAO,eAAe,QAAQ;AAAA,QAChD,WAAA,OAAO,OAAO,OAAO,eAAe;AAEhB,wCAAA;AAAA,QAC/B;AAAA,MACD;AAEA,UAAI,OAAO,SAAS;AAEnB,cAAM,eAAe,OAAO,QAAQ,OACnC,CAAC,OAAO,CAAC,UAAU,KAAK,CAAC,aAAa,SAAS,OAAO,EAAE,CAAC;AAEtD,YAAA,aAAa,SAAS,GAAG;AACtB,gBAAA,KAAK,cAAc,YAAY;AAAA,QACtC;AAAA,MACD;AAEA,UAAI,OAAO,cAAc;AACxB,YAAI,CAAC,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IACxD,MAAM,KAAK,YAAY,mBAAmB,KAAK,MAAM,OAAO,IAAI;AAE/D,SAAA,aACJ,UACA,wBACC,OAAO,SAAS,WAAW,SAAS,cACrC,gBAAgB,KAAK,EAAE;AAExB,aAAS,KAAK;AAAA,MACb,SAAS,kBACR,OAAO,SAAS,WAAW,SAAS,cACrC,aAAa,KAAK;AAAA,IAAA,CAClB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqCA,MAAM,eACL,UACA,QAA6B;AAEvB,UAAA,WAAWA,WAAO;AACxB,UAAM,SAAS,MAAM,KAAK,cAAc,YAAY,QAAQ;AAExD,QAAA,UAAU,6BAA6B,OAAO,EAAE;AACpD,QAAI,WAAW,aAAa;AACrB,YAAAE,cAAa,KAAK;AAClB,YAAA,YAAY,MAAMA,YAAW;AACnC,YAAM,KAAK,cAAc,aAAa,OAAO,EAAE;AAC/C,YAAMC,KACJ,OAAA,KAAK,YAAYD,YAAW,gBAAgB;AAAA,QAC5C,SAAS;AAAA,QACT,SAAS;AAAA,MACT,CAAA,EACA,IAAI,KAAK,SAAS;AACT,iBAAA;AAAA,IACZ;AACA,aAAS,KAAK;AAAA,MACb;AAAA,IAAA,CACA;AAEM,WAAA;AAAA,EACR;AACA;;"}
1
+ {"version":3,"file":"repository.cjs","sources":["../../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\";\nimport { AxiosResponse } from \"axios\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { AssetApiClient } from \"../clients/assetApi\";\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\";\nimport { ContentApiClient } from \"../clients/contentApi\";\nimport {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n} from \"../clients/coreApi\";\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\";\nimport { ManageV2Client } from \"../clients/manageV2\";\nimport { MigrationApiClient } from \"../clients/migrationApi\";\nimport { WroomClient } from \"../clients/wroom\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\n/** Utility to manage test data for a Prismic repository */\nexport class RepositoryManager {\n\tconstructor(\n\t\treadonly name: string,\n\t\tprivate readonly coreApiClient: CoreApiClient,\n\t\tprivate readonly authApiClient: AuthenticationApiClient,\n\t\tprivate readonly wroomClient: WroomClient,\n\t\tprivate readonly customTypesApiClient: CustomTypesApiClient,\n\t\tprivate readonly migrationApiClient: MigrationApiClient | undefined,\n\t\tprivate readonly assetApiClient: AssetApiClient,\n\t\tprivate readonly manageV2Client: ManageV2Client,\n\t) {}\n\n\tasync configure(config: RepositoryConfig): Promise<void> {\n\t\tconst hasLangConfig =\n\t\t\tconfig.defaultLocale || config.locales || config.customLocale;\n\t\tif (hasLangConfig) {\n\t\t\tconst languages = await this.coreApiClient.getLanguages();\n\t\t\tlet updateDefaultLocaleAtTheEnd = false;\n\t\t\t// if no locale exists on repo, the master locale needs to be set first\n\t\t\tif (config.defaultLocale) {\n\t\t\t\tconst master = languages.find(({ is_master }) => is_master === true);\n\t\t\t\tif (!master) {\n\t\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"create\");\n\t\t\t\t} else if (master.id !== config.defaultLocale) {\n\t\t\t\t\t// update the master lang at the end, after it is created.\n\t\t\t\t\tupdateDefaultLocaleAtTheEnd = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.locales) {\n\t\t\t\t// No need to add default locale and already existing languages\n\t\t\t\tconst localesToAdd = config.locales.filter(\n\t\t\t\t\t(id) => !languages.some((language) => language.id === id),\n\t\t\t\t);\n\t\t\t\tif (localesToAdd.length > 0) {\n\t\t\t\t\tawait this.createLocales(localesToAdd);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.customLocale) {\n\t\t\t\tif (!languages.find(({ id }) => id === config.customLocale?.lang.id)) {\n\t\t\t\t\tawait this.createCustomLocale(config.customLocale);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.defaultLocale && updateDefaultLocaleAtTheEnd) {\n\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"update\");\n\t\t\t}\n\t\t}\n\n\t\tif (config.slices) {\n\t\t\tawait this.createSlices(config.slices);\n\t\t}\n\n\t\tif (config.customTypes) {\n\t\t\tawait this.createCustomTypes(config.customTypes);\n\t\t}\n\n\t\tif (config.preview) {\n\t\t\tawait this.createPreview(config.preview);\n\t\t}\n\n\t\tif (config.rolePerLocal) {\n\t\t\tawait this.toggleRolePerLocal(true);\n\t\t}\n\t}\n\n\t/** @returns the repository base url, like https://my-repo.prismic.io */\n\tgetBaseURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), this.name);\n\t}\n\n\t/** @returns the repository base cdn url, like https://my-repo.cdn.prismic.io */\n\tgetBaseCdnURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), `${this.name}.cdn`);\n\t}\n\n\t/**\n\t * @returns a Content Type api client configured to target the repository CDN\n\t * url. Uses Playwright for requests so if your project uses Playwright too,\n\t * any network request will be present in Playwright test reports.\n\t */\n\tgetContentApiClient(config?: {\n\t\tversion?: \"v1\" | \"v2\";\n\t\taccessToken?: string;\n\t}): ContentApiClient {\n\t\treturn new ContentApiClient(this.getBaseCdnURL(), config);\n\t}\n\n\t/**\n\t * @returns an instance of the Migration api client, see\n\t * https://prismic.io/docs/migration-api-technical-reference\n\t */\n\tgetMigrationApiClient(): MigrationApiClient {\n\t\tif (!this.migrationApiClient) {\n\t\t\tthrow \"No client found for the migration api. Did you provide a migration api url in the configuration?\";\n\t\t}\n\n\t\treturn this.migrationApiClient;\n\t}\n\n\t/**\n\t * @returns an instance of the Asset api client, see\n\t * https://prismic.io/docs/asset-api-technical-reference\n\t */\n\tgetAssetApiClient(): AssetApiClient {\n\t\treturn this.assetApiClient;\n\t}\n\n\t/** @returns the Wroom commit hash deployed on the current repository */\n\tasync getDeployedVersion(): Promise<string | undefined> {\n\t\tconst response = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"underground/834b34f16f451e00f268dd5c8c81d16e3c020275\",\n\t\t);\n\n\t\t// Somehow axios directly parses the text response `Prismic version: <commit hash> into a version attribute\n\t\treturn response.data.version;\n\t}\n\n\t/**\n\t * Set additional standard locales for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locales - An array of all locales to be added to the repository.\n\t *\n\t * @throws Error if setting the locales fails.\n\t */\n\tasync createLocales(locales: string[]): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages\",\n\t\t\t{ languages: locales },\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t(data as string).includes(\"already existing languages\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add locales ${locales.join(\", \")}`);\n\t\t}\n\t\tprofiler.done({ message: `locales '${locales}' created` });\n\t}\n\n\t/**\n\t * Set additional custom locale for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locale - The locale to be added to the repository.\n\t *\n\t * @throws Error if setting the locale fails.\n\t */\n\tasync createCustomLocale(locale: CustomLocale): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages/custom\",\n\t\t\tlocale,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 && JSON.stringify(data).includes(\"code is already used\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not create custom locale ${locale}`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `custom locale ${JSON.stringify(locale)} created`,\n\t\t});\n\t}\n\n\tprivate failIfNot200(response: AxiosResponse, msg: string) {\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(msg);\n\t\t}\n\t}\n\n\t/**\n\t * Delete a locale from a repository.\n\t *\n\t * @param locale - locale to remove from the repository configuration.\n\t *\n\t * @throws Error if deleting the locale fails.\n\t */\n\tasync deleteLocale(locale: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/multilanguages/${locale}/delete`,\n\t\t);\n\t\tthis.failIfNot200(response, `Could not delete locale ${locale}`);\n\t\tprofiler.done({ message: `locale '${locale}' deleted` });\n\t}\n\n\t/**\n\t * Create or update the default (master) locale for a repository in Wroom, the\n\t * locale needs to exist in the repository.\n\t *\n\t * @param locale - The locale to be set as the default.\n\t * @param endpoint - \"createMasterLang\" to create it, \"defineAsMaster\" to\n\t * update it.\n\t *\n\t * @throws Error if setting the default locale fails.\n\t */\n\tasync setDefaultLocale(\n\t\tlocale: string,\n\t\taction: \"create\" | \"update\",\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst endpoint = {\n\t\t\tcreate: \"createMasterLang\",\n\t\t\tupdate: \"defineAsMaster\",\n\t\t};\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`/app/settings/multilanguages/${locale}/${endpoint[action]}`,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t// returns 400 if master lang is already set\n\t\t\t\tJSON.stringify(data).includes(\"Unable to set as master language\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not set default locale to ${locale}`);\n\t\t}\n\t\tprofiler.done({ message: `default locale set to '${locale}'` });\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\n\t *\n\t * @returns A Promise that resolves when the release is created.\n\t */\n\tasync createRelease(label: string): Promise<{ id: string }> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(this.name, \"app/releases\", {\n\t\t\tlabel,\n\t\t});\n\t\tthis.failIfNot200(response, `Could not create release ${label}`);\n\t\tprofiler.done({ message: `release '${label}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\n\t * @param repository - The name of the repository.\n\t * @param id - The ID of the release to be deleted.\n\t */\n\tasync deleteRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/releases/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete release with id ${id}`);\n\t\tprofiler.done({ message: `release '${id}' deleted` });\n\t}\n\n\t/**\n\t * Creates a preview for a repository.\n\t *\n\t * @param data - The data for creating the preview.\n\t */\n\tasync createPreview(data: Preview): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/new`,\n\t\t\tdata,\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not create preview ${data.name}`);\n\t\tprofiler.done({ message: `preview '${data.name}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a preview from a repository.\n\t *\n\t * @param id - The ID of the preview to be deleted.\n\t */\n\tasync deletePreview(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/delete/${id}`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete preview with id ${id}`);\n\t\tprofiler.done({ message: `preview '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create a webhook.\n\t *\n\t * @returns A Promise that resolves with the webhook id.\n\t */\n\tasync createWebhook(\n\t\tname: string,\n\t\turl: string,\n\t\tsecret: string,\n\t\ttriggers: {\n\t\t\tdocumentsPublished?: boolean;\n\t\t\tdocumentsUnpublished?: boolean;\n\t\t\treleasesCreated?: boolean;\n\t\t\treleasesUpdated?: boolean;\n\t\t\ttagsCreated?: boolean;\n\t\t\ttagsDeleted?: boolean;\n\t\t},\n\t\tactive: boolean,\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/webhooks/create\",\n\t\t\t{\n\t\t\t\tname,\n\t\t\t\turl,\n\t\t\t\tsecret,\n\t\t\t\tactive: active ? \"on\" : \"off\",\n\t\t\t\t...triggers,\n\t\t\t},\n\t\t);\n\t\tthis.failIfNot200(response, `Could not create webhook ${name}`);\n\t\tprofiler.done({ message: `webhook '${name}' created` });\n\n\t\treturn response.data.created;\n\t}\n\n\t/**\n\t * Deletes a webhook.\n\t *\n\t * @param id - The webhook ID.\n\t */\n\tasync deleteWebhook(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/webhooks/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete webhook with id ${id}`);\n\t\tprofiler.done({ message: `webhook '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes -\n\t */\n\tasync createCustomTypes(customTypes: CustomType[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes);\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices -\n\t */\n\tasync createSlices(slices: SharedSlice[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createSlices(slices);\n\t}\n\n\t/**\n\t * Create an access token to query private items of the Content api.\n\t *\n\t * @param appName - mandatory authorized application name\n\t * @param tokenScope - access token scope. Use \"master\" to when your content\n\t * api is fully private or \"master+releases\" to access private releases\n\t */\n\tasync createContentAPIToken(\n\t\tappName: string,\n\t\ttokenScope: \"master\" | \"master+releases\" = \"master\",\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\t\ttype AuthorizedAppResponse = {\n\t\t\tid: string;\n\t\t\tname: string;\n\t\t\twroom_auths: { token: string; scope: \"master\" | \"master+releases\" }[];\n\t\t};\n\t\tconst existingApps: AxiosResponse<AuthorizedAppResponse[]> =\n\t\t\tawait this.wroomClient.get(this.name, \"settings/security/contentapi\");\n\n\t\tthis.failIfNot200(\n\t\t\texistingApps,\n\t\t\t`Could not get status of existing applications to generate a content api token`,\n\t\t);\n\t\tlet app = existingApps.data.find(({ name, wroom_auths }) => {\n\t\t\treturn name === appName && wroom_auths.length > 0;\n\t\t});\n\n\t\tif (!app) {\n\t\t\tconst response: AxiosResponse<AuthorizedAppResponse> =\n\t\t\t\tawait this.wroomClient.post(this.name, \"settings/security/oauthapp\", {\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t});\n\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api app ${appName}`,\n\t\t\t);\n\t\t\tapp = response.data;\n\t\t}\n\n\t\tlet tokenInfo = app.wroom_auths.find(({ scope }) => scope === tokenScope);\n\t\tif (!tokenInfo) {\n\t\t\tconst response = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/authorizations\",\n\t\t\t\t{\n\t\t\t\t\tapp: app.id,\n\t\t\t\t\tscope: tokenScope,\n\t\t\t\t},\n\t\t\t);\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api access token for app ${appName} with scope ${tokenScope}`,\n\t\t\t);\n\t\t\ttokenInfo = response.data;\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `content api access token for app '${appName}' created`,\n\t\t});\n\n\t\tif (!tokenInfo?.token) {\n\t\t\tthrow `Could not create content api access token for app ${appName} with scope ${tokenScope}`;\n\t\t}\n\n\t\treturn tokenInfo.token;\n\t}\n\n\t/** Create a permanent access token to authenticate to Prismic public apis. */\n\tasync createPermanentAccessToken(): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst token = await this.authApiClient.getMachine2MachineToken(this.name);\n\n\t\tprofiler.done({\n\t\t\tmessage: `machine2machine token created`,\n\t\t});\n\n\t\treturn token;\n\t}\n\n\t/**\n\t * Toggle the Role per local feature\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleRolePerLocal(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.toggleRolePerLocal({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Role per local for ${\n\t\t\t\tthis.name\n\t\t\t}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Role per local ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t});\n\t}\n\n\t/**\n\t * Change the Repository Plan\n\t *\n\t * @param {string} newPlanId - The Id of the new Plan to apply\n\t */\n\tasync changePlan(newPlanId: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.changePlan({\n\t\t\trepository: this.name,\n\t\t\tnewPlanId: newPlanId,\n\t\t\tbypassManualBilling: true, // For now the library does not support Stripe features\n\t\t});\n\n\t\tthis.failIfNot200(response, \"Could not change the Repository Plan\");\n\t\tprofiler.done({\n\t\t\tmessage: `Repository Plan changed to ${newPlanId}`,\n\t\t});\n\t}\n\n\t/**\n\t * Add a new user to the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync addUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.addUserToRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 409 &&\n\t\t\t\tJSON.stringify(data).includes(\"already a member of the repo\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add a new user ${email} to the repository`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was added to the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Remove a user from the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync removeUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.removeUserFromRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not remove the user ${email} from the repository`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was removed from the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Update the role of a user in a repository\n\t *\n\t * @param {string} email - The email of the user\n\t * @param {string | Record<string, string>} role - The new Role of the user,\n\t * either a string for basic workflow or an object such as `{ \"lang_id\":\n\t * \"Writer\" }`\n\t *\n\t * Example of roles are\n\t *\n\t * - Administrator\n\t * - Writer\n\t * - Contributor\n\t * - Manager (publisher)\n\t */\n\tasync updateUserRole(\n\t\temail: string,\n\t\trole: string | Record<string, string>,\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response =\n\t\t\ttypeof role === \"string\"\n\t\t\t\t? await this.wroomClient.updateRole(this.name, email, role)\n\t\t\t\t: await this.wroomClient.updateRolePerLocal(this.name, email, role);\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not update the ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} of the user ${email}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Updated User's ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} for user ${email}`,\n\t\t});\n\t}\n\n\t/**\n\t * Creates a document using the core api. If the Core api format is too\n\t * specific, use the migration api client to create a document with the\n\t * MigrationApiClient. See the `getMigrationApiClient()` method.\n\t *\n\t * @example To create a document by converting it from the Page Builder to\n\t * Core api format\n\t *\n\t * ```js\n\t * import { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';\n\t *\n\t * const document = {\n\t * title: 'A new document',\n\t * custom_type_id: 'home-page',\n\t * locale: 'en-gb',\n\t * integration_field_ids: [],\n\t * tags: [],\n\t * data: DocumentLegacy.encode({\n\t * uid: {\n\t * __TYPE__: UIDContentType,\n\t * value: 'home-page',\n\t * },\n\t * })\n\t * }\n\t * await repository.createDocument(document, 'published');\n\t * \t * ```\n\t * ```\n\t *\n\t * @returns\n\t *\n\t * @param document - in the core api format.\n\t *\n\t * @param status - status of the document, if published, the function will\n\t * wait for a new content api master ref to be created\n\t */\n\tasync createDocument(\n\t\tdocument: CoreApiDocumentCreationPayload,\n\t\tstatus: \"draft\" | \"published\",\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst profiler = logger.startTimer();\n\t\tconst result = await this.coreApiClient.createDraft(document);\n\n\t\tlet message = `Document created with id '${result.id}'`;\n\t\tif (status === \"published\") {\n\t\t\tconst contentApi = this.getContentApiClient();\n\t\t\tconst masterRef = await contentApi.getMasterRef();\n\t\t\tawait this.coreApiClient.publishDraft(result.id);\n\t\t\tawait expect\n\t\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\t\ttimeout: 10_000,\n\t\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t\t})\n\t\t\t\t.not.toBe(masterRef);\n\t\t\tmessage += \", status 'published' and new master ref available\";\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage,\n\t\t});\n\n\t\treturn result;\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale;\n\tlocales?: string[];\n\tdefaultLocale?: string;\n\tslices?: SharedSlice[];\n\tcustomTypes?: CustomType[];\n\tpreview?: Preview;\n\trolePerLocal?: boolean;\n};\n\nexport type Preview = {\n\tname: string;\n\twebsiteURL: string;\n\tresolverPath: string;\n};\n\nexport type CustomLocale = {\n\tlang: {\n\t\tlabel: string;\n\t\tid: string;\n\t\tuseStandardAnalyzer?: boolean;\n\t};\n\tregion: {\n\t\tlabel: string;\n\t\tid: string;\n\t};\n};\n"],"names":["getRepositoryUrl","ContentApiClient","logger","logHttpResponse","contentApi","expect"],"mappings":";;;;;;;;;MAwBa,kBAAiB;AAAA,EAC7B,YACU,MACQ,eACA,eACA,aACA,sBACA,oBACA,gBACA,gBAA8B;AAPtC;AACQ;AACA;AACA;AACA;AACA;AACA;AACA;AAPR,SAAI,OAAJ;AACQ,SAAa,gBAAb;AACA,SAAa,gBAAb;AACA,SAAW,cAAX;AACA,SAAoB,uBAApB;AACA,SAAkB,qBAAlB;AACA,SAAc,iBAAd;AACA,SAAc,iBAAd;AAAA,EAAA;AAAA,EAGlB,MAAM,UAAU,QAAwB;AACvC,UAAM,gBACL,OAAO,iBAAiB,OAAO,WAAW,OAAO;AAClD,QAAI,eAAe;AAClB,YAAM,YAAY,MAAM,KAAK,cAAc,aAAY;AACvD,UAAI,8BAA8B;AAElC,UAAI,OAAO,eAAe;AACnB,cAAA,SAAS,UAAU,KAAK,CAAC,EAAE,UAAS,MAAO,cAAc,IAAI;AACnE,YAAI,CAAC,QAAQ;AACZ,gBAAM,KAAK,iBAAiB,OAAO,eAAe,QAAQ;AAAA,QAChD,WAAA,OAAO,OAAO,OAAO,eAAe;AAEhB,wCAAA;AAAA,QAAA;AAAA,MAC/B;AAGD,UAAI,OAAO,SAAS;AAEnB,cAAM,eAAe,OAAO,QAA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;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsCF,MAAM,eACL,UACA,QAA6B;AAEvB,UAAA,WAAWA,WAAO;AACxB,UAAM,SAAS,MAAM,KAAK,cAAc,YAAY,QAAQ;AAExD,QAAA,UAAU,6BAA6B,OAAO,EAAE;AACpD,QAAI,WAAW,aAAa;AACrB,YAAAE,cAAa,KAAK;AAClB,YAAA,YAAY,MAAMA,YAAW;AACnC,YAAM,KAAK,cAAc,aAAa,OAAO,EAAE;AAC/C,YAAMC,KACJ,OAAA,KAAK,YAAYD,YAAW,gBAAgB;AAAA,QAC5C,SAAS;AAAA,QACT,SAAS;AAAA,MAAA,CACT,EACA,IAAI,KAAK,SAAS;AACT,iBAAA;AAAA,IAAA;AAEZ,aAAS,KAAK;AAAA,MACb;AAAA,IAAA,CACA;AAEM,WAAA;AAAA,EAAA;AAER;;"}
@@ -1,4 +1,5 @@
1
1
  import { CustomType, SharedSlice } from "@prismicio/types-internal/lib/customtypes";
2
+ import { AssetApiClient } from "../clients/assetApi";
2
3
  import { AuthenticationApiClient } from "../clients/authenticationApi";
3
4
  import { ContentApiClient } from "../clients/contentApi";
4
5
  import { CoreApiClient, CoreApiDocumentCreationPayload, CoreApiDocumentCreationResponse } from "../clients/coreApi";
@@ -14,8 +15,9 @@ export declare class RepositoryManager {
14
15
  private readonly wroomClient;
15
16
  private readonly customTypesApiClient;
16
17
  private readonly migrationApiClient;
18
+ private readonly assetApiClient;
17
19
  private readonly manageV2Client;
18
- constructor(name: string, coreApiClient: CoreApiClient, authApiClient: AuthenticationApiClient, wroomClient: WroomClient, customTypesApiClient: CustomTypesApiClient, migrationApiClient: MigrationApiClient | undefined, manageV2Client: ManageV2Client);
20
+ constructor(name: string, coreApiClient: CoreApiClient, authApiClient: AuthenticationApiClient, wroomClient: WroomClient, customTypesApiClient: CustomTypesApiClient, migrationApiClient: MigrationApiClient | undefined, assetApiClient: AssetApiClient, manageV2Client: ManageV2Client);
19
21
  configure(config: RepositoryConfig): Promise<void>;
20
22
  /** @returns the repository base url, like https://my-repo.prismic.io */
21
23
  getBaseURL(): string;
@@ -35,6 +37,11 @@ export declare class RepositoryManager {
35
37
  * https://prismic.io/docs/migration-api-technical-reference
36
38
  */
37
39
  getMigrationApiClient(): MigrationApiClient;
40
+ /**
41
+ * @returns an instance of the Asset api client, see
42
+ * https://prismic.io/docs/asset-api-technical-reference
43
+ */
44
+ getAssetApiClient(): AssetApiClient;
38
45
  /** @returns the Wroom commit hash deployed on the current repository */
39
46
  getDeployedVersion(): Promise<string | undefined>;
40
47
  /**
@@ -104,6 +111,25 @@ export declare class RepositoryManager {
104
111
  * @param id - The ID of the preview to be deleted.
105
112
  */
106
113
  deletePreview(id: string): Promise<void>;
114
+ /**
115
+ * Create a webhook.
116
+ *
117
+ * @returns A Promise that resolves with the webhook id.
118
+ */
119
+ createWebhook(name: string, url: string, secret: string, triggers: {
120
+ documentsPublished?: boolean;
121
+ documentsUnpublished?: boolean;
122
+ releasesCreated?: boolean;
123
+ releasesUpdated?: boolean;
124
+ tagsCreated?: boolean;
125
+ tagsDeleted?: boolean;
126
+ }, active: boolean): Promise<string>;
127
+ /**
128
+ * Deletes a webhook.
129
+ *
130
+ * @param id - The webhook ID.
131
+ */
132
+ deleteWebhook(id: string): Promise<void>;
107
133
  /**
108
134
  * Create Custom Types using the Custom types api.
109
135
  *
@@ -1,21 +1,19 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  import { expect } from "@playwright/test";
8
5
  import { ContentApiClient } from "../clients/contentApi.js";
9
6
  import { logger, logHttpResponse } from "../utils/log.js";
10
7
  import { getRepositoryUrl } from "../utils/urls.js";
11
8
  class RepositoryManager {
12
- constructor(name, coreApiClient, authApiClient, wroomClient, customTypesApiClient, migrationApiClient, manageV2Client) {
9
+ constructor(name, coreApiClient, authApiClient, wroomClient, customTypesApiClient, migrationApiClient, assetApiClient, manageV2Client) {
13
10
  __publicField(this, "name");
14
11
  __publicField(this, "coreApiClient");
15
12
  __publicField(this, "authApiClient");
16
13
  __publicField(this, "wroomClient");
17
14
  __publicField(this, "customTypesApiClient");
18
15
  __publicField(this, "migrationApiClient");
16
+ __publicField(this, "assetApiClient");
19
17
  __publicField(this, "manageV2Client");
20
18
  this.name = name;
21
19
  this.coreApiClient = coreApiClient;
@@ -23,6 +21,7 @@ class RepositoryManager {
23
21
  this.wroomClient = wroomClient;
24
22
  this.customTypesApiClient = customTypesApiClient;
25
23
  this.migrationApiClient = migrationApiClient;
24
+ this.assetApiClient = assetApiClient;
26
25
  this.manageV2Client = manageV2Client;
27
26
  }
28
27
  async configure(config) {
@@ -95,6 +94,13 @@ class RepositoryManager {
95
94
  }
96
95
  return this.migrationApiClient;
97
96
  }
97
+ /**
98
+ * @returns an instance of the Asset api client, see
99
+ * https://prismic.io/docs/asset-api-technical-reference
100
+ */
101
+ getAssetApiClient() {
102
+ return this.assetApiClient;
103
+ }
98
104
  /** @returns the Wroom commit hash deployed on the current repository */
99
105
  async getDeployedVersion() {
100
106
  const response = await this.wroomClient.get(this.name, "underground/834b34f16f451e00f268dd5c8c81d16e3c020275");
@@ -236,6 +242,35 @@ class RepositoryManager {
236
242
  this.failIfNot200(response, `Could not delete preview with id ${id}`);
237
243
  profiler.done({ message: `preview '${id}' deleted` });
238
244
  }
245
+ /**
246
+ * Create a webhook.
247
+ *
248
+ * @returns A Promise that resolves with the webhook id.
249
+ */
250
+ async createWebhook(name, url, secret, triggers, active) {
251
+ const profiler = logger.startTimer();
252
+ const response = await this.wroomClient.post(this.name, "app/settings/webhooks/create", {
253
+ name,
254
+ url,
255
+ secret,
256
+ active: active ? "on" : "off",
257
+ ...triggers
258
+ });
259
+ this.failIfNot200(response, `Could not create webhook ${name}`);
260
+ profiler.done({ message: `webhook '${name}' created` });
261
+ return response.data.created;
262
+ }
263
+ /**
264
+ * Deletes a webhook.
265
+ *
266
+ * @param id - The webhook ID.
267
+ */
268
+ async deleteWebhook(id) {
269
+ const profiler = logger.startTimer();
270
+ const response = await this.wroomClient.post(this.name, `app/settings/webhooks/${id}/delete`, {});
271
+ this.failIfNot200(response, `Could not delete webhook with id ${id}`);
272
+ profiler.done({ message: `webhook '${id}' deleted` });
273
+ }
239
274
  /**
240
275
  * Create Custom Types using the Custom types api.
241
276
  *
@@ -1 +1 @@
1
- {"version":3,"file":"repository.js","sources":["../../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\";\nimport { AxiosResponse } from \"axios\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\";\nimport { ContentApiClient } from \"../clients/contentApi\";\nimport {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n} from \"../clients/coreApi\";\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\";\nimport { ManageV2Client } from \"../clients/manageV2\";\nimport { MigrationApiClient } from \"../clients/migrationApi\";\nimport { WroomClient } from \"../clients/wroom\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\n/** Utility to manage test data for a Prismic repository */\nexport class RepositoryManager {\n\tconstructor(\n\t\treadonly name: string,\n\t\tprivate readonly coreApiClient: CoreApiClient,\n\t\tprivate readonly authApiClient: AuthenticationApiClient,\n\t\tprivate readonly wroomClient: WroomClient,\n\t\tprivate readonly customTypesApiClient: CustomTypesApiClient,\n\t\tprivate readonly migrationApiClient: MigrationApiClient | undefined,\n\t\tprivate readonly manageV2Client: ManageV2Client,\n\t) {}\n\n\tasync configure(config: RepositoryConfig): Promise<void> {\n\t\tconst hasLangConfig =\n\t\t\tconfig.defaultLocale || config.locales || config.customLocale;\n\t\tif (hasLangConfig) {\n\t\t\tconst languages = await this.coreApiClient.getLanguages();\n\t\t\tlet updateDefaultLocaleAtTheEnd = false;\n\t\t\t// if no locale exists on repo, the master locale needs to be set first\n\t\t\tif (config.defaultLocale) {\n\t\t\t\tconst master = languages.find(({ is_master }) => is_master === true);\n\t\t\t\tif (!master) {\n\t\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"create\");\n\t\t\t\t} else if (master.id !== config.defaultLocale) {\n\t\t\t\t\t// update the master lang at the end, after it is created.\n\t\t\t\t\tupdateDefaultLocaleAtTheEnd = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.locales) {\n\t\t\t\t// No need to add default locale and already existing languages\n\t\t\t\tconst localesToAdd = config.locales.filter(\n\t\t\t\t\t(id) => !languages.some((language) => language.id === id),\n\t\t\t\t);\n\t\t\t\tif (localesToAdd.length > 0) {\n\t\t\t\t\tawait this.createLocales(localesToAdd);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.customLocale) {\n\t\t\t\tif (!languages.find(({ id }) => id === config.customLocale?.lang.id)) {\n\t\t\t\t\tawait this.createCustomLocale(config.customLocale);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.defaultLocale && updateDefaultLocaleAtTheEnd) {\n\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"update\");\n\t\t\t}\n\t\t}\n\n\t\tif (config.slices) {\n\t\t\tawait this.createSlices(config.slices);\n\t\t}\n\n\t\tif (config.customTypes) {\n\t\t\tawait this.createCustomTypes(config.customTypes);\n\t\t}\n\n\t\tif (config.preview) {\n\t\t\tawait this.createPreview(config.preview);\n\t\t}\n\n\t\tif (config.rolePerLocal) {\n\t\t\tawait this.toggleRolePerLocal(true);\n\t\t}\n\t}\n\n\t/** @returns the repository base url, like https://my-repo.prismic.io */\n\tgetBaseURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), this.name);\n\t}\n\n\t/** @returns the repository base cdn url, like https://my-repo.cdn.prismic.io */\n\tgetBaseCdnURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), `${this.name}.cdn`);\n\t}\n\n\t/**\n\t * @returns a Content Type api client configured to target the repository CDN\n\t * url. Uses Playwright for requests so if your project uses Playwright too,\n\t * any network request will be present in Playwright test reports.\n\t */\n\tgetContentApiClient(config?: {\n\t\tversion?: \"v1\" | \"v2\";\n\t\taccessToken?: string;\n\t}): ContentApiClient {\n\t\treturn new ContentApiClient(this.getBaseCdnURL(), config);\n\t}\n\n\t/**\n\t * @returns an instance of the Migration api client, see\n\t * https://prismic.io/docs/migration-api-technical-reference\n\t */\n\tgetMigrationApiClient(): MigrationApiClient {\n\t\tif (!this.migrationApiClient) {\n\t\t\tthrow \"No client found for the migration api. Did you provide a migration api url in the configuration?\";\n\t\t}\n\n\t\treturn this.migrationApiClient;\n\t}\n\n\t/** @returns the Wroom commit hash deployed on the current repository */\n\tasync getDeployedVersion(): Promise<string | undefined> {\n\t\tconst response = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"underground/834b34f16f451e00f268dd5c8c81d16e3c020275\",\n\t\t);\n\n\t\t// Somehow axios directly parses the text response `Prismic version: <commit hash> into a version attribute\n\t\treturn response.data.version;\n\t}\n\n\t/**\n\t * Set additional standard locales for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locales - An array of all locales to be added to the repository.\n\t *\n\t * @throws Error if setting the locales fails.\n\t */\n\tasync createLocales(locales: string[]): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages\",\n\t\t\t{ languages: locales },\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t(data as string).includes(\"already existing languages\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add locales ${locales.join(\", \")}`);\n\t\t}\n\t\tprofiler.done({ message: `locales '${locales}' created` });\n\t}\n\n\t/**\n\t * Set additional custom locale for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locale - The locale to be added to the repository.\n\t *\n\t * @throws Error if setting the locale fails.\n\t */\n\tasync createCustomLocale(locale: CustomLocale): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages/custom\",\n\t\t\tlocale,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 && JSON.stringify(data).includes(\"code is already used\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not create custom locale ${locale}`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `custom locale ${JSON.stringify(locale)} created`,\n\t\t});\n\t}\n\n\tprivate failIfNot200(response: AxiosResponse, msg: string) {\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(msg);\n\t\t}\n\t}\n\n\t/**\n\t * Delete a locale from a repository.\n\t *\n\t * @param locale - locale to remove from the repository configuration.\n\t *\n\t * @throws Error if deleting the locale fails.\n\t */\n\tasync deleteLocale(locale: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/multilanguages/${locale}/delete`,\n\t\t);\n\t\tthis.failIfNot200(response, `Could not delete locale ${locale}`);\n\t\tprofiler.done({ message: `locale '${locale}' deleted` });\n\t}\n\n\t/**\n\t * Create or update the default (master) locale for a repository in Wroom, the\n\t * locale needs to exist in the repository.\n\t *\n\t * @param locale - The locale to be set as the default.\n\t * @param endpoint - \"createMasterLang\" to create it, \"defineAsMaster\" to\n\t * update it.\n\t *\n\t * @throws Error if setting the default locale fails.\n\t */\n\tasync setDefaultLocale(\n\t\tlocale: string,\n\t\taction: \"create\" | \"update\",\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst endpoint = {\n\t\t\tcreate: \"createMasterLang\",\n\t\t\tupdate: \"defineAsMaster\",\n\t\t};\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`/app/settings/multilanguages/${locale}/${endpoint[action]}`,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t// returns 400 if master lang is already set\n\t\t\t\tJSON.stringify(data).includes(\"Unable to set as master language\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not set default locale to ${locale}`);\n\t\t}\n\t\tprofiler.done({ message: `default locale set to '${locale}'` });\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\n\t *\n\t * @returns A Promise that resolves when the release is created.\n\t */\n\tasync createRelease(label: string): Promise<{ id: string }> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(this.name, \"app/releases\", {\n\t\t\tlabel,\n\t\t});\n\t\tthis.failIfNot200(response, `Could not create release ${label}`);\n\t\tprofiler.done({ message: `release '${label}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\n\t * @param repository - The name of the repository.\n\t * @param id - The ID of the release to be deleted.\n\t */\n\tasync deleteRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/releases/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete release with id ${id}`);\n\t\tprofiler.done({ message: `release '${id}' deleted` });\n\t}\n\n\t/**\n\t * Creates a preview for a repository.\n\t *\n\t * @param data - The data for creating the preview.\n\t */\n\tasync createPreview(data: Preview): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/new`,\n\t\t\tdata,\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not create preview ${data.name}`);\n\t\tprofiler.done({ message: `preview '${data.name}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a preview from a repository.\n\t *\n\t * @param id - The ID of the preview to be deleted.\n\t */\n\tasync deletePreview(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/delete/${id}`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete preview with id ${id}`);\n\t\tprofiler.done({ message: `preview '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes -\n\t */\n\tasync createCustomTypes(customTypes: CustomType[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes);\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices -\n\t */\n\tasync createSlices(slices: SharedSlice[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createSlices(slices);\n\t}\n\n\t/**\n\t * Create an access token to query private items of the Content api.\n\t *\n\t * @param appName - mandatory authorized application name\n\t * @param tokenScope - access token scope. Use \"master\" to when your content\n\t * api is fully private or \"master+releases\" to access private releases\n\t */\n\tasync createContentAPIToken(\n\t\tappName: string,\n\t\ttokenScope: \"master\" | \"master+releases\" = \"master\",\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\t\ttype AuthorizedAppResponse = {\n\t\t\tid: string;\n\t\t\tname: string;\n\t\t\twroom_auths: { token: string; scope: \"master\" | \"master+releases\" }[];\n\t\t};\n\t\tconst existingApps: AxiosResponse<AuthorizedAppResponse[]> =\n\t\t\tawait this.wroomClient.get(this.name, \"settings/security/contentapi\");\n\n\t\tthis.failIfNot200(\n\t\t\texistingApps,\n\t\t\t`Could not get status of existing applications to generate a content api token`,\n\t\t);\n\t\tlet app = existingApps.data.find(({ name, wroom_auths }) => {\n\t\t\treturn name === appName && wroom_auths.length > 0;\n\t\t});\n\n\t\tif (!app) {\n\t\t\tconst response: AxiosResponse<AuthorizedAppResponse> =\n\t\t\t\tawait this.wroomClient.post(this.name, \"settings/security/oauthapp\", {\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t});\n\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api app ${appName}`,\n\t\t\t);\n\t\t\tapp = response.data;\n\t\t}\n\n\t\tlet tokenInfo = app.wroom_auths.find(({ scope }) => scope === tokenScope);\n\t\tif (!tokenInfo) {\n\t\t\tconst response = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/authorizations\",\n\t\t\t\t{\n\t\t\t\t\tapp: app.id,\n\t\t\t\t\tscope: tokenScope,\n\t\t\t\t},\n\t\t\t);\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api access token for app ${appName} with scope ${tokenScope}`,\n\t\t\t);\n\t\t\ttokenInfo = response.data;\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `content api access token for app '${appName}' created`,\n\t\t});\n\n\t\tif (!tokenInfo?.token) {\n\t\t\tthrow `Could not create content api access token for app ${appName} with scope ${tokenScope}`;\n\t\t}\n\n\t\treturn tokenInfo.token;\n\t}\n\n\t/** Create a permanent access token to authenticate to Prismic public apis. */\n\tasync createPermanentAccessToken(): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst token = await this.authApiClient.getMachine2MachineToken(this.name);\n\n\t\tprofiler.done({\n\t\t\tmessage: `machine2machine token created`,\n\t\t});\n\n\t\treturn token;\n\t}\n\n\t/**\n\t * Toggle the Role per local feature\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleRolePerLocal(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.toggleRolePerLocal({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Role per local for ${\n\t\t\t\tthis.name\n\t\t\t}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Role per local ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t});\n\t}\n\n\t/**\n\t * Change the Repository Plan\n\t *\n\t * @param {string} newPlanId - The Id of the new Plan to apply\n\t */\n\tasync changePlan(newPlanId: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.changePlan({\n\t\t\trepository: this.name,\n\t\t\tnewPlanId: newPlanId,\n\t\t\tbypassManualBilling: true, // For now the library does not support Stripe features\n\t\t});\n\n\t\tthis.failIfNot200(response, \"Could not change the Repository Plan\");\n\t\tprofiler.done({\n\t\t\tmessage: `Repository Plan changed to ${newPlanId}`,\n\t\t});\n\t}\n\n\t/**\n\t * Add a new user to the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync addUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.addUserToRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 409 &&\n\t\t\t\tJSON.stringify(data).includes(\"already a member of the repo\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add a new user ${email} to the repository`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was added to the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Remove a user from the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync removeUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.removeUserFromRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not remove the user ${email} from the repository`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was removed from the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Update the role of a user in a repository\n\t *\n\t * @param {string} email - The email of the user\n\t * @param {string | Record<string, string>} role - The new Role of the user,\n\t * either a string for basic workflow or an object such as `{ \"lang_id\":\n\t * \"Writer\" }`\n\t *\n\t * Example of roles are\n\t *\n\t * - Administrator\n\t * - Writer\n\t * - Contributor\n\t * - Manager (publisher)\n\t */\n\tasync updateUserRole(\n\t\temail: string,\n\t\trole: string | Record<string, string>,\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response =\n\t\t\ttypeof role === \"string\"\n\t\t\t\t? await this.wroomClient.updateRole(this.name, email, role)\n\t\t\t\t: await this.wroomClient.updateRolePerLocal(this.name, email, role);\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not update the ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} of the user ${email}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Updated User's ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} for user ${email}`,\n\t\t});\n\t}\n\n\t/**\n\t * Creates a document using the core api. If the Core api format is too\n\t * specific, use the migration api client to create a document with the\n\t * MigrationApiClient. See the `getMigrationApiClient()` method.\n\t *\n\t * @example To create a document by converting it from the Page Builder to\n\t * Core api format\n\t *\n\t * ```js\n\t * import { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';\n\t *\n\t * const document = {\n\t * title: 'A new document',\n\t * custom_type_id: 'home-page',\n\t * locale: 'en-gb',\n\t * integration_field_ids: [],\n\t * tags: [],\n\t * data: DocumentLegacy.encode({\n\t * uid: {\n\t * __TYPE__: UIDContentType,\n\t * value: 'home-page',\n\t * },\n\t * })\n\t * }\n\t * await repository.createDocument(document, 'published');\n\t * \t * ```\n\t * ```\n\t *\n\t * @returns\n\t *\n\t * @param document - in the core api format.\n\t *\n\t * @param status - status of the document, if published, the function will\n\t * wait for a new content api master ref to be created\n\t */\n\tasync createDocument(\n\t\tdocument: CoreApiDocumentCreationPayload,\n\t\tstatus: \"draft\" | \"published\",\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst profiler = logger.startTimer();\n\t\tconst result = await this.coreApiClient.createDraft(document);\n\n\t\tlet message = `Document created with id '${result.id}'`;\n\t\tif (status === \"published\") {\n\t\t\tconst contentApi = this.getContentApiClient();\n\t\t\tconst masterRef = await contentApi.getMasterRef();\n\t\t\tawait this.coreApiClient.publishDraft(result.id);\n\t\t\tawait expect\n\t\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\t\ttimeout: 10_000,\n\t\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t\t})\n\t\t\t\t.not.toBe(masterRef);\n\t\t\tmessage += \", status 'published' and new master ref available\";\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage,\n\t\t});\n\n\t\treturn result;\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale;\n\tlocales?: string[];\n\tdefaultLocale?: string;\n\tslices?: SharedSlice[];\n\tcustomTypes?: CustomType[];\n\tpreview?: Preview;\n\trolePerLocal?: boolean;\n};\n\nexport type Preview = {\n\tname: string;\n\twebsiteURL: string;\n\tresolverPath: string;\n};\n\nexport type CustomLocale = {\n\tlang: {\n\t\tlabel: string;\n\t\tid: string;\n\t\tuseStandardAnalyzer?: boolean;\n\t};\n\tregion: {\n\t\tlabel: string;\n\t\tid: string;\n\t};\n};\n"],"names":[],"mappings":";;;;;;;;;;MAuBa,kBAAiB;AAAA,EAC7B,YACU,MACQ,eACA,eACA,aACA,sBACA,oBACA,gBAA8B;AANtC;AACQ;AACA;AACA;AACA;AACA;AACA;AANR,SAAI,OAAJ;AACQ,SAAa,gBAAb;AACA,SAAa,gBAAb;AACA,SAAW,cAAX;AACA,SAAoB,uBAApB;AACA,SAAkB,qBAAlB;AACA,SAAc,iBAAd;AAAA,EACf;AAAA,EAEH,MAAM,UAAU,QAAwB;AACvC,UAAM,gBACL,OAAO,iBAAiB,OAAO,WAAW,OAAO;AAClD,QAAI,eAAe;AAClB,YAAM,YAAY,MAAM,KAAK,cAAc,aAAY;AACvD,UAAI,8BAA8B;AAElC,UAAI,OAAO,eAAe;AACnB,cAAA,SAAS,UAAU,KAAK,CAAC,EAAE,gBAAgB,cAAc,IAAI;AACnE,YAAI,CAAC,QAAQ;AACZ,gBAAM,KAAK,iBAAiB,OAAO,eAAe,QAAQ;AAAA,QAChD,WAAA,OAAO,OAAO,OAAO,eAAe;AAEhB,wCAAA;AAAA,QAC/B;AAAA,MACD;AAEA,UAAI,OAAO,SAAS;AAEnB,cAAM,eAAe,OAAO,QAAQ,OACnC,CAAC,OAAO,CAAC,UAAU,KAAK,CAAC,aAAa,SAAS,OAAO,EAAE,CAAC;AAEtD,YAAA,aAAa,SAAS,GAAG;AACtB,gBAAA,KAAK,cAAc,YAAY;AAAA,QACtC;AAAA,MACD;AAEA,UAAI,OAAO,cAAc;AACxB,YAAI,CAAC,UAAU,KAAK,CAAC,EAAE,GAAA;;AAAS,0BAAO,YAAO,iBAAP,mBAAqB,KAAK;AAAA,SAAE,GAAG;AAC/D,gBAAA,KAAK,mBAAmB,OAAO,YAAY;AAAA,QAClD;AA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A,IAAA,CAClB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqCA,MAAM,eACL,UACA,QAA6B;AAEvB,UAAA,WAAW,OAAO;AACxB,UAAM,SAAS,MAAM,KAAK,cAAc,YAAY,QAAQ;AAExD,QAAA,UAAU,6BAA6B,OAAO,EAAE;AACpD,QAAI,WAAW,aAAa;AACrB,YAAA,aAAa,KAAK;AAClB,YAAA,YAAY,MAAM,WAAW;AACnC,YAAM,KAAK,cAAc,aAAa,OAAO,EAAE;AAC/C,YAAM,OACJ,KAAK,YAAY,WAAW,gBAAgB;AAAA,QAC5C,SAAS;AAAA,QACT,SAAS;AAAA,MACT,CAAA,EACA,IAAI,KAAK,SAAS;AACT,iBAAA;AAAA,IACZ;AACA,aAAS,KAAK;AAAA,MACb;AAAA,IAAA,CACA;AAEM,WAAA;AAAA,EACR;AACA;"}
1
+ {"version":3,"file":"repository.js","sources":["../../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\";\nimport { AxiosResponse } from \"axios\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { AssetApiClient } from \"../clients/assetApi\";\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\";\nimport { ContentApiClient } from \"../clients/contentApi\";\nimport {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n} from \"../clients/coreApi\";\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\";\nimport { ManageV2Client } from \"../clients/manageV2\";\nimport { MigrationApiClient } from \"../clients/migrationApi\";\nimport { WroomClient } from \"../clients/wroom\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\n/** Utility to manage test data for a Prismic repository */\nexport class RepositoryManager {\n\tconstructor(\n\t\treadonly name: string,\n\t\tprivate readonly coreApiClient: CoreApiClient,\n\t\tprivate readonly authApiClient: AuthenticationApiClient,\n\t\tprivate readonly wroomClient: WroomClient,\n\t\tprivate readonly customTypesApiClient: CustomTypesApiClient,\n\t\tprivate readonly migrationApiClient: MigrationApiClient | undefined,\n\t\tprivate readonly assetApiClient: AssetApiClient,\n\t\tprivate readonly manageV2Client: ManageV2Client,\n\t) {}\n\n\tasync configure(config: RepositoryConfig): Promise<void> {\n\t\tconst hasLangConfig =\n\t\t\tconfig.defaultLocale || config.locales || config.customLocale;\n\t\tif (hasLangConfig) {\n\t\t\tconst languages = await this.coreApiClient.getLanguages();\n\t\t\tlet updateDefaultLocaleAtTheEnd = false;\n\t\t\t// if no locale exists on repo, the master locale needs to be set first\n\t\t\tif (config.defaultLocale) {\n\t\t\t\tconst master = languages.find(({ is_master }) => is_master === true);\n\t\t\t\tif (!master) {\n\t\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"create\");\n\t\t\t\t} else if (master.id !== config.defaultLocale) {\n\t\t\t\t\t// update the master lang at the end, after it is created.\n\t\t\t\t\tupdateDefaultLocaleAtTheEnd = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.locales) {\n\t\t\t\t// No need to add default locale and already existing languages\n\t\t\t\tconst localesToAdd = config.locales.filter(\n\t\t\t\t\t(id) => !languages.some((language) => language.id === id),\n\t\t\t\t);\n\t\t\t\tif (localesToAdd.length > 0) {\n\t\t\t\t\tawait this.createLocales(localesToAdd);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.customLocale) {\n\t\t\t\tif (!languages.find(({ id }) => id === config.customLocale?.lang.id)) {\n\t\t\t\t\tawait this.createCustomLocale(config.customLocale);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.defaultLocale && updateDefaultLocaleAtTheEnd) {\n\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"update\");\n\t\t\t}\n\t\t}\n\n\t\tif (config.slices) {\n\t\t\tawait this.createSlices(config.slices);\n\t\t}\n\n\t\tif (config.customTypes) {\n\t\t\tawait this.createCustomTypes(config.customTypes);\n\t\t}\n\n\t\tif (config.preview) {\n\t\t\tawait this.createPreview(config.preview);\n\t\t}\n\n\t\tif (config.rolePerLocal) {\n\t\t\tawait this.toggleRolePerLocal(true);\n\t\t}\n\t}\n\n\t/** @returns the repository base url, like https://my-repo.prismic.io */\n\tgetBaseURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), this.name);\n\t}\n\n\t/** @returns the repository base cdn url, like https://my-repo.cdn.prismic.io */\n\tgetBaseCdnURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), `${this.name}.cdn`);\n\t}\n\n\t/**\n\t * @returns a Content Type api client configured to target the repository CDN\n\t * url. Uses Playwright for requests so if your project uses Playwright too,\n\t * any network request will be present in Playwright test reports.\n\t */\n\tgetContentApiClient(config?: {\n\t\tversion?: \"v1\" | \"v2\";\n\t\taccessToken?: string;\n\t}): ContentApiClient {\n\t\treturn new ContentApiClient(this.getBaseCdnURL(), config);\n\t}\n\n\t/**\n\t * @returns an instance of the Migration api client, see\n\t * https://prismic.io/docs/migration-api-technical-reference\n\t */\n\tgetMigrationApiClient(): MigrationApiClient {\n\t\tif (!this.migrationApiClient) {\n\t\t\tthrow \"No client found for the migration api. Did you provide a migration api url in the configuration?\";\n\t\t}\n\n\t\treturn this.migrationApiClient;\n\t}\n\n\t/**\n\t * @returns an instance of the Asset api client, see\n\t * https://prismic.io/docs/asset-api-technical-reference\n\t */\n\tgetAssetApiClient(): AssetApiClient {\n\t\treturn this.assetApiClient;\n\t}\n\n\t/** @returns the Wroom commit hash deployed on the current repository */\n\tasync getDeployedVersion(): Promise<string | undefined> {\n\t\tconst response = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"underground/834b34f16f451e00f268dd5c8c81d16e3c020275\",\n\t\t);\n\n\t\t// Somehow axios directly parses the text response `Prismic version: <commit hash> into a version attribute\n\t\treturn response.data.version;\n\t}\n\n\t/**\n\t * Set additional standard locales for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locales - An array of all locales to be added to the repository.\n\t *\n\t * @throws Error if setting the locales fails.\n\t */\n\tasync createLocales(locales: string[]): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages\",\n\t\t\t{ languages: locales },\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t(data as string).includes(\"already existing languages\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add locales ${locales.join(\", \")}`);\n\t\t}\n\t\tprofiler.done({ message: `locales '${locales}' created` });\n\t}\n\n\t/**\n\t * Set additional custom locale for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locale - The locale to be added to the repository.\n\t *\n\t * @throws Error if setting the locale fails.\n\t */\n\tasync createCustomLocale(locale: CustomLocale): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages/custom\",\n\t\t\tlocale,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 && JSON.stringify(data).includes(\"code is already used\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not create custom locale ${locale}`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `custom locale ${JSON.stringify(locale)} created`,\n\t\t});\n\t}\n\n\tprivate failIfNot200(response: AxiosResponse, msg: string) {\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(msg);\n\t\t}\n\t}\n\n\t/**\n\t * Delete a locale from a repository.\n\t *\n\t * @param locale - locale to remove from the repository configuration.\n\t *\n\t * @throws Error if deleting the locale fails.\n\t */\n\tasync deleteLocale(locale: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/multilanguages/${locale}/delete`,\n\t\t);\n\t\tthis.failIfNot200(response, `Could not delete locale ${locale}`);\n\t\tprofiler.done({ message: `locale '${locale}' deleted` });\n\t}\n\n\t/**\n\t * Create or update the default (master) locale for a repository in Wroom, the\n\t * locale needs to exist in the repository.\n\t *\n\t * @param locale - The locale to be set as the default.\n\t * @param endpoint - \"createMasterLang\" to create it, \"defineAsMaster\" to\n\t * update it.\n\t *\n\t * @throws Error if setting the default locale fails.\n\t */\n\tasync setDefaultLocale(\n\t\tlocale: string,\n\t\taction: \"create\" | \"update\",\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst endpoint = {\n\t\t\tcreate: \"createMasterLang\",\n\t\t\tupdate: \"defineAsMaster\",\n\t\t};\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`/app/settings/multilanguages/${locale}/${endpoint[action]}`,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t// returns 400 if master lang is already set\n\t\t\t\tJSON.stringify(data).includes(\"Unable to set as master language\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not set default locale to ${locale}`);\n\t\t}\n\t\tprofiler.done({ message: `default locale set to '${locale}'` });\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\n\t *\n\t * @returns A Promise that resolves when the release is created.\n\t */\n\tasync createRelease(label: string): Promise<{ id: string }> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(this.name, \"app/releases\", {\n\t\t\tlabel,\n\t\t});\n\t\tthis.failIfNot200(response, `Could not create release ${label}`);\n\t\tprofiler.done({ message: `release '${label}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\n\t * @param repository - The name of the repository.\n\t * @param id - The ID of the release to be deleted.\n\t */\n\tasync deleteRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/releases/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete release with id ${id}`);\n\t\tprofiler.done({ message: `release '${id}' deleted` });\n\t}\n\n\t/**\n\t * Creates a preview for a repository.\n\t *\n\t * @param data - The data for creating the preview.\n\t */\n\tasync createPreview(data: Preview): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/new`,\n\t\t\tdata,\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not create preview ${data.name}`);\n\t\tprofiler.done({ message: `preview '${data.name}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a preview from a repository.\n\t *\n\t * @param id - The ID of the preview to be deleted.\n\t */\n\tasync deletePreview(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`previews/delete/${id}`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete preview with id ${id}`);\n\t\tprofiler.done({ message: `preview '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create a webhook.\n\t *\n\t * @returns A Promise that resolves with the webhook id.\n\t */\n\tasync createWebhook(\n\t\tname: string,\n\t\turl: string,\n\t\tsecret: string,\n\t\ttriggers: {\n\t\t\tdocumentsPublished?: boolean;\n\t\t\tdocumentsUnpublished?: boolean;\n\t\t\treleasesCreated?: boolean;\n\t\t\treleasesUpdated?: boolean;\n\t\t\ttagsCreated?: boolean;\n\t\t\ttagsDeleted?: boolean;\n\t\t},\n\t\tactive: boolean,\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/webhooks/create\",\n\t\t\t{\n\t\t\t\tname,\n\t\t\t\turl,\n\t\t\t\tsecret,\n\t\t\t\tactive: active ? \"on\" : \"off\",\n\t\t\t\t...triggers,\n\t\t\t},\n\t\t);\n\t\tthis.failIfNot200(response, `Could not create webhook ${name}`);\n\t\tprofiler.done({ message: `webhook '${name}' created` });\n\n\t\treturn response.data.created;\n\t}\n\n\t/**\n\t * Deletes a webhook.\n\t *\n\t * @param id - The webhook ID.\n\t */\n\tasync deleteWebhook(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/webhooks/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete webhook with id ${id}`);\n\t\tprofiler.done({ message: `webhook '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes -\n\t */\n\tasync createCustomTypes(customTypes: CustomType[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes);\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices -\n\t */\n\tasync createSlices(slices: SharedSlice[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createSlices(slices);\n\t}\n\n\t/**\n\t * Create an access token to query private items of the Content api.\n\t *\n\t * @param appName - mandatory authorized application name\n\t * @param tokenScope - access token scope. Use \"master\" to when your content\n\t * api is fully private or \"master+releases\" to access private releases\n\t */\n\tasync createContentAPIToken(\n\t\tappName: string,\n\t\ttokenScope: \"master\" | \"master+releases\" = \"master\",\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\t\ttype AuthorizedAppResponse = {\n\t\t\tid: string;\n\t\t\tname: string;\n\t\t\twroom_auths: { token: string; scope: \"master\" | \"master+releases\" }[];\n\t\t};\n\t\tconst existingApps: AxiosResponse<AuthorizedAppResponse[]> =\n\t\t\tawait this.wroomClient.get(this.name, \"settings/security/contentapi\");\n\n\t\tthis.failIfNot200(\n\t\t\texistingApps,\n\t\t\t`Could not get status of existing applications to generate a content api token`,\n\t\t);\n\t\tlet app = existingApps.data.find(({ name, wroom_auths }) => {\n\t\t\treturn name === appName && wroom_auths.length > 0;\n\t\t});\n\n\t\tif (!app) {\n\t\t\tconst response: AxiosResponse<AuthorizedAppResponse> =\n\t\t\t\tawait this.wroomClient.post(this.name, \"settings/security/oauthapp\", {\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t});\n\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api app ${appName}`,\n\t\t\t);\n\t\t\tapp = response.data;\n\t\t}\n\n\t\tlet tokenInfo = app.wroom_auths.find(({ scope }) => scope === tokenScope);\n\t\tif (!tokenInfo) {\n\t\t\tconst response = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/authorizations\",\n\t\t\t\t{\n\t\t\t\t\tapp: app.id,\n\t\t\t\t\tscope: tokenScope,\n\t\t\t\t},\n\t\t\t);\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api access token for app ${appName} with scope ${tokenScope}`,\n\t\t\t);\n\t\t\ttokenInfo = response.data;\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `content api access token for app '${appName}' created`,\n\t\t});\n\n\t\tif (!tokenInfo?.token) {\n\t\t\tthrow `Could not create content api access token for app ${appName} with scope ${tokenScope}`;\n\t\t}\n\n\t\treturn tokenInfo.token;\n\t}\n\n\t/** Create a permanent access token to authenticate to Prismic public apis. */\n\tasync createPermanentAccessToken(): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst token = await this.authApiClient.getMachine2MachineToken(this.name);\n\n\t\tprofiler.done({\n\t\t\tmessage: `machine2machine token created`,\n\t\t});\n\n\t\treturn token;\n\t}\n\n\t/**\n\t * Toggle the Role per local feature\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleRolePerLocal(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.toggleRolePerLocal({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Role per local for ${\n\t\t\t\tthis.name\n\t\t\t}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Role per local ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t});\n\t}\n\n\t/**\n\t * Change the Repository Plan\n\t *\n\t * @param {string} newPlanId - The Id of the new Plan to apply\n\t */\n\tasync changePlan(newPlanId: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.changePlan({\n\t\t\trepository: this.name,\n\t\t\tnewPlanId: newPlanId,\n\t\t\tbypassManualBilling: true, // For now the library does not support Stripe features\n\t\t});\n\n\t\tthis.failIfNot200(response, \"Could not change the Repository Plan\");\n\t\tprofiler.done({\n\t\t\tmessage: `Repository Plan changed to ${newPlanId}`,\n\t\t});\n\t}\n\n\t/**\n\t * Add a new user to the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync addUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.addUserToRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 409 &&\n\t\t\t\tJSON.stringify(data).includes(\"already a member of the repo\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add a new user ${email} to the repository`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was added to the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Remove a user from the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync removeUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.removeUserFromRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not remove the user ${email} from the repository`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was removed from the repository`,\n\t\t});\n\t}\n\n\t/**\n\t * Update the role of a user in a repository\n\t *\n\t * @param {string} email - The email of the user\n\t * @param {string | Record<string, string>} role - The new Role of the user,\n\t * either a string for basic workflow or an object such as `{ \"lang_id\":\n\t * \"Writer\" }`\n\t *\n\t * Example of roles are\n\t *\n\t * - Administrator\n\t * - Writer\n\t * - Contributor\n\t * - Manager (publisher)\n\t */\n\tasync updateUserRole(\n\t\temail: string,\n\t\trole: string | Record<string, string>,\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response =\n\t\t\ttypeof role === \"string\"\n\t\t\t\t? await this.wroomClient.updateRole(this.name, email, role)\n\t\t\t\t: await this.wroomClient.updateRolePerLocal(this.name, email, role);\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not update the ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} of the user ${email}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Updated User's ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} for user ${email}`,\n\t\t});\n\t}\n\n\t/**\n\t * Creates a document using the core api. If the Core api format is too\n\t * specific, use the migration api client to create a document with the\n\t * MigrationApiClient. See the `getMigrationApiClient()` method.\n\t *\n\t * @example To create a document by converting it from the Page Builder to\n\t * Core api format\n\t *\n\t * ```js\n\t * import { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';\n\t *\n\t * const document = {\n\t * title: 'A new document',\n\t * custom_type_id: 'home-page',\n\t * locale: 'en-gb',\n\t * integration_field_ids: [],\n\t * tags: [],\n\t * data: DocumentLegacy.encode({\n\t * uid: {\n\t * __TYPE__: UIDContentType,\n\t * value: 'home-page',\n\t * },\n\t * })\n\t * }\n\t * await repository.createDocument(document, 'published');\n\t * \t * ```\n\t * ```\n\t *\n\t * @returns\n\t *\n\t * @param document - in the core api format.\n\t *\n\t * @param status - status of the document, if published, the function will\n\t * wait for a new content api master ref to be created\n\t */\n\tasync createDocument(\n\t\tdocument: CoreApiDocumentCreationPayload,\n\t\tstatus: \"draft\" | \"published\",\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst profiler = logger.startTimer();\n\t\tconst result = await this.coreApiClient.createDraft(document);\n\n\t\tlet message = `Document created with id '${result.id}'`;\n\t\tif (status === \"published\") {\n\t\t\tconst contentApi = this.getContentApiClient();\n\t\t\tconst masterRef = await contentApi.getMasterRef();\n\t\t\tawait this.coreApiClient.publishDraft(result.id);\n\t\t\tawait expect\n\t\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\t\ttimeout: 10_000,\n\t\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t\t})\n\t\t\t\t.not.toBe(masterRef);\n\t\t\tmessage += \", status 'published' and new master ref available\";\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage,\n\t\t});\n\n\t\treturn result;\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale;\n\tlocales?: string[];\n\tdefaultLocale?: string;\n\tslices?: SharedSlice[];\n\tcustomTypes?: CustomType[];\n\tpreview?: Preview;\n\trolePerLocal?: boolean;\n};\n\nexport type Preview = {\n\tname: string;\n\twebsiteURL: string;\n\tresolverPath: string;\n};\n\nexport type CustomLocale = {\n\tlang: {\n\t\tlabel: string;\n\t\tid: string;\n\t\tuseStandardAnalyzer?: boolean;\n\t};\n\tregion: {\n\t\tlabel: string;\n\t\tid: string;\n\t};\n};\n"],"names":[],"mappings":";;;;;;;MAwBa,kBAAiB;AAAA,EAC7B,YACU,MACQ,eACA,eACA,aACA,sBACA,oBACA,gBACA,gBAA8B;AAPtC;AACQ;AACA;AACA;AACA;AACA;AACA;AACA;AAPR,SAAI,OAAJ;AACQ,SAAa,gBAAb;AACA,SAAa,gBAAb;AACA,SAAW,cAAX;AACA,SAAoB,uBAApB;AACA,SAAkB,qBAAlB;AACA,SAAc,iBAAd;AACA,SAAc,iBAAd;AAAA,EAAA;AAAA,EAGlB,MAAM,UAAU,QAAwB;AACvC,UAAM,gBACL,OAAO,iBAAiB,OAAO,WAAW,OAAO;AAClD,QAAI,eAAe;AAClB,YAAM,YAAY,MAAM,KAAK,cAAc,aAAY;AACvD,UAAI,8BAA8B;AAElC,UAAI,OAAO,eAAe;AACnB,cAAA,SAAS,UAAU,KAAK,CAAC,EAAE,UAAS,MAAO,cAAc,IAAI;AACnE,YAAI,CAAC,QAAQ;AACZ,gBAAM,KAAK,iBAAiB,OAAO,eAAe,QAAQ;AAAA,QAChD,WAAA,OAAO,OAAO,OAAO,eAAe;AAEhB,wCAAA;AAAA,QAAA;AAAA,MAC/B;AAGD,UAAI,OAAO,SAAS;AAEnB,cAAM,eAAe,OAAO,QAAQ,OACnC,CAAC,OAAO,CAAC,UAAU,KAAK,CAAC,aAAa,SAAS,OAAO,EAAE,CAAC;AAEtD,YAAA,aAAa,SAAS,GAAG;AACtB,gBAAA,KAAK,cAAc,YAAY;AAAA,QAAA;AAAA,MACtC;AAGD,UAAI,OAAO,cAAc;AACxB,YAAI,CAAC,UAAU,KAAK,CAAC,EAAE,GAAA;;AAAS,0BAAO,YAAO,iBAAP,mBAAqB,KAAK;AAAA,SAA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AACpD,QAAI,WAAW,aAAa;AACrB,YAAA,aAAa,KAAK;AAClB,YAAA,YAAY,MAAM,WAAW;AACnC,YAAM,KAAK,cAAc,aAAa,OAAO,EAAE;AAC/C,YAAM,OACJ,KAAK,YAAY,WAAW,gBAAgB;AAAA,QAC5C,SAAS;AAAA,QACT,SAAS;AAAA,MAAA,CACT,EACA,IAAI,KAAK,SAAS;AACT,iBAAA;AAAA,IAAA;AAEZ,aAAS,KAAK;AAAA,MACb;AAAA,IAAA,CACA;AAEM,WAAA;AAAA,EAAA;AAER;"}
package/dist/types.d.ts CHANGED
@@ -7,6 +7,8 @@ export type UrlConfig = {
7
7
  authenticationApi: string;
8
8
  /** Prismic migration api base url */
9
9
  migrationApi?: string;
10
+ /** Asset api base url */
11
+ assetApi: string;
10
12
  };
11
13
  export type AuthConfig = {
12
14
  email: string;
@@ -21,4 +23,5 @@ export type SetupConfiguration = {
21
23
  authConfig: AuthConfig;
22
24
  manageV2Config?: ManageV2Config;
23
25
  cluster?: string;
26
+ environment?: string;
24
27
  };
@@ -1 +1 @@
1
- {"version":3,"file":"cookies.cjs","sources":["../../../src/utils/cookies.ts"],"sourcesContent":["import { AxiosHeaderValue } from \"axios\";\n\n/**\n * Extract the value of a specific cookie from Axios cookies.\n *\n * @param cookies - Axios cookies, can be a string or an array\n * @param cookieName - The name of the cookie to extract.\n */\nexport const extractCookie = (\n\tcookies: AxiosHeaderValue | undefined,\n\tcookieName: string,\n): string | undefined => {\n\tconst regex = new RegExp(`${cookieName}=([^;]+)`, \"i\"); // 'i' flag for case-insensitivity\n\n\tif (typeof cookies === \"string\") {\n\t\tconst match = cookies.match(regex);\n\n\t\treturn match ? match[1] : undefined;\n\t}\n\tif (Array.isArray(cookies)) {\n\t\tfor (const cookie of cookies) {\n\t\t\tconst match = cookie.match(regex);\n\t\t\tif (match) {\n\t\t\t\treturn match[1];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined;\n};\n"],"names":[],"mappings":";;AAQa,MAAA,gBAAgB,CAC5B,SACA,eACuB;AACvB,QAAM,QAAQ,IAAI,OAAO,GAAG,UAAU,YAAY,GAAG;AAEjD,MAAA,OAAO,YAAY,UAAU;AAC1B,UAAA,QAAQ,QAAQ,MAAM,KAAK;AAE1B,WAAA,QAAQ,MAAM,CAAC,IAAI;AAAA,EAC3B;AACI,MAAA,MAAM,QAAQ,OAAO,GAAG;AAC3B,eAAW,UAAU,SAAS;AACvB,YAAA,QAAQ,OAAO,MAAM,KAAK;AAChC,UAAI,OAAO;AACV,eAAO,MAAM,CAAC;AAAA,MACf;AAAA,IACD;AAAA,EACD;AAEO,SAAA;AACR;;"}
1
+ {"version":3,"file":"cookies.cjs","sources":["../../../src/utils/cookies.ts"],"sourcesContent":["import { AxiosHeaderValue } from \"axios\";\n\n/**\n * Extract the value of a specific cookie from Axios cookies.\n *\n * @param cookies - Axios cookies, can be a string or an array\n * @param cookieName - The name of the cookie to extract.\n */\nexport const extractCookie = (\n\tcookies: AxiosHeaderValue | undefined,\n\tcookieName: string,\n): string | undefined => {\n\tconst regex = new RegExp(`${cookieName}=([^;]+)`, \"i\"); // 'i' flag for case-insensitivity\n\n\tif (typeof cookies === \"string\") {\n\t\tconst match = cookies.match(regex);\n\n\t\treturn match ? match[1] : undefined;\n\t}\n\tif (Array.isArray(cookies)) {\n\t\tfor (const cookie of cookies) {\n\t\t\tconst match = cookie.match(regex);\n\t\t\tif (match) {\n\t\t\t\treturn match[1];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined;\n};\n"],"names":[],"mappings":";;AAQa,MAAA,gBAAgB,CAC5B,SACA,eACuB;AACvB,QAAM,QAAQ,IAAI,OAAO,GAAG,UAAU,YAAY,GAAG;AAEjD,MAAA,OAAO,YAAY,UAAU;AAC1B,UAAA,QAAQ,QAAQ,MAAM,KAAK;AAE1B,WAAA,QAAQ,MAAM,CAAC,IAAI;AAAA,EAAA;AAEvB,MAAA,MAAM,QAAQ,OAAO,GAAG;AAC3B,eAAW,UAAU,SAAS;AACvB,YAAA,QAAQ,OAAO,MAAM,KAAK;AAChC,UAAI,OAAO;AACV,eAAO,MAAM,CAAC;AAAA,MAAA;AAAA,IACf;AAAA,EACD;AAGM,SAAA;AACR;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"cookies.js","sources":["../../../src/utils/cookies.ts"],"sourcesContent":["import { AxiosHeaderValue } from \"axios\";\n\n/**\n * Extract the value of a specific cookie from Axios cookies.\n *\n * @param cookies - Axios cookies, can be a string or an array\n * @param cookieName - The name of the cookie to extract.\n */\nexport const extractCookie = (\n\tcookies: AxiosHeaderValue | undefined,\n\tcookieName: string,\n): string | undefined => {\n\tconst regex = new RegExp(`${cookieName}=([^;]+)`, \"i\"); // 'i' flag for case-insensitivity\n\n\tif (typeof cookies === \"string\") {\n\t\tconst match = cookies.match(regex);\n\n\t\treturn match ? match[1] : undefined;\n\t}\n\tif (Array.isArray(cookies)) {\n\t\tfor (const cookie of cookies) {\n\t\t\tconst match = cookie.match(regex);\n\t\t\tif (match) {\n\t\t\t\treturn match[1];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined;\n};\n"],"names":[],"mappings":"AAQa,MAAA,gBAAgB,CAC5B,SACA,eACuB;AACvB,QAAM,QAAQ,IAAI,OAAO,GAAG,UAAU,YAAY,GAAG;AAEjD,MAAA,OAAO,YAAY,UAAU;AAC1B,UAAA,QAAQ,QAAQ,MAAM,KAAK;AAE1B,WAAA,QAAQ,MAAM,CAAC,IAAI;AAAA,EAC3B;AACI,MAAA,MAAM,QAAQ,OAAO,GAAG;AAC3B,eAAW,UAAU,SAAS;AACvB,YAAA,QAAQ,OAAO,MAAM,KAAK;AAChC,UAAI,OAAO;AACV,eAAO,MAAM,CAAC;AAAA,MACf;AAAA,IACD;AAAA,EACD;AAEO,SAAA;AACR;"}
1
+ {"version":3,"file":"cookies.js","sources":["../../../src/utils/cookies.ts"],"sourcesContent":["import { AxiosHeaderValue } from \"axios\";\n\n/**\n * Extract the value of a specific cookie from Axios cookies.\n *\n * @param cookies - Axios cookies, can be a string or an array\n * @param cookieName - The name of the cookie to extract.\n */\nexport const extractCookie = (\n\tcookies: AxiosHeaderValue | undefined,\n\tcookieName: string,\n): string | undefined => {\n\tconst regex = new RegExp(`${cookieName}=([^;]+)`, \"i\"); // 'i' flag for case-insensitivity\n\n\tif (typeof cookies === \"string\") {\n\t\tconst match = cookies.match(regex);\n\n\t\treturn match ? match[1] : undefined;\n\t}\n\tif (Array.isArray(cookies)) {\n\t\tfor (const cookie of cookies) {\n\t\t\tconst match = cookie.match(regex);\n\t\t\tif (match) {\n\t\t\t\treturn match[1];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined;\n};\n"],"names":[],"mappings":"AAQa,MAAA,gBAAgB,CAC5B,SACA,eACuB;AACvB,QAAM,QAAQ,IAAI,OAAO,GAAG,UAAU,YAAY,GAAG;AAEjD,MAAA,OAAO,YAAY,UAAU;AAC1B,UAAA,QAAQ,QAAQ,MAAM,KAAK;AAE1B,WAAA,QAAQ,MAAM,CAAC,IAAI;AAAA,EAAA;AAEvB,MAAA,MAAM,QAAQ,OAAO,GAAG;AAC3B,eAAW,UAAU,SAAS;AACvB,YAAA,QAAQ,OAAO,MAAM,KAAK;AAChC,UAAI,OAAO;AACV,eAAO,MAAM,CAAC;AAAA,MAAA;AAAA,IACf;AAAA,EACD;AAGM,SAAA;AACR;"}
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => {
5
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
- return value;
7
- };
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
5
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
9
6
  class EnvVariableManager {
10
7
  constructor(variableName) {
@@ -1 +1 @@
1
- {"version":3,"file":"envVariableManager.cjs","sources":["../../../src/utils/envVariableManager.ts"],"sourcesContent":["/**\n * Manage a list of strings within an environment variable. This is useful to\n * share data across different test phases (setup, teardown, test execution) as\n * most test frameworks run these in independent states\n */\nexport class EnvVariableManager {\n\tconstructor(private variableName: string) {}\n\n\t/** add a string and persist it in the environment variable */\n\tadd(value: string): void {\n\t\tconst existingValues = this.getAll();\n\t\texistingValues.push(value);\n\n\t\tthis.setAll(existingValues);\n\t}\n\n\t/** remove a string from the environment variable */\n\tremove(value: string): void {\n\t\tconst existingValues = this.getAll();\n\t\tconst updatedValues = existingValues.filter((item) => item !== value);\n\n\t\tthis.setAll(updatedValues);\n\t}\n\n\t/** return all items stored in the environment variable */\n\tgetAll(): string[] {\n\t\tconst value = process.env[this.variableName] || \"[]\";\n\n\t\treturn JSON.parse(value);\n\t}\n\n\tprivate setAll(values: string[]): void {\n\t\tprocess.env[this.variableName] = JSON.stringify(values);\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;MAKa,mBAAkB;AAAA,EAC9B,YAAoB,cAAoB;AAApB;AAAA,SAAY,eAAZ;AAAA,EAAuB;AAAA;AAAA,EAG3C,IAAI,OAAa;AACV,UAAA,iBAAiB,KAAK;AAC5B,mBAAe,KAAK,KAAK;AAEzB,SAAK,OAAO,cAAc;AAAA,EAC3B;AAAA;AAAA,EAGA,OAAO,OAAa;AACb,UAAA,iBAAiB,KAAK;AAC5B,UAAM,gBAAgB,eAAe,OAAO,CAAC,SAAS,SAAS,KAAK;AAEpE,SAAK,OAAO,aAAa;AAAA,EAC1B;AAAA;AAAA,EAGA,SAAM;AACL,UAAM,QAAQ,QAAQ,IAAI,KAAK,YAAY,KAAK;AAEzC,WAAA,KAAK,MAAM,KAAK;AAAA,EACxB;AAAA,EAEQ,OAAO,QAAgB;AAC9B,YAAQ,IAAI,KAAK,YAAY,IAAI,KAAK,UAAU,MAAM;AAAA,EACvD;AACA;;"}
1
+ {"version":3,"file":"envVariableManager.cjs","sources":["../../../src/utils/envVariableManager.ts"],"sourcesContent":["/**\n * Manage a list of strings within an environment variable. This is useful to\n * share data across different test phases (setup, teardown, test execution) as\n * most test frameworks run these in independent states\n */\nexport class EnvVariableManager {\n\tconstructor(private variableName: string) {}\n\n\t/** add a string and persist it in the environment variable */\n\tadd(value: string): void {\n\t\tconst existingValues = this.getAll();\n\t\texistingValues.push(value);\n\n\t\tthis.setAll(existingValues);\n\t}\n\n\t/** remove a string from the environment variable */\n\tremove(value: string): void {\n\t\tconst existingValues = this.getAll();\n\t\tconst updatedValues = existingValues.filter((item) => item !== value);\n\n\t\tthis.setAll(updatedValues);\n\t}\n\n\t/** return all items stored in the environment variable */\n\tgetAll(): string[] {\n\t\tconst value = process.env[this.variableName] || \"[]\";\n\n\t\treturn JSON.parse(value);\n\t}\n\n\tprivate setAll(values: string[]): void {\n\t\tprocess.env[this.variableName] = JSON.stringify(values);\n\t}\n}\n"],"names":[],"mappings":";;;;;MAKa,mBAAkB;AAAA,EAC9B,YAAoB,cAAoB;AAApB;AAAA,SAAY,eAAZ;AAAA,EAAA;AAAA;AAAA,EAGpB,IAAI,OAAa;AACV,UAAA,iBAAiB,KAAK;AAC5B,mBAAe,KAAK,KAAK;AAEzB,SAAK,OAAO,cAAc;AAAA,EAAA;AAAA;AAAA,EAI3B,OAAO,OAAa;AACb,UAAA,iBAAiB,KAAK;AAC5B,UAAM,gBAAgB,eAAe,OAAO,CAAC,SAAS,SAAS,KAAK;AAEpE,SAAK,OAAO,aAAa;AAAA,EAAA;AAAA;AAAA,EAI1B,SAAM;AACL,UAAM,QAAQ,QAAQ,IAAI,KAAK,YAAY,KAAK;AAEzC,WAAA,KAAK,MAAM,KAAK;AAAA,EAAA;AAAA,EAGhB,OAAO,QAAgB;AAC9B,YAAQ,IAAI,KAAK,YAAY,IAAI,KAAK,UAAU,MAAM;AAAA,EAAA;AAEvD;;"}
@@ -1,9 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  class EnvVariableManager {
8
5
  constructor(variableName) {
9
6
  __publicField(this, "variableName");
@@ -1 +1 @@
1
- {"version":3,"file":"envVariableManager.js","sources":["../../../src/utils/envVariableManager.ts"],"sourcesContent":["/**\n * Manage a list of strings within an environment variable. This is useful to\n * share data across different test phases (setup, teardown, test execution) as\n * most test frameworks run these in independent states\n */\nexport class EnvVariableManager {\n\tconstructor(private variableName: string) {}\n\n\t/** add a string and persist it in the environment variable */\n\tadd(value: string): void {\n\t\tconst existingValues = this.getAll();\n\t\texistingValues.push(value);\n\n\t\tthis.setAll(existingValues);\n\t}\n\n\t/** remove a string from the environment variable */\n\tremove(value: string): void {\n\t\tconst existingValues = this.getAll();\n\t\tconst updatedValues = existingValues.filter((item) => item !== value);\n\n\t\tthis.setAll(updatedValues);\n\t}\n\n\t/** return all items stored in the environment variable */\n\tgetAll(): string[] {\n\t\tconst value = process.env[this.variableName] || \"[]\";\n\n\t\treturn JSON.parse(value);\n\t}\n\n\tprivate setAll(values: string[]): void {\n\t\tprocess.env[this.variableName] = JSON.stringify(values);\n\t}\n}\n"],"names":[],"mappings":";;;;;;MAKa,mBAAkB;AAAA,EAC9B,YAAoB,cAAoB;AAApB;AAAA,SAAY,eAAZ;AAAA,EAAuB;AAAA;AAAA,EAG3C,IAAI,OAAa;AACV,UAAA,iBAAiB,KAAK;AAC5B,mBAAe,KAAK,KAAK;AAEzB,SAAK,OAAO,cAAc;AAAA,EAC3B;AAAA;AAAA,EAGA,OAAO,OAAa;AACb,UAAA,iBAAiB,KAAK;AAC5B,UAAM,gBAAgB,eAAe,OAAO,CAAC,SAAS,SAAS,KAAK;AAEpE,SAAK,OAAO,aAAa;AAAA,EAC1B;AAAA;AAAA,EAGA,SAAM;AACL,UAAM,QAAQ,QAAQ,IAAI,KAAK,YAAY,KAAK;AAEzC,WAAA,KAAK,MAAM,KAAK;AAAA,EACxB;AAAA,EAEQ,OAAO,QAAgB;AAC9B,YAAQ,IAAI,KAAK,YAAY,IAAI,KAAK,UAAU,MAAM;AAAA,EACvD;AACA;"}
1
+ {"version":3,"file":"envVariableManager.js","sources":["../../../src/utils/envVariableManager.ts"],"sourcesContent":["/**\n * Manage a list of strings within an environment variable. This is useful to\n * share data across different test phases (setup, teardown, test execution) as\n * most test frameworks run these in independent states\n */\nexport class EnvVariableManager {\n\tconstructor(private variableName: string) {}\n\n\t/** add a string and persist it in the environment variable */\n\tadd(value: string): void {\n\t\tconst existingValues = this.getAll();\n\t\texistingValues.push(value);\n\n\t\tthis.setAll(existingValues);\n\t}\n\n\t/** remove a string from the environment variable */\n\tremove(value: string): void {\n\t\tconst existingValues = this.getAll();\n\t\tconst updatedValues = existingValues.filter((item) => item !== value);\n\n\t\tthis.setAll(updatedValues);\n\t}\n\n\t/** return all items stored in the environment variable */\n\tgetAll(): string[] {\n\t\tconst value = process.env[this.variableName] || \"[]\";\n\n\t\treturn JSON.parse(value);\n\t}\n\n\tprivate setAll(values: string[]): void {\n\t\tprocess.env[this.variableName] = JSON.stringify(values);\n\t}\n}\n"],"names":[],"mappings":";;;MAKa,mBAAkB;AAAA,EAC9B,YAAoB,cAAoB;AAApB;AAAA,SAAY,eAAZ;AAAA,EAAA;AAAA;AAAA,EAGpB,IAAI,OAAa;AACV,UAAA,iBAAiB,KAAK;AAC5B,mBAAe,KAAK,KAAK;AAEzB,SAAK,OAAO,cAAc;AAAA,EAAA;AAAA;AAAA,EAI3B,OAAO,OAAa;AACb,UAAA,iBAAiB,KAAK;AAC5B,UAAM,gBAAgB,eAAe,OAAO,CAAC,SAAS,SAAS,KAAK;AAEpE,SAAK,OAAO,aAAa;AAAA,EAAA;AAAA;AAAA,EAI1B,SAAM;AACL,UAAM,QAAQ,QAAQ,IAAI,KAAK,YAAY,KAAK;AAEzC,WAAA,KAAK,MAAM,KAAK;AAAA,EAAA;AAAA,EAGhB,OAAO,QAAgB;AAC9B,YAAQ,IAAI,KAAK,YAAY,IAAI,KAAK,UAAU,MAAM;AAAA,EAAA;AAEvD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"log.cjs","sources":["../../../src/utils/log.ts"],"sourcesContent":["import { APIResponse } from \"@playwright/test\";\nimport { AxiosResponse } from \"axios\";\nimport { createLogger, format, transports } from \"winston\";\n\nexport const logHttpResponse = (response: AxiosResponse): void => {\n\tconst { status, data } = response;\n\tconst { baseURL = \"\", url = \"\" } = response.config;\n\t// make sure the url always shows baseURL + path.\n\t// Depending on how the AxiosInstance was called, the url already contains the baseURL\n\tconst fullUrl = url.startsWith(\"http\") ? url : `${baseURL}/${url}`;\n\n\tlogger.info(\n\t\t`Call to ${fullUrl} failed, received [${status}] ${JSON.stringify(data)}`,\n\t);\n};\n\nexport const logPlaywrightApiResponse = async (\n\tresponse: APIResponse,\n): Promise<void> => {\n\tlogger.info(\n\t\t`Call to ${response.url()} failed, received [${response.status()}] ${JSON.stringify(\n\t\t\tawait response.text(),\n\t\t)}`,\n\t);\n};\n\nconst { combine, printf } = format;\n\nconst customFormat = printf(({ message, durationMs }) => {\n\tconst baseMsg = `[test data] ${message}`;\n\tif (durationMs) {\n\t\treturn `${baseMsg} in ${durationMs}ms`;\n\t}\n\n\treturn baseMsg;\n});\n\nexport const logger = createLogger({\n\tsilent: process.env[\"prismic_e2e_tests_utils_silent\"] === \"true\",\n\tlevel: process.env[\"prismic_e2e_tests_utils_log_level\"] || \"info\",\n\tformat: combine(customFormat),\n\ttransports: [new transports.Console()],\n});\n"],"names":["format","createLogger","transports"],"mappings":";;;AAIa,MAAA,kBAAkB,CAAC,aAAiC;AAC1D,QAAA,EAAE,QAAQ,KAAS,IAAA;AACzB,QAAM,EAAE,UAAU,IAAI,MAAM,OAAO,SAAS;AAGtC,QAAA,UAAU,IAAI,WAAW,MAAM,IAAI,MAAM,GAAG,OAAO,IAAI,GAAG;AAEzD,SAAA,KACN,WAAW,OAAO,sBAAsB,MAAM,KAAK,KAAK,UAAU,IAAI,CAAC,EAAE;AAE3E;AAEa,MAAA,2BAA2B,OACvC,aACkB;AAClB,SAAO,KACN,WAAW,SAAS,IAAK,CAAA,sBAAsB,SAAS,OAAQ,CAAA,KAAK,KAAK,UACzE,MAAM,SAAS,KAAM,CAAA,CACrB,EAAE;AAEL;AAEA,MAAM,EAAE,SAAS,OAAW,IAAAA;AAE5B,MAAM,eAAe,OAAO,CAAC,EAAE,SAAS,iBAAgB;AACjD,QAAA,UAAU,eAAe,OAAO;AACtC,MAAI,YAAY;AACR,WAAA,GAAG,OAAO,OAAO,UAAU;AAAA,EACnC;AAEO,SAAA;AACR,CAAC;AAEM,MAAM,SAASC,QAAAA,aAAa;AAAA,EAClC,QAAQ,QAAQ,IAAI,gCAAgC,MAAM;AAAA,EAC1D,OAAO,QAAQ,IAAI,mCAAmC,KAAK;AAAA,EAC3D,QAAQ,QAAQ,YAAY;AAAA,EAC5B,YAAY,CAAC,IAAIC,mBAAW,SAAS;AACrC,CAAA;;;;"}
1
+ {"version":3,"file":"log.cjs","sources":["../../../src/utils/log.ts"],"sourcesContent":["import { APIResponse } from \"@playwright/test\";\nimport { AxiosResponse } from \"axios\";\nimport { createLogger, format, transports } from \"winston\";\n\nexport const logHttpResponse = (response: AxiosResponse): void => {\n\tconst { status, data } = response;\n\tconst { baseURL = \"\", url = \"\" } = response.config;\n\t// make sure the url always shows baseURL + path.\n\t// Depending on how the AxiosInstance was called, the url already contains the baseURL\n\tconst fullUrl = url.startsWith(\"http\") ? url : `${baseURL}/${url}`;\n\n\tlogger.info(\n\t\t`Call to ${fullUrl} failed, received [${status}] ${JSON.stringify(data)}`,\n\t);\n};\n\nexport const logPlaywrightApiResponse = async (\n\tresponse: APIResponse,\n): Promise<void> => {\n\tlogger.info(\n\t\t`Call to ${response.url()} failed, received [${response.status()}] ${JSON.stringify(\n\t\t\tawait response.text(),\n\t\t)}`,\n\t);\n};\n\nconst { combine, printf } = format;\n\nconst customFormat = printf(({ message, durationMs }) => {\n\tconst baseMsg = `[test data] ${message}`;\n\tif (durationMs) {\n\t\treturn `${baseMsg} in ${durationMs}ms`;\n\t}\n\n\treturn baseMsg;\n});\n\nexport const logger = createLogger({\n\tsilent: process.env[\"prismic_e2e_tests_utils_silent\"] === \"true\",\n\tlevel: process.env[\"prismic_e2e_tests_utils_log_level\"] || \"info\",\n\tformat: combine(customFormat),\n\ttransports: [new transports.Console()],\n});\n"],"names":["format","createLogger","transports"],"mappings":";;;AAIa,MAAA,kBAAkB,CAAC,aAAiC;AAC1D,QAAA,EAAE,QAAQ,KAAA,IAAS;AACzB,QAAM,EAAE,UAAU,IAAI,MAAM,GAAA,IAAO,SAAS;AAGtC,QAAA,UAAU,IAAI,WAAW,MAAM,IAAI,MAAM,GAAG,OAAO,IAAI,GAAG;AAEzD,SAAA,KACN,WAAW,OAAO,sBAAsB,MAAM,KAAK,KAAK,UAAU,IAAI,CAAC,EAAE;AAE3E;AAEa,MAAA,2BAA2B,OACvC,aACkB;AAClB,SAAO,KACN,WAAW,SAAS,IAAK,CAAA,sBAAsB,SAAS,OAAA,CAAQ,KAAK,KAAK,UACzE,MAAM,SAAS,KAAM,CAAA,CACrB,EAAE;AAEL;AAEA,MAAM,EAAE,SAAS,OAAA,IAAWA,QAAA;AAE5B,MAAM,eAAe,OAAO,CAAC,EAAE,SAAS,iBAAgB;AACjD,QAAA,UAAU,eAAe,OAAO;AACtC,MAAI,YAAY;AACR,WAAA,GAAG,OAAO,OAAO,UAAU;AAAA,EAAA;AAG5B,SAAA;AACR,CAAC;AAEM,MAAM,SAASC,QAAAA,aAAa;AAAA,EAClC,QAAQ,QAAQ,IAAI,gCAAgC,MAAM;AAAA,EAC1D,OAAO,QAAQ,IAAI,mCAAmC,KAAK;AAAA,EAC3D,QAAQ,QAAQ,YAAY;AAAA,EAC5B,YAAY,CAAC,IAAIC,QAAA,WAAW,QAAS,CAAA;AACrC,CAAA;;;;"}
package/dist/utils/log.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createLogger, transports, format } from "winston";
1
+ import { format, createLogger, transports } from "winston";
2
2
  const logHttpResponse = (response) => {
3
3
  const { status, data } = response;
4
4
  const { baseURL = "", url = "" } = response.config;
@@ -1 +1 @@
1
- {"version":3,"file":"log.js","sources":["../../../src/utils/log.ts"],"sourcesContent":["import { APIResponse } from \"@playwright/test\";\nimport { AxiosResponse } from \"axios\";\nimport { createLogger, format, transports } from \"winston\";\n\nexport const logHttpResponse = (response: AxiosResponse): void => {\n\tconst { status, data } = response;\n\tconst { baseURL = \"\", url = \"\" } = response.config;\n\t// make sure the url always shows baseURL + path.\n\t// Depending on how the AxiosInstance was called, the url already contains the baseURL\n\tconst fullUrl = url.startsWith(\"http\") ? url : `${baseURL}/${url}`;\n\n\tlogger.info(\n\t\t`Call to ${fullUrl} failed, received [${status}] ${JSON.stringify(data)}`,\n\t);\n};\n\nexport const logPlaywrightApiResponse = async (\n\tresponse: APIResponse,\n): Promise<void> => {\n\tlogger.info(\n\t\t`Call to ${response.url()} failed, received [${response.status()}] ${JSON.stringify(\n\t\t\tawait response.text(),\n\t\t)}`,\n\t);\n};\n\nconst { combine, printf } = format;\n\nconst customFormat = printf(({ message, durationMs }) => {\n\tconst baseMsg = `[test data] ${message}`;\n\tif (durationMs) {\n\t\treturn `${baseMsg} in ${durationMs}ms`;\n\t}\n\n\treturn baseMsg;\n});\n\nexport const logger = createLogger({\n\tsilent: process.env[\"prismic_e2e_tests_utils_silent\"] === \"true\",\n\tlevel: process.env[\"prismic_e2e_tests_utils_log_level\"] || \"info\",\n\tformat: combine(customFormat),\n\ttransports: [new transports.Console()],\n});\n"],"names":[],"mappings":";AAIa,MAAA,kBAAkB,CAAC,aAAiC;AAC1D,QAAA,EAAE,QAAQ,KAAS,IAAA;AACzB,QAAM,EAAE,UAAU,IAAI,MAAM,OAAO,SAAS;AAGtC,QAAA,UAAU,IAAI,WAAW,MAAM,IAAI,MAAM,GAAG,OAAO,IAAI,GAAG;AAEzD,SAAA,KACN,WAAW,OAAO,sBAAsB,MAAM,KAAK,KAAK,UAAU,IAAI,CAAC,EAAE;AAE3E;AAEa,MAAA,2BAA2B,OACvC,aACkB;AAClB,SAAO,KACN,WAAW,SAAS,IAAK,CAAA,sBAAsB,SAAS,OAAQ,CAAA,KAAK,KAAK,UACzE,MAAM,SAAS,KAAM,CAAA,CACrB,EAAE;AAEL;AAEA,MAAM,EAAE,SAAS,OAAW,IAAA;AAE5B,MAAM,eAAe,OAAO,CAAC,EAAE,SAAS,iBAAgB;AACjD,QAAA,UAAU,eAAe,OAAO;AACtC,MAAI,YAAY;AACR,WAAA,GAAG,OAAO,OAAO,UAAU;AAAA,EACnC;AAEO,SAAA;AACR,CAAC;AAEM,MAAM,SAAS,aAAa;AAAA,EAClC,QAAQ,QAAQ,IAAI,gCAAgC,MAAM;AAAA,EAC1D,OAAO,QAAQ,IAAI,mCAAmC,KAAK;AAAA,EAC3D,QAAQ,QAAQ,YAAY;AAAA,EAC5B,YAAY,CAAC,IAAI,WAAW,SAAS;AACrC,CAAA;"}
1
+ {"version":3,"file":"log.js","sources":["../../../src/utils/log.ts"],"sourcesContent":["import { APIResponse } from \"@playwright/test\";\nimport { AxiosResponse } from \"axios\";\nimport { createLogger, format, transports } from \"winston\";\n\nexport const logHttpResponse = (response: AxiosResponse): void => {\n\tconst { status, data } = response;\n\tconst { baseURL = \"\", url = \"\" } = response.config;\n\t// make sure the url always shows baseURL + path.\n\t// Depending on how the AxiosInstance was called, the url already contains the baseURL\n\tconst fullUrl = url.startsWith(\"http\") ? url : `${baseURL}/${url}`;\n\n\tlogger.info(\n\t\t`Call to ${fullUrl} failed, received [${status}] ${JSON.stringify(data)}`,\n\t);\n};\n\nexport const logPlaywrightApiResponse = async (\n\tresponse: APIResponse,\n): Promise<void> => {\n\tlogger.info(\n\t\t`Call to ${response.url()} failed, received [${response.status()}] ${JSON.stringify(\n\t\t\tawait response.text(),\n\t\t)}`,\n\t);\n};\n\nconst { combine, printf } = format;\n\nconst customFormat = printf(({ message, durationMs }) => {\n\tconst baseMsg = `[test data] ${message}`;\n\tif (durationMs) {\n\t\treturn `${baseMsg} in ${durationMs}ms`;\n\t}\n\n\treturn baseMsg;\n});\n\nexport const logger = createLogger({\n\tsilent: process.env[\"prismic_e2e_tests_utils_silent\"] === \"true\",\n\tlevel: process.env[\"prismic_e2e_tests_utils_log_level\"] || \"info\",\n\tformat: combine(customFormat),\n\ttransports: [new transports.Console()],\n});\n"],"names":[],"mappings":";AAIa,MAAA,kBAAkB,CAAC,aAAiC;AAC1D,QAAA,EAAE,QAAQ,KAAA,IAAS;AACzB,QAAM,EAAE,UAAU,IAAI,MAAM,GAAA,IAAO,SAAS;AAGtC,QAAA,UAAU,IAAI,WAAW,MAAM,IAAI,MAAM,GAAG,OAAO,IAAI,GAAG;AAEzD,SAAA,KACN,WAAW,OAAO,sBAAsB,MAAM,KAAK,KAAK,UAAU,IAAI,CAAC,EAAE;AAE3E;AAEa,MAAA,2BAA2B,OACvC,aACkB;AAClB,SAAO,KACN,WAAW,SAAS,IAAK,CAAA,sBAAsB,SAAS,OAAA,CAAQ,KAAK,KAAK,UACzE,MAAM,SAAS,KAAM,CAAA,CACrB,EAAE;AAEL;AAEA,MAAM,EAAE,SAAS,OAAA,IAAW;AAE5B,MAAM,eAAe,OAAO,CAAC,EAAE,SAAS,iBAAgB;AACjD,QAAA,UAAU,eAAe,OAAO;AACtC,MAAI,YAAY;AACR,WAAA,GAAG,OAAO,OAAO,UAAU;AAAA,EAAA;AAG5B,SAAA;AACR,CAAC;AAEM,MAAM,SAAS,aAAa;AAAA,EAClC,QAAQ,QAAQ,IAAI,gCAAgC,MAAM;AAAA,EAC1D,OAAO,QAAQ,IAAI,mCAAmC,KAAK;AAAA,EAC3D,QAAQ,QAAQ,YAAY;AAAA,EAC5B,YAAY,CAAC,IAAI,WAAW,QAAS,CAAA;AACrC,CAAA;"}
@@ -1 +1 @@
1
- {"version":3,"file":"urls.cjs","sources":["../../../src/utils/urls.ts"],"sourcesContent":["/**\n * Build a repository base url from the prismic base url\n *\n * @param baseUrl - prismic base url like prismic.io\n * @param repository - the repository name\n *\n * @returns the repository url like https://my-repo.prismic.io\n */\nexport function getRepositoryUrl(baseUrl: string, repository: string): string {\n\tconst url = new URL(baseUrl);\n\turl.hostname = `${repository}.${url.hostname}`;\n\n\treturn url.toString();\n}\n\n/**\n * Prevent issues when building urls using `URL` that contain sub path without\n * trailing slashes.\n *\n * @returns the original url with a trailing slash, if needed.\n */\nexport function appendTrailingSlash(url: string): string {\n\tif (!url.endsWith(\"/\")) {\n\t\treturn url + \"/\";\n\t}\n\n\treturn url;\n}\n"],"names":[],"mappings":";;AAQgB,SAAA,iBAAiB,SAAiB,YAAkB;AAC7D,QAAA,MAAM,IAAI,IAAI,OAAO;AAC3B,MAAI,WAAW,GAAG,UAAU,IAAI,IAAI,QAAQ;AAE5C,SAAO,IAAI;AACZ;AAQM,SAAU,oBAAoB,KAAW;AAC9C,MAAI,CAAC,IAAI,SAAS,GAAG,GAAG;AACvB,WAAO,MAAM;AAAA,EACd;AAEO,SAAA;AACR;;;"}
1
+ {"version":3,"file":"urls.cjs","sources":["../../../src/utils/urls.ts"],"sourcesContent":["/**\n * Build a repository base url from the prismic base url\n *\n * @param baseUrl - prismic base url like prismic.io\n * @param repository - the repository name\n *\n * @returns the repository url like https://my-repo.prismic.io\n */\nexport function getRepositoryUrl(baseUrl: string, repository: string): string {\n\tconst url = new URL(baseUrl);\n\turl.hostname = `${repository}.${url.hostname}`;\n\n\treturn url.toString();\n}\n\n/**\n * Prevent issues when building urls using `URL` that contain sub path without\n * trailing slashes.\n *\n * @returns the original url with a trailing slash, if needed.\n */\nexport function appendTrailingSlash(url: string): string {\n\tif (!url.endsWith(\"/\")) {\n\t\treturn url + \"/\";\n\t}\n\n\treturn url;\n}\n"],"names":[],"mappings":";;AAQgB,SAAA,iBAAiB,SAAiB,YAAkB;AAC7D,QAAA,MAAM,IAAI,IAAI,OAAO;AAC3B,MAAI,WAAW,GAAG,UAAU,IAAI,IAAI,QAAQ;AAE5C,SAAO,IAAI,SAAQ;AACpB;AAQM,SAAU,oBAAoB,KAAW;AAC9C,MAAI,CAAC,IAAI,SAAS,GAAG,GAAG;AACvB,WAAO,MAAM;AAAA,EAAA;AAGP,SAAA;AACR;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"urls.js","sources":["../../../src/utils/urls.ts"],"sourcesContent":["/**\n * Build a repository base url from the prismic base url\n *\n * @param baseUrl - prismic base url like prismic.io\n * @param repository - the repository name\n *\n * @returns the repository url like https://my-repo.prismic.io\n */\nexport function getRepositoryUrl(baseUrl: string, repository: string): string {\n\tconst url = new URL(baseUrl);\n\turl.hostname = `${repository}.${url.hostname}`;\n\n\treturn url.toString();\n}\n\n/**\n * Prevent issues when building urls using `URL` that contain sub path without\n * trailing slashes.\n *\n * @returns the original url with a trailing slash, if needed.\n */\nexport function appendTrailingSlash(url: string): string {\n\tif (!url.endsWith(\"/\")) {\n\t\treturn url + \"/\";\n\t}\n\n\treturn url;\n}\n"],"names":[],"mappings":"AAQgB,SAAA,iBAAiB,SAAiB,YAAkB;AAC7D,QAAA,MAAM,IAAI,IAAI,OAAO;AAC3B,MAAI,WAAW,GAAG,UAAU,IAAI,IAAI,QAAQ;AAE5C,SAAO,IAAI;AACZ;AAQM,SAAU,oBAAoB,KAAW;AAC9C,MAAI,CAAC,IAAI,SAAS,GAAG,GAAG;AACvB,WAAO,MAAM;AAAA,EACd;AAEO,SAAA;AACR;"}
1
+ {"version":3,"file":"urls.js","sources":["../../../src/utils/urls.ts"],"sourcesContent":["/**\n * Build a repository base url from the prismic base url\n *\n * @param baseUrl - prismic base url like prismic.io\n * @param repository - the repository name\n *\n * @returns the repository url like https://my-repo.prismic.io\n */\nexport function getRepositoryUrl(baseUrl: string, repository: string): string {\n\tconst url = new URL(baseUrl);\n\turl.hostname = `${repository}.${url.hostname}`;\n\n\treturn url.toString();\n}\n\n/**\n * Prevent issues when building urls using `URL` that contain sub path without\n * trailing slashes.\n *\n * @returns the original url with a trailing slash, if needed.\n */\nexport function appendTrailingSlash(url: string): string {\n\tif (!url.endsWith(\"/\")) {\n\t\treturn url + \"/\";\n\t}\n\n\treturn url;\n}\n"],"names":[],"mappings":"AAQgB,SAAA,iBAAiB,SAAiB,YAAkB;AAC7D,QAAA,MAAM,IAAI,IAAI,OAAO;AAC3B,MAAI,WAAW,GAAG,UAAU,IAAI,IAAI,QAAQ;AAE5C,SAAO,IAAI,SAAQ;AACpB;AAQM,SAAU,oBAAoB,KAAW;AAC9C,MAAI,CAAC,IAAI,SAAS,GAAG,GAAG;AACvB,WAAO,MAAM;AAAA,EAAA;AAGP,SAAA;AACR;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/e2e-tests-utils",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.1",
4
4
  "description": "A collection of utilities for to manage Prismic test data",
5
5
  "keywords": [
6
6
  "typescript",