@prismicio/e2e-tests-utils 1.18.0 → 1.19.0-canary.d349d21

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 (159) hide show
  1. package/README.md +24 -27
  2. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  3. package/dist/clients/apiClient.cjs +38 -38
  4. package/dist/clients/apiClient.cjs.map +1 -1
  5. package/dist/clients/apiClient.d.cts +30 -0
  6. package/dist/clients/apiClient.d.cts.map +1 -0
  7. package/dist/clients/apiClient.d.ts +23 -23
  8. package/dist/clients/apiClient.d.ts.map +1 -0
  9. package/dist/clients/apiClient.js +38 -38
  10. package/dist/clients/apiClient.js.map +1 -1
  11. package/dist/clients/assetApi.cjs +81 -93
  12. package/dist/clients/assetApi.cjs.map +1 -1
  13. package/dist/clients/assetApi.d.cts +105 -0
  14. package/dist/clients/assetApi.d.cts.map +1 -0
  15. package/dist/clients/assetApi.d.ts +96 -97
  16. package/dist/clients/assetApi.d.ts.map +1 -0
  17. package/dist/clients/assetApi.js +79 -91
  18. package/dist/clients/assetApi.js.map +1 -1
  19. package/dist/clients/authenticationApi.cjs +66 -73
  20. package/dist/clients/authenticationApi.cjs.map +1 -1
  21. package/dist/clients/authenticationApi.d.cts +20 -0
  22. package/dist/clients/authenticationApi.d.cts.map +1 -0
  23. package/dist/clients/authenticationApi.d.ts +18 -13
  24. package/dist/clients/authenticationApi.d.ts.map +1 -0
  25. package/dist/clients/authenticationApi.js +65 -72
  26. package/dist/clients/authenticationApi.js.map +1 -1
  27. package/dist/clients/contentApi.cjs +94 -103
  28. package/dist/clients/contentApi.cjs.map +1 -1
  29. package/dist/clients/contentApi.d.cts +116 -0
  30. package/dist/clients/contentApi.d.cts.map +1 -0
  31. package/dist/clients/contentApi.d.ts +102 -98
  32. package/dist/clients/contentApi.d.ts.map +1 -0
  33. package/dist/clients/contentApi.js +94 -103
  34. package/dist/clients/contentApi.js.map +1 -1
  35. package/dist/clients/coreApi.cjs +154 -145
  36. package/dist/clients/coreApi.cjs.map +1 -1
  37. package/dist/clients/coreApi.d.cts +143 -0
  38. package/dist/clients/coreApi.d.cts.map +1 -0
  39. package/dist/clients/coreApi.d.ts +132 -109
  40. package/dist/clients/coreApi.d.ts.map +1 -0
  41. package/dist/clients/coreApi.js +153 -144
  42. package/dist/clients/coreApi.js.map +1 -1
  43. package/dist/clients/customTypesApi.cjs +90 -99
  44. package/dist/clients/customTypesApi.cjs.map +1 -1
  45. package/dist/clients/customTypesApi.d.cts +46 -0
  46. package/dist/clients/customTypesApi.d.cts.map +1 -0
  47. package/dist/clients/customTypesApi.d.ts +45 -45
  48. package/dist/clients/customTypesApi.d.ts.map +1 -0
  49. package/dist/clients/customTypesApi.js +87 -98
  50. package/dist/clients/customTypesApi.js.map +1 -1
  51. package/dist/clients/integrationFields.cjs +96 -87
  52. package/dist/clients/integrationFields.cjs.map +1 -1
  53. package/dist/clients/integrationFields.d.cts +30 -0
  54. package/dist/clients/integrationFields.d.cts.map +1 -0
  55. package/dist/clients/integrationFields.d.ts +27 -22
  56. package/dist/clients/integrationFields.d.ts.map +1 -0
  57. package/dist/clients/integrationFields.js +93 -86
  58. package/dist/clients/integrationFields.js.map +1 -1
  59. package/dist/clients/manageV2.cjs +154 -171
  60. package/dist/clients/manageV2.cjs.map +1 -1
  61. package/dist/clients/manageV2.d.cts +105 -0
  62. package/dist/clients/manageV2.d.cts.map +1 -0
  63. package/dist/clients/manageV2.d.ts +103 -111
  64. package/dist/clients/manageV2.d.ts.map +1 -0
  65. package/dist/clients/manageV2.js +149 -169
  66. package/dist/clients/manageV2.js.map +1 -1
  67. package/dist/clients/migrationApi.cjs +37 -36
  68. package/dist/clients/migrationApi.cjs.map +1 -1
  69. package/dist/clients/migrationApi.d.cts +48 -0
  70. package/dist/clients/migrationApi.d.cts.map +1 -0
  71. package/dist/clients/migrationApi.d.ts +45 -39
  72. package/dist/clients/migrationApi.d.ts.map +1 -0
  73. package/dist/clients/migrationApi.js +35 -34
  74. package/dist/clients/migrationApi.js.map +1 -1
  75. package/dist/clients/wroom.cjs +101 -122
  76. package/dist/clients/wroom.cjs.map +1 -1
  77. package/dist/clients/wroom.d.cts +48 -0
  78. package/dist/clients/wroom.d.cts.map +1 -0
  79. package/dist/clients/wroom.d.ts +46 -47
  80. package/dist/clients/wroom.d.ts.map +1 -0
  81. package/dist/clients/wroom.js +99 -122
  82. package/dist/clients/wroom.js.map +1 -1
  83. package/dist/index.cjs +13 -15
  84. package/dist/index.d.cts +8 -0
  85. package/dist/index.d.ts +8 -7
  86. package/dist/index.js +5 -14
  87. package/dist/managers/repositories.cjs +159 -169
  88. package/dist/managers/repositories.cjs.map +1 -1
  89. package/dist/managers/repositories.d.cts +67 -0
  90. package/dist/managers/repositories.d.cts.map +1 -0
  91. package/dist/managers/repositories.d.ts +56 -63
  92. package/dist/managers/repositories.d.ts.map +1 -0
  93. package/dist/managers/repositories.js +148 -159
  94. package/dist/managers/repositories.js.map +1 -1
  95. package/dist/managers/repository.cjs +595 -616
  96. package/dist/managers/repository.cjs.map +1 -1
  97. package/dist/managers/repository.d.cts +341 -0
  98. package/dist/managers/repository.d.cts.map +1 -0
  99. package/dist/managers/repository.d.ts +336 -307
  100. package/dist/managers/repository.d.ts.map +1 -0
  101. package/dist/managers/repository.js +595 -616
  102. package/dist/managers/repository.js.map +1 -1
  103. package/dist/types.d.cts +41 -0
  104. package/dist/types.d.cts.map +1 -0
  105. package/dist/types.d.ts +35 -37
  106. package/dist/types.d.ts.map +1 -0
  107. package/dist/utils/cookies.cjs +19 -17
  108. package/dist/utils/cookies.cjs.map +1 -1
  109. package/dist/utils/cookies.js +20 -18
  110. package/dist/utils/cookies.js.map +1 -1
  111. package/dist/utils/envVariableManager.cjs +33 -34
  112. package/dist/utils/envVariableManager.cjs.map +1 -1
  113. package/dist/utils/envVariableManager.js +34 -35
  114. package/dist/utils/envVariableManager.js.map +1 -1
  115. package/dist/utils/log.cjs +18 -19
  116. package/dist/utils/log.cjs.map +1 -1
  117. package/dist/utils/log.js +18 -21
  118. package/dist/utils/log.js.map +1 -1
  119. package/dist/utils/random.cjs +13 -6
  120. package/dist/utils/random.cjs.map +1 -1
  121. package/dist/utils/random.js +13 -6
  122. package/dist/utils/random.js.map +1 -1
  123. package/dist/utils/strings.cjs +13 -7
  124. package/dist/utils/strings.cjs.map +1 -1
  125. package/dist/utils/strings.js +14 -8
  126. package/dist/utils/strings.js.map +1 -1
  127. package/dist/utils/urls.cjs +21 -10
  128. package/dist/utils/urls.cjs.map +1 -1
  129. package/dist/utils/urls.js +22 -12
  130. package/dist/utils/urls.js.map +1 -1
  131. package/package.json +42 -67
  132. package/src/clients/apiClient.ts +16 -21
  133. package/src/clients/assetApi.ts +75 -82
  134. package/src/clients/authenticationApi.ts +54 -27
  135. package/src/clients/contentApi.ts +111 -129
  136. package/src/clients/coreApi.ts +166 -117
  137. package/src/clients/customTypesApi.ts +54 -74
  138. package/src/clients/integrationFields.ts +59 -74
  139. package/src/clients/manageV2.ts +72 -96
  140. package/src/clients/migrationApi.ts +35 -39
  141. package/src/clients/wroom.ts +42 -56
  142. package/src/index.ts +7 -7
  143. package/src/managers/repositories.ts +85 -108
  144. package/src/managers/repository.ts +410 -378
  145. package/src/types.ts +31 -31
  146. package/src/utils/cookies.ts +8 -8
  147. package/src/utils/envVariableManager.ts +15 -15
  148. package/src/utils/log.ts +17 -21
  149. package/src/utils/random.ts +5 -6
  150. package/src/utils/strings.ts +7 -9
  151. package/src/utils/urls.ts +10 -12
  152. package/dist/index.cjs.map +0 -1
  153. package/dist/index.js.map +0 -1
  154. package/dist/utils/cookies.d.ts +0 -8
  155. package/dist/utils/envVariableManager.d.ts +0 -16
  156. package/dist/utils/log.d.ts +0 -5
  157. package/dist/utils/random.d.ts +0 -8
  158. package/dist/utils/strings.d.ts +0 -11
  159. package/dist/utils/urls.d.ts +0 -16
@@ -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 { IntegrationFieldConfig } from \"../types\";\n\nimport { AssetApiClient } from \"../clients/assetApi\";\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\";\nimport { ContentApiClient } from \"../clients/contentApi\";\nimport {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n\tCoreApiDocumentData,\n\tCoreApiDocumentsPayload,\n\tCoreApiDocumentsResponse,\n\tRelease,\n} from \"../clients/coreApi\";\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\";\nimport { IntegrationFieldsClient } from \"../clients/integrationFields\";\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\tprivate readonly integrationFieldsClient:\n\t\t\t| IntegrationFieldsClient\n\t\t\t| undefined,\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.simulatorURL) {\n\t\t\tawait this.setSimulatorURL(config.simulatorURL);\n\t\t}\n\n\t\tif (config.rolePerLocal) {\n\t\t\tawait this.toggleRolePerLocal(true);\n\t\t}\n\n\t\tif (config.customRoles) {\n\t\t\tawait this.toggleCustomRoles(true);\n\t\t}\n\n\t\tif (config.integrationFields) {\n\t\t\tawait this.toggleIntegrationFields(true);\n\t\t\tawait this.setupIntegrationFields(config.integrationFields);\n\t\t}\n\t}\n\n\t/** @returns the repository base url, like https://my-repo.prismic.io */\n\tgetBaseURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), this.name);\n\t}\n\n\t/** @returns the repository base cdn url, like https://my-repo.cdn.prismic.io */\n\tgetBaseCdnURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), `${this.name}.cdn`);\n\t}\n\n\t/**\n\t * @returns a Content Type api client configured to target the repository CDN\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 * Retrieves documents.\n\t *\n\t * @param args - Configure which documents are retrieved.\n\t *\n\t * @returns A paginated set of documents.\n\t */\n\tasync getDocuments(\n\t\targs: CoreApiDocumentsPayload,\n\t): Promise<CoreApiDocumentsResponse> {\n\t\treturn this.coreApiClient.getDocuments(args);\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\n\t *\n\t * @returns A Promise that resolves when the release is created.\n\t */\n\tasync createRelease(label: string): Promise<{ id: string }> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(this.name, \"app/releases\", {\n\t\t\tlabel,\n\t\t});\n\t\tthis.failIfNot200(response, `Could not create release ${label}`);\n\t\tprofiler.done({ message: `release '${label}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Retrieves the migration release.\n\t *\n\t * @returns The migration relese metadata.\n\t */\n\tasync getMigrationRelease(): Promise<Release> {\n\t\tconst releases = await this.coreApiClient.getReleases();\n\t\tconst migrationRelease = releases.find((release) => release.migration);\n\t\tif (!migrationRelease) {\n\t\t\tthrow new Error(`The repository does not have a migration release`);\n\t\t}\n\n\t\treturn migrationRelease;\n\t}\n\n\t/**\n\t * Publishes a release.\n\t *\n\t * @param id - The ID of the release.\n\t *\n\t * @returns A Promise that resolves when the release is published and a new\n\t * master ref is available.\n\t */\n\tasync publishRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst contentApi = this.getContentApiClient();\n\t\tconst masterRef = await contentApi.getMasterRef();\n\t\tawait this.coreApiClient.publishRelease(id);\n\t\tawait expect\n\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\ttimeout: 10_000,\n\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t})\n\t\t\t.not.toBe(masterRef);\n\n\t\tprofiler.done({\n\t\t\tmessage: `release '${id}' published and new master ref available`,\n\t\t});\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\n\t * @param id - The ID of the release to be deleted.\n\t */\n\tasync deleteRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\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 * Set the simulator URL (table of slices) for a repository.\n\t *\n\t * @param data - The simulator URL to set.\n\t */\n\tasync setSimulatorURL(simulatorURL: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst repository = await this.coreApiClient.getRepository();\n\t\tawait this.coreApiClient.updateRepository({\n\t\t\t...repository,\n\t\t\tsimulator_url: simulatorURL,\n\t\t});\n\n\t\tprofiler.done({\n\t\t\tmessage: `simulator preview '${simulatorURL}' created`,\n\t\t});\n\t}\n\n\t/**\n\t * Deletes a preview from a repository.\n\t *\n\t * @param id - The ID of the preview to be deleted.\n\t */\n\tasync deletePreview(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\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\tasync deleteCustomType(customTypeId: string): Promise<void> {\n\t\tawait this.customTypesApiClient.deleteCustomType(customTypeId);\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices -\n\t */\n\tasync createSlices(slices: SharedSlice[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createSlices(slices);\n\t}\n\n\t/**\n\t * Create an access token to query private items of the Content api.\n\t *\n\t * @param appName - mandatory authorized application name\n\t * @param tokenScope - access token scope. Use \"master\" to when your content\n\t * api is fully private or \"master+releases\" to access private releases\n\t */\n\tasync createContentAPIToken(\n\t\tappName: string,\n\t\ttokenScope: \"master\" | \"master+releases\" = \"master\",\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\t\ttype AuthorizedAppResponse = {\n\t\t\tid: string;\n\t\t\tname: string;\n\t\t\twroom_auths: { token: string; scope: \"master\" | \"master+releases\" }[];\n\t\t};\n\t\tconst existingApps: AxiosResponse<AuthorizedAppResponse[]> =\n\t\t\tawait this.wroomClient.get(this.name, \"settings/security/contentapi\");\n\n\t\tthis.failIfNot200(\n\t\t\texistingApps,\n\t\t\t`Could not get status of existing applications to generate a content api token`,\n\t\t);\n\t\tlet app = existingApps.data.find(({ name, wroom_auths }) => {\n\t\t\treturn name === appName && wroom_auths.length > 0;\n\t\t});\n\n\t\tif (!app) {\n\t\t\tconst response: AxiosResponse<AuthorizedAppResponse> =\n\t\t\t\tawait this.wroomClient.post(this.name, \"settings/security/oauthapp\", {\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t});\n\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api app ${appName}`,\n\t\t\t);\n\t\t\tapp = response.data;\n\t\t}\n\n\t\tlet tokenInfo = app.wroom_auths.find(({ scope }) => scope === tokenScope);\n\t\tif (!tokenInfo) {\n\t\t\tconst response = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/authorizations\",\n\t\t\t\t{\n\t\t\t\t\tapp: app.id,\n\t\t\t\t\tscope: tokenScope,\n\t\t\t\t},\n\t\t\t);\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api access token for app ${appName} with scope ${tokenScope}`,\n\t\t\t);\n\t\t\ttokenInfo = response.data;\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `content api access token for app '${appName}' created`,\n\t\t});\n\n\t\tif (!tokenInfo?.token) {\n\t\t\tthrow `Could not create content api access token for app ${appName} with scope ${tokenScope}`;\n\t\t}\n\n\t\treturn tokenInfo.token;\n\t}\n\n\t/** Create a permanent access token to authenticate to Prismic public apis. */\n\tasync createPermanentAccessToken(): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst token = await this.authApiClient.getMachine2MachineToken(this.name);\n\n\t\tprofiler.done({\n\t\t\tmessage: `machine2machine token created`,\n\t\t});\n\n\t\treturn token;\n\t}\n\n\t/**\n\t * Toggle the Role per Locale workflow\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleRolePerLocal(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.toggleRolePerLocal({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Role per local for ${\n\t\t\t\tthis.name\n\t\t\t}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Role per local ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t});\n\t}\n\n\t/**\n\t * Toggle the Custom Roles workflow\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleCustomRoles(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.toggleCustomRoles({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Custom Roles for ${\n\t\t\t\tthis.name\n\t\t\t}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Custom Roles ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t});\n\t}\n\n\t/**\n\t * Toggle the Integration Fields feature\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleIntegrationFields(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.toggleIntegrationFields({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t});\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Integration Fields for ${\n\t\t\t\tthis.name\n\t\t\t}`,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Integration Fields ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t});\n\t}\n\n\t/**\n\t * Change the Repository Plan\n\t *\n\t * @param {string} newPlanId - The Id of the new Plan to apply\n\t */\n\tasync changePlan(newPlanId: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.changePlan({\n\t\t\trepository: this.name,\n\t\t\tnewPlanId: newPlanId,\n\t\t\tbypassManualBilling: true, // For now the library does not support Stripe features\n\t\t});\n\n\t\tthis.failIfNot200(response, \"Could not change the Repository Plan\");\n\t\tprofiler.done({\n\t\t\tmessage: `Repository Plan changed to ${newPlanId}`,\n\t\t});\n\t}\n\n\t/**\n\t * Add a new user to the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync addUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.manageV2Client.addUserToRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t});\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 409 &&\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\t/**\n\t * Retrieves data for a specific document version.\n\t *\n\t * @param versionId - The document's version ID.\n\t *\n\t * @returns The document's version data.\n\t */\n\tasync getDocumentData(versionId: string): Promise<CoreApiDocumentData> {\n\t\treturn await this.coreApiClient.getDocumentData(versionId);\n\t}\n\n\tasync setupIntegrationFields(\n\t\tintegrationFields: IntegrationFieldConfig[],\n\t): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tif (!this.integrationFieldsClient) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Integration Fields client not found. Did you provide a integration fields api url in the configuration?\",\n\t\t\t);\n\t\t}\n\n\t\tawait this.integrationFieldsClient.setupIntegrationFields(\n\t\t\tintegrationFields,\n\t\t);\n\t\tprofiler.done({\n\t\t\tmessage: `Integration Fields setup`,\n\t\t});\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale;\n\tlocales?: string[];\n\tdefaultLocale?: string;\n\tslices?: SharedSlice[];\n\tcustomTypes?: CustomType[];\n\tpreview?: Preview;\n\tsimulatorURL?: string;\n\trolePerLocal?: boolean;\n\tcustomRoles?: boolean;\n\tintegrationFields?: IntegrationFieldConfig[];\n};\n\nexport type Preview = {\n\tname: string;\n\twebsiteURL: string;\n\tresolverPath: string;\n};\n\nexport type CustomLocale = {\n\tlang: {\n\t\tlabel: string;\n\t\tid: string;\n\t\tuseStandardAnalyzer?: boolean;\n\t};\n\tregion: {\n\t\tlabel: string;\n\t\tid: string;\n\t};\n};\n"],"names":["getRepositoryUrl","ContentApiClient","logger","logHttpResponse","contentApi","expect"],"mappings":";;;;;;;;;;;;MA+Ba,kBAAiB;AAAA,EAC7B,YACU,MACQ,eACA,eACA,aACA,sBACA,oBACA,gBACA,gBACA,yBAEL;AAVH;AACQ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARR,SAAI,OAAJ;AACQ,SAAa,gBAAb;AACA,SAAa,gBAAb;AACA,SAAW,cAAX;AACA,SAAoB,uBAApB;AACA,SAAkB,qBAAlB;AACA,SAAc,iBAAd;AACA,SAAc,iBAAd;AACA,SAAuB,0BAAvB;AAAA,EAGf;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,QACl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AA;AAAA;AAAA,EASA,MAAM,gBAAgB,WAAiB;AACtC,WAAO,MAAM,KAAK,cAAc,gBAAgB,SAAS;AAAA,EAC1D;AAAA,EAEA,MAAM,uBACL,mBAA2C;AAErC,UAAA,WAAWF,WAAO;AAEpB,QAAA,CAAC,KAAK,yBAAyB;AAC5B,YAAA,IAAI,MACT,yGAAyG;AAAA,IAE3G;AAEM,UAAA,KAAK,wBAAwB,uBAClC,iBAAiB;AAElB,aAAS,KAAK;AAAA,MACb,SAAS;AAAA,IAAA,CACT;AAAA,EACF;AACA;;"}
1
+ {"version":3,"file":"repository.cjs","names":["getRepositoryUrl","ContentApiClient","logger","expect"],"sources":["../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\"\nimport type { DynamicCustomTypeModel, SharedSliceModel } from \"@prismicio/types-internal\"\nimport type { AxiosResponse } from \"axios\"\n\nimport type { AssetApiClient } from \"../clients/assetApi\"\nimport type { AuthenticationApiClient } from \"../clients/authenticationApi\"\nimport { ContentApiClient } from \"../clients/contentApi\"\nimport type {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n\tCoreApiDocumentData,\n\tCoreApiDocumentsPayload,\n\tCoreApiDocumentsResponse,\n\tCoreApiDocumentUpdatePayload,\n\tRelease,\n} from \"../clients/coreApi\"\nimport type { CustomTypesApiClient } from \"../clients/customTypesApi\"\nimport type { IntegrationFieldsClient } from \"../clients/integrationFields\"\nimport type { ManageV2Client } from \"../clients/manageV2\"\nimport type { MigrationApiClient } from \"../clients/migrationApi\"\nimport type { WroomClient } from \"../clients/wroom\"\nimport type { IntegrationFieldConfig } from \"../types\"\nimport { logHttpResponse, logger } from \"../utils/log\"\nimport { getRepositoryUrl } from \"../utils/urls\"\n\n/** Utility to manage test data for a Prismic repository */\nexport class RepositoryManager {\n\tconstructor(\n\t\treadonly name: string,\n\t\tprivate readonly coreApiClient: CoreApiClient,\n\t\tprivate readonly authApiClient: AuthenticationApiClient,\n\t\tprivate readonly wroomClient: WroomClient,\n\t\tprivate readonly customTypesApiClient: CustomTypesApiClient,\n\t\tprivate readonly migrationApiClient: MigrationApiClient | undefined,\n\t\tprivate readonly assetApiClient: AssetApiClient,\n\t\tprivate readonly manageV2Client: ManageV2Client,\n\t\tprivate readonly integrationFieldsClient: IntegrationFieldsClient | undefined,\n\t) {}\n\n\tasync configure(config: RepositoryConfig): Promise<void> {\n\t\tconst hasLangConfig = config.defaultLocale || config.locales || config.customLocale\n\t\tif (hasLangConfig) {\n\t\t\tconst languages = await this.coreApiClient.getLanguages()\n\t\t\tlet updateDefaultLocaleAtTheEnd = false\n\t\t\t// if no locale exists on repo, the master locale needs to be set first\n\t\t\tif (config.defaultLocale) {\n\t\t\t\tconst master = languages.find(({ is_master }) => is_master === true)\n\t\t\t\tif (!master) {\n\t\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"create\")\n\t\t\t\t} else if (master.id !== config.defaultLocale) {\n\t\t\t\t\t// update the master lang at the end, after it is created.\n\t\t\t\t\tupdateDefaultLocaleAtTheEnd = true\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.locales) {\n\t\t\t\t// No need to add default locale and already existing languages\n\t\t\t\tconst localesToAdd = config.locales.filter(\n\t\t\t\t\t(id) => !languages.some((language) => language.id === id),\n\t\t\t\t)\n\t\t\t\tif (localesToAdd.length > 0) {\n\t\t\t\t\tawait this.createLocales(localesToAdd)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.customLocale) {\n\t\t\t\tif (!languages.find(({ id }) => id === config.customLocale?.lang.id)) {\n\t\t\t\t\tawait this.createCustomLocale(config.customLocale)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.defaultLocale && updateDefaultLocaleAtTheEnd) {\n\t\t\t\tawait this.setDefaultLocale(config.defaultLocale, \"update\")\n\t\t\t}\n\t\t}\n\n\t\tif (config.slices) {\n\t\t\tawait this.createSlices(config.slices)\n\t\t}\n\n\t\tif (config.customTypes) {\n\t\t\tawait this.createCustomTypes(config.customTypes)\n\t\t}\n\n\t\tif (config.preview) {\n\t\t\tawait this.createPreview(config.preview)\n\t\t}\n\n\t\tif (config.simulatorURL) {\n\t\t\tawait this.setSimulatorURL(config.simulatorURL)\n\t\t}\n\n\t\tif (config.rolePerLocal) {\n\t\t\tawait this.toggleRolePerLocal(true)\n\t\t}\n\n\t\tif (config.customRoles) {\n\t\t\tawait this.toggleCustomRoles(true)\n\t\t}\n\n\t\tif (config.integrationFields) {\n\t\t\tawait this.toggleIntegrationFields(true)\n\t\t\tawait this.setupIntegrationFields(config.integrationFields)\n\t\t}\n\t}\n\n\t/** @returns The repository base url, like https://my-repo.prismic.io */\n\tgetBaseURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), this.name)\n\t}\n\n\t/** @returns The repository base cdn url, like https://my-repo.cdn.prismic.io */\n\tgetBaseCdnURL(): string {\n\t\treturn getRepositoryUrl(this.wroomClient.getBaseURL(), `${this.name}.cdn`)\n\t}\n\n\t/**\n\t * @returns A Content Type api client configured to target the repository CDN url. Uses Playwright\n\t * for requests so if your project uses Playwright too, any network request will be present in\n\t * Playwright test reports.\n\t */\n\tgetContentApiClient(config?: { version?: \"v1\" | \"v2\"; accessToken?: string }): ContentApiClient {\n\t\treturn new ContentApiClient(this.getBaseCdnURL(), config)\n\t}\n\n\t/**\n\t * @returns An instance of the Migration api client, see\n\t * https://prismic.io/docs/migration-api-technical-reference\n\t */\n\tgetMigrationApiClient(): MigrationApiClient {\n\t\tif (!this.migrationApiClient) {\n\t\t\tthrow \"No client found for the migration api. Did you provide a migration api url in the configuration?\"\n\t\t}\n\n\t\treturn this.migrationApiClient\n\t}\n\n\t/**\n\t * @returns An instance of the Asset api client, see\n\t * https://prismic.io/docs/asset-api-technical-reference\n\t */\n\tgetAssetApiClient(): AssetApiClient {\n\t\treturn this.assetApiClient\n\t}\n\n\t/** @returns The Wroom commit hash deployed on the current repository */\n\tasync getDeployedVersion(): Promise<string | undefined> {\n\t\tconst response = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"underground/834b34f16f451e00f268dd5c8c81d16e3c020275\",\n\t\t)\n\n\t\t// Somehow axios directly parses the text response `Prismic version: <commit hash> into a version attribute\n\t\treturn response.data.version\n\t}\n\n\t/**\n\t * Set additional standard locales for a repository in Wroom, does not fail if the locales already\n\t * exist.\n\t *\n\t * @param locales - An array of all locales to be added to the repository.\n\t * @throws Error if setting the locales fails.\n\t */\n\tasync createLocales(locales: string[]): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(this.name, \"app/settings/multilanguages\", {\n\t\t\tlanguages: locales,\n\t\t})\n\n\t\tconst { data, status } = response\n\t\tconst success =\n\t\t\tstatus === 200 || (status === 400 && (data as string).includes(\"already existing languages\"))\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response)\n\t\t\tthrow new Error(`Could not add locales ${locales.join(\", \")}`)\n\t\t}\n\t\tprofiler.done({ message: `locales '${locales}' created` })\n\t}\n\n\t/**\n\t * Set additional custom locale for a repository in Wroom, does not fail if the locales already\n\t * exist.\n\t *\n\t * @param locale - The locale to be added to the repository.\n\t * @throws Error if setting the locale fails.\n\t */\n\tasync createCustomLocale(locale: CustomLocale): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages/custom\",\n\t\t\tlocale,\n\t\t)\n\n\t\tconst { data, status } = response\n\t\tconst success =\n\t\t\tstatus === 200 || (status === 400 && JSON.stringify(data).includes(\"code is already used\"))\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response)\n\t\t\tthrow new Error(`Could not create custom locale ${locale}`)\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `custom locale ${JSON.stringify(locale)} created`,\n\t\t})\n\t}\n\n\tprivate failIfNot200(response: AxiosResponse, msg: string) {\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response)\n\t\t\tthrow new Error(msg)\n\t\t}\n\t}\n\n\t/**\n\t * Delete a locale from a repository.\n\t *\n\t * @param locale - Locale to remove from the repository configuration.\n\t * @throws Error if deleting the locale fails.\n\t */\n\tasync deleteLocale(locale: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/multilanguages/${locale}/delete`,\n\t\t)\n\t\tthis.failIfNot200(response, `Could not delete locale ${locale}`)\n\t\tprofiler.done({ message: `locale '${locale}' deleted` })\n\t}\n\n\t/**\n\t * Create or update the default (master) locale for a repository in Wroom, the locale needs to\n\t * exist in the repository.\n\t *\n\t * @param locale - The locale to be set as the default.\n\t * @param endpoint - \"createMasterLang\" to create it, \"defineAsMaster\" to update it.\n\t * @throws Error if setting the default locale fails.\n\t */\n\tasync setDefaultLocale(locale: string, action: \"create\" | \"update\"): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst endpoint = {\n\t\t\tcreate: \"createMasterLang\",\n\t\t\tupdate: \"defineAsMaster\",\n\t\t}\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`/app/settings/multilanguages/${locale}/${endpoint[action]}`,\n\t\t)\n\n\t\tconst { data, status } = response\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t// returns 400 if master lang is already set\n\t\t\t\tJSON.stringify(data).includes(\"Unable to set as master language\"))\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response)\n\t\t\tthrow new Error(`Could not set default locale to ${locale}`)\n\t\t}\n\t\tprofiler.done({ message: `default locale set to '${locale}'` })\n\t}\n\n\t/**\n\t * Retrieves documents.\n\t *\n\t * @param args - Configure which documents are retrieved.\n\t * @returns A paginated set of documents.\n\t */\n\tasync getDocuments(args: CoreApiDocumentsPayload): Promise<CoreApiDocumentsResponse> {\n\t\treturn this.coreApiClient.getDocuments(args)\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\n\t * @returns A Promise that resolves when the release is created.\n\t */\n\tasync createRelease(label: string): Promise<{ id: string }> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(this.name, \"app/releases\", {\n\t\t\tlabel,\n\t\t})\n\t\tthis.failIfNot200(response, `Could not create release ${label}`)\n\t\tprofiler.done({ message: `release '${label}' created` })\n\n\t\treturn response.data\n\t}\n\n\t/**\n\t * Retrieves the migration release.\n\t *\n\t * @returns The migration relese metadata.\n\t */\n\tasync getMigrationRelease(): Promise<Release> {\n\t\tconst releases = await this.coreApiClient.getReleases()\n\t\tconst migrationRelease = releases.find((release) => release.migration)\n\t\tif (!migrationRelease) {\n\t\t\tthrow new Error(`The repository does not have a migration release`)\n\t\t}\n\n\t\treturn migrationRelease\n\t}\n\n\t/**\n\t * Publishes a release.\n\t *\n\t * @param id - The ID of the release.\n\t * @returns A Promise that resolves when the release is published and a new master ref is\n\t * available.\n\t */\n\tasync publishRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst contentApi = this.getContentApiClient()\n\t\tconst masterRef = await contentApi.getMasterRef()\n\t\tawait this.coreApiClient.publishRelease(id)\n\t\tawait this.waitForNewMasterRef(contentApi, masterRef)\n\n\t\tprofiler.done({\n\t\t\tmessage: `release '${id}' published and new master ref available`,\n\t\t})\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\n\t * @param id - The ID of the release to be deleted.\n\t */\n\tasync deleteRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(this.name, `app/releases/${id}/delete`, {})\n\n\t\tthis.failIfNot200(response, `Could not delete release with id ${id}`)\n\t\tprofiler.done({ message: `release '${id}' deleted` })\n\t}\n\n\t/**\n\t * Creates a preview for a repository.\n\t *\n\t * @param data - The data for creating the preview.\n\t */\n\tasync createPreview(data: Preview): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(this.name, `previews/new`, data)\n\n\t\tthis.failIfNot200(response, `Could not create preview ${data.name}`)\n\t\tprofiler.done({ message: `preview '${data.name}' created` })\n\n\t\treturn response.data\n\t}\n\n\t/**\n\t * Set the simulator URL (table of slices) for a repository.\n\t *\n\t * @param data - The simulator URL to set.\n\t */\n\tasync setSimulatorURL(simulatorURL: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst repository = await this.coreApiClient.getRepository()\n\t\tawait this.coreApiClient.updateRepository({\n\t\t\t...repository,\n\t\t\tsimulator_url: simulatorURL,\n\t\t})\n\n\t\tprofiler.done({\n\t\t\tmessage: `simulator preview '${simulatorURL}' created`,\n\t\t})\n\t}\n\n\t/**\n\t * Deletes a preview from a repository.\n\t *\n\t * @param id - The ID of the preview to be deleted.\n\t */\n\tasync deletePreview(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(this.name, `previews/delete/${id}`, {})\n\n\t\tthis.failIfNot200(response, `Could not delete preview with id ${id}`)\n\t\tprofiler.done({ message: `preview '${id}' deleted` })\n\t}\n\n\t/**\n\t * Create a webhook.\n\t *\n\t * @returns A Promise that resolves with the webhook id.\n\t */\n\tasync createWebhook(\n\t\tname: string,\n\t\turl: string,\n\t\tsecret: string,\n\t\ttriggers: {\n\t\t\tdocumentsPublished?: boolean\n\t\t\tdocumentsUnpublished?: boolean\n\t\t\treleasesCreated?: boolean\n\t\t\treleasesUpdated?: boolean\n\t\t\ttagsCreated?: boolean\n\t\t\ttagsDeleted?: boolean\n\t\t},\n\t\tactive: boolean,\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(this.name, \"app/settings/webhooks/create\", {\n\t\t\tname,\n\t\t\turl,\n\t\t\tsecret,\n\t\t\tactive: active ? \"on\" : \"off\",\n\t\t\t...triggers,\n\t\t})\n\t\tthis.failIfNot200(response, `Could not create webhook ${name}`)\n\t\tprofiler.done({ message: `webhook '${name}' created` })\n\n\t\treturn response.data.created\n\t}\n\n\t/**\n\t * Deletes a webhook.\n\t *\n\t * @param id - The webhook ID.\n\t */\n\tasync deleteWebhook(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/webhooks/${id}/delete`,\n\t\t\t{},\n\t\t)\n\n\t\tthis.failIfNot200(response, `Could not delete webhook with id ${id}`)\n\t\tprofiler.done({ message: `webhook '${id}' deleted` })\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes\n\t */\n\tasync createCustomTypes(customTypes: DynamicCustomTypeModel[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes)\n\t}\n\n\tasync deleteCustomType(customTypeId: string): Promise<void> {\n\t\tawait this.customTypesApiClient.deleteCustomType(customTypeId)\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices\n\t */\n\tasync createSlices(slices: SharedSliceModel[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createSlices(slices)\n\t}\n\n\t/**\n\t * Create an access token to query private items of the Content api.\n\t *\n\t * @param appName - Mandatory authorized application name\n\t * @param tokenScope - Access token scope. Use \"master\" to when your content api is fully private\n\t * or \"master+releases\" to access private releases\n\t */\n\tasync createContentAPIToken(\n\t\tappName: string,\n\t\ttokenScope: \"master\" | \"master+releases\" = \"master\",\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer()\n\t\ttype AuthorizedAppResponse = {\n\t\t\tid: string\n\t\t\tname: string\n\t\t\twroom_auths: { token: string; scope: \"master\" | \"master+releases\" }[]\n\t\t}\n\t\tconst existingApps: AxiosResponse<AuthorizedAppResponse[]> = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"settings/security/contentapi\",\n\t\t)\n\n\t\tthis.failIfNot200(\n\t\t\texistingApps,\n\t\t\t`Could not get status of existing applications to generate a content api token`,\n\t\t)\n\t\tlet app = existingApps.data.find(({ name, wroom_auths }) => {\n\t\t\treturn name === appName && wroom_auths.length > 0\n\t\t})\n\n\t\tif (!app) {\n\t\t\tconst response: AxiosResponse<AuthorizedAppResponse> = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/oauthapp\",\n\t\t\t\t{\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tthis.failIfNot200(response, `Could not create content api app ${appName}`)\n\t\t\tapp = response.data\n\t\t}\n\n\t\tlet tokenInfo = app.wroom_auths.find(({ scope }) => scope === tokenScope)\n\t\tif (!tokenInfo) {\n\t\t\tconst response = await this.wroomClient.post(this.name, \"settings/security/authorizations\", {\n\t\t\t\tapp: app.id,\n\t\t\t\tscope: tokenScope,\n\t\t\t})\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api access token for app ${appName} with scope ${tokenScope}`,\n\t\t\t)\n\t\t\ttokenInfo = response.data\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `content api access token for app '${appName}' created`,\n\t\t})\n\n\t\tif (!tokenInfo?.token) {\n\t\t\tthrow `Could not create content api access token for app ${appName} with scope ${tokenScope}`\n\t\t}\n\n\t\treturn tokenInfo.token\n\t}\n\n\t/** Create a permanent access token to authenticate to Prismic public apis. */\n\tasync createPermanentAccessToken(): Promise<string> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst token = await this.authApiClient.getMachine2MachineToken(this.name)\n\n\t\tprofiler.done({\n\t\t\tmessage: `machine2machine token created`,\n\t\t})\n\n\t\treturn token\n\t}\n\n\t/**\n\t * Toggle the Role per Locale workflow\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleRolePerLocal(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.toggleRolePerLocal({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t})\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Role per local for ${this.name}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Role per local ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t})\n\t}\n\n\t/**\n\t * Toggle the Custom Roles workflow\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleCustomRoles(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.toggleCustomRoles({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t})\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Custom Roles for ${this.name}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Custom Roles ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t})\n\t}\n\n\t/**\n\t * Toggle the Integration Fields feature\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleIntegrationFields(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.toggleIntegrationFields({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t})\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Integration Fields for ${this.name}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Integration Fields ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t})\n\t}\n\n\t/**\n\t * Change the Repository Plan\n\t *\n\t * @param {string} newPlanId - The Id of the new Plan to apply\n\t */\n\tasync changePlan(newPlanId: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.changePlan({\n\t\t\trepository: this.name,\n\t\t\tnewPlanId: newPlanId,\n\t\t\tbypassManualBilling: true, // For now the library does not support Stripe features\n\t\t})\n\n\t\tthis.failIfNot200(response, \"Could not change the Repository Plan\")\n\t\tprofiler.done({\n\t\t\tmessage: `Repository Plan changed to ${newPlanId}`,\n\t\t})\n\t}\n\n\t/**\n\t * Add a new user to the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync addUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.addUserToRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t})\n\n\t\tconst { data, status } = response\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 409 && JSON.stringify(data).includes(\"already a member of the repo\"))\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response)\n\t\t\tthrow new Error(`Could not add a new user ${email} to the repository`)\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was added to the repository`,\n\t\t})\n\t}\n\n\t/**\n\t * Remove a user from the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync removeUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.removeUserFromRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t})\n\n\t\tthis.failIfNot200(response, `Could not remove the user ${email} from the repository`)\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was removed from the repository`,\n\t\t})\n\t}\n\n\t/**\n\t * Update the role of a user in a repository\n\t *\n\t * @param {string} email - The email of the user\n\t * @param {string | Record<string, string>} role - The new Role of the user, either a string for\n\t * basic workflow or an object such as `{ \"lang_id\": \"Writer\" }`\n\t *\n\t * Example of roles are\n\t *\n\t * - Administrator\n\t * - Writer\n\t * - Contributor\n\t * - Manager (publisher)\n\t */\n\tasync updateUserRole(email: string, role: string | Record<string, string>): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response =\n\t\t\ttypeof role === \"string\"\n\t\t\t\t? await this.wroomClient.updateRole(this.name, email, role)\n\t\t\t\t: await this.wroomClient.updateRolePerLocal(this.name, email, role)\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not update the ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} of the user ${email}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Updated User's ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} for user ${email}`,\n\t\t})\n\t}\n\n\t/**\n\t * Creates a document using the core api. If the Core api format is too specific, use the\n\t * migration api client to create a document with the MigrationApiClient. See the\n\t * `getMigrationApiClient()` method.\n\t *\n\t * @example\n\t * \tTo create a document by converting it from the Page Builder to\n\t * \tCore api format\n\t *\n\t * \t```js\n\t * \timport { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';\n\t *\n\t * \tconst document = {\n\t * \ttitle: 'A new document',\n\t * \tcustom_type_id: 'home-page',\n\t * \tlocale: 'en-gb',\n\t * \tintegration_field_ids: [],\n\t * \ttags: [],\n\t * \tdata: DocumentLegacy.encode({\n\t * \tuid: {\n\t * \t__TYPE__: UIDContentType,\n\t * \tvalue: 'home-page',\n\t * \t},\n\t * \t})\n\t * \t}\n\t * \tawait repository.createDocument(document, 'published');\n\t * \t* ```\n\t * \t```\n\t *\n\t * \t@returns\n\t *\n\t * \t@param document - in the core api format.\n\t *\n\t * \t@param status - status of the document, if published, the function will\n\t * \twait for a new content api master ref to be created\n\t */\n\tasync createDocument(\n\t\tdocument: CoreApiDocumentCreationPayload,\n\t\tstatus: \"draft\" | \"published\",\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst profiler = logger.startTimer()\n\t\tconst result = await this.coreApiClient.createDraft(document)\n\n\t\tlet message = `Document created with id '${result.id}'`\n\t\tif (status === \"published\") {\n\t\t\tconst contentApi = this.getContentApiClient()\n\t\t\tconst masterRef = await contentApi.getMasterRef()\n\t\t\tawait this.coreApiClient.publishDraft(result.id)\n\t\t\tawait this.waitForNewMasterRef(contentApi, masterRef)\n\t\t\tmessage += \", status 'published' and new master ref available\"\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage,\n\t\t})\n\n\t\treturn result\n\t}\n\n\t/**\n\t * Updates an existing document using the core api by creating a new draft version on top of the\n\t * given base version. If the status is published, the function will, unless disabled, wait for a\n\t * new content api master ref to be created.\n\t *\n\t * @param documentId - The id of the document to update.\n\t * @param data - The new version payload in the core api format.\n\t * @param baseVersionId - The id of the version the draft is created from.\n\t * @param status - Status of the new version, if published, the function will wait for a new\n\t * content api master ref to be created.\n\t * @param options - Additional options.\n\t * @param options.skipMasterRefWait - When publishing, skip waiting for a new content api master\n\t * ref to be available (default false). Set to true to return without waiting for the\n\t * projection.\n\t * @returns The updated document, including the new version's id. When publishing, the document is\n\t * retrieved again after publication so that the returned versions reflect the published state.\n\t */\n\tasync updateDocument(\n\t\tdocumentId: string,\n\t\tdata: CoreApiDocumentUpdatePayload,\n\t\tbaseVersionId: string,\n\t\tstatus: \"draft\" | \"published\",\n\t\toptions: { skipMasterRefWait?: boolean } = {},\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst { skipMasterRefWait = false } = options\n\t\tconst profiler = logger.startTimer()\n\t\tconst draft = await this.coreApiClient.updateDraft(documentId, data, baseVersionId)\n\n\t\tif (status === \"draft\") {\n\t\t\tprofiler.done({ message: `Document '${documentId}' updated` })\n\n\t\t\treturn draft\n\t\t}\n\n\t\tlet message = `Document '${documentId}' updated, status 'published'`\n\t\tif (skipMasterRefWait) {\n\t\t\tawait this.coreApiClient.publishDraft(documentId)\n\t\t} else {\n\t\t\tconst contentApi = this.getContentApiClient()\n\t\t\tconst masterRef = await contentApi.getMasterRef()\n\t\t\tawait this.coreApiClient.publishDraft(documentId)\n\t\t\tawait this.waitForNewMasterRef(contentApi, masterRef)\n\t\t\tmessage += \" and new master ref available\"\n\t\t}\n\n\t\tconst { results } = await this.coreApiClient.getDocuments({\n\t\t\tdocumentIds: [documentId],\n\t\t\tlimit: 1,\n\t\t})\n\t\tconst publishedDocument = results[0]\n\t\tif (!publishedDocument) {\n\t\t\tthrow new Error(`Could not retrieve document '${documentId}' after publication`)\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage,\n\t\t})\n\n\t\treturn publishedDocument\n\t}\n\n\t/**\n\t * Unpublishes (archives) a live document using the core api. Unless disabled, waits for a new\n\t * content api master ref to be available.\n\t *\n\t * @param documentId - The id of the document to unpublish.\n\t * @param options - Additional options.\n\t * @param options.skipMasterRefWait - Skip waiting for a new content api master ref to be\n\t * available (default false). Set to true to return without waiting for the projection.\n\t */\n\tasync unpublishDocument(\n\t\tdocumentId: string,\n\t\toptions: { skipMasterRefWait?: boolean } = {},\n\t): Promise<void> {\n\t\tconst { skipMasterRefWait = false } = options\n\t\tconst profiler = logger.startTimer()\n\n\t\tif (skipMasterRefWait) {\n\t\t\tawait this.coreApiClient.unpublishDocument(documentId)\n\t\t\tprofiler.done({ message: `Document '${documentId}' unpublished` })\n\n\t\t\treturn\n\t\t}\n\n\t\tconst contentApi = this.getContentApiClient()\n\t\tconst masterRef = await contentApi.getMasterRef()\n\t\tawait this.coreApiClient.unpublishDocument(documentId)\n\t\tawait this.waitForNewMasterRef(contentApi, masterRef)\n\n\t\tprofiler.done({\n\t\t\tmessage: `Document '${documentId}' unpublished and new master ref available`,\n\t\t})\n\t}\n\n\t/**\n\t * Retrieves data for a specific document version.\n\t *\n\t * @param versionId - The document's version ID.\n\t * @returns The document's version data.\n\t */\n\tasync getDocumentData(versionId: string): Promise<CoreApiDocumentData> {\n\t\treturn await this.coreApiClient.getDocumentData(versionId)\n\t}\n\n\tasync setupIntegrationFields(integrationFields: IntegrationFieldConfig[]): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tif (!this.integrationFieldsClient) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Integration Fields client not found. Did you provide a integration fields api url in the configuration?\",\n\t\t\t)\n\t\t}\n\n\t\tawait this.integrationFieldsClient.setupIntegrationFields(integrationFields)\n\t\tprofiler.done({\n\t\t\tmessage: `Integration Fields setup`,\n\t\t})\n\t}\n\n\tprivate async waitForNewMasterRef(\n\t\tcontentApi: ContentApiClient,\n\t\tpreviousMasterRef: string,\n\t): Promise<void> {\n\t\tawait expect\n\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\ttimeout: 10_000,\n\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t})\n\t\t\t.not.toBe(previousMasterRef)\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale\n\tlocales?: string[]\n\tdefaultLocale?: string\n\tslices?: SharedSliceModel[]\n\tcustomTypes?: DynamicCustomTypeModel[]\n\tpreview?: Preview\n\tsimulatorURL?: string\n\trolePerLocal?: boolean\n\tcustomRoles?: boolean\n\tintegrationFields?: IntegrationFieldConfig[]\n}\n\nexport type Preview = {\n\tname: string\n\twebsiteURL: string\n\tresolverPath: string\n}\n\nexport type CustomLocale = {\n\tlang: {\n\t\tlabel: string\n\t\tid: string\n\t\tuseStandardAnalyzer?: boolean\n\t}\n\tregion: {\n\t\tlabel: string\n\t\tid: string\n\t}\n}\n"],"mappings":";;;;;;AA2BA,IAAa,oBAAb,MAA+B;CAEpB;CACQ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CATlB,YACC,MACA,eACA,eACA,aACA,sBACA,oBACA,gBACA,gBACA,yBACC;EATQ,KAAA,OAAA;EACQ,KAAA,gBAAA;EACA,KAAA,gBAAA;EACA,KAAA,cAAA;EACA,KAAA,uBAAA;EACA,KAAA,qBAAA;EACA,KAAA,iBAAA;EACA,KAAA,iBAAA;EACA,KAAA,0BAAA;CACf;CAEH,MAAM,UAAU,QAAyC;EAExD,IADsB,OAAO,iBAAiB,OAAO,WAAW,OAAO,cACpD;GAClB,MAAM,YAAY,MAAM,KAAK,cAAc,aAAa;GACxD,IAAI,8BAA8B;GAElC,IAAI,OAAO,eAAe;IACzB,MAAM,SAAS,UAAU,MAAM,EAAE,gBAAg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K,iBAAiB;CAC7B;AACD"}
@@ -0,0 +1,341 @@
1
+ import { IntegrationFieldConfig } from "../types.cjs";
2
+ import { AssetApiClient } from "../clients/assetApi.cjs";
3
+ import { AuthenticationApiClient } from "../clients/authenticationApi.cjs";
4
+ import { ContentApiClient } from "../clients/contentApi.cjs";
5
+ import { CoreApiClient, CoreApiDocumentCreationPayload, CoreApiDocumentCreationResponse, CoreApiDocumentData, CoreApiDocumentUpdatePayload, CoreApiDocumentsPayload, CoreApiDocumentsResponse, Release } from "../clients/coreApi.cjs";
6
+ import { CustomTypesApiClient } from "../clients/customTypesApi.cjs";
7
+ import { WroomClient } from "../clients/wroom.cjs";
8
+ import { IntegrationFieldsClient } from "../clients/integrationFields.cjs";
9
+ import { ManageV2Client } from "../clients/manageV2.cjs";
10
+ import { MigrationApiClient } from "../clients/migrationApi.cjs";
11
+ import { DynamicCustomTypeModel, SharedSliceModel } from "@prismicio/types-internal";
12
+
13
+ //#region src/managers/repository.d.ts
14
+ /** Utility to manage test data for a Prismic repository */
15
+ declare class RepositoryManager {
16
+ readonly name: string;
17
+ private readonly coreApiClient;
18
+ private readonly authApiClient;
19
+ private readonly wroomClient;
20
+ private readonly customTypesApiClient;
21
+ private readonly migrationApiClient;
22
+ private readonly assetApiClient;
23
+ private readonly manageV2Client;
24
+ private readonly integrationFieldsClient;
25
+ constructor(name: string, coreApiClient: CoreApiClient, authApiClient: AuthenticationApiClient, wroomClient: WroomClient, customTypesApiClient: CustomTypesApiClient, migrationApiClient: MigrationApiClient | undefined, assetApiClient: AssetApiClient, manageV2Client: ManageV2Client, integrationFieldsClient: IntegrationFieldsClient | undefined);
26
+ configure(config: RepositoryConfig): Promise<void>;
27
+ /** @returns The repository base url, like https://my-repo.prismic.io */
28
+ getBaseURL(): string;
29
+ /** @returns The repository base cdn url, like https://my-repo.cdn.prismic.io */
30
+ getBaseCdnURL(): string;
31
+ /**
32
+ * @returns A Content Type api client configured to target the repository CDN url. Uses Playwright
33
+ * for requests so if your project uses Playwright too, any network request will be present in
34
+ * Playwright test reports.
35
+ */
36
+ getContentApiClient(config?: {
37
+ version?: "v1" | "v2";
38
+ accessToken?: string;
39
+ }): ContentApiClient;
40
+ /**
41
+ * @returns An instance of the Migration api client, see
42
+ * https://prismic.io/docs/migration-api-technical-reference
43
+ */
44
+ getMigrationApiClient(): MigrationApiClient;
45
+ /**
46
+ * @returns An instance of the Asset api client, see
47
+ * https://prismic.io/docs/asset-api-technical-reference
48
+ */
49
+ getAssetApiClient(): AssetApiClient;
50
+ /** @returns The Wroom commit hash deployed on the current repository */
51
+ getDeployedVersion(): Promise<string | undefined>;
52
+ /**
53
+ * Set additional standard locales for a repository in Wroom, does not fail if the locales already
54
+ * exist.
55
+ *
56
+ * @param locales - An array of all locales to be added to the repository.
57
+ * @throws Error if setting the locales fails.
58
+ */
59
+ createLocales(locales: string[]): Promise<void>;
60
+ /**
61
+ * Set additional custom locale for a repository in Wroom, does not fail if the locales already
62
+ * exist.
63
+ *
64
+ * @param locale - The locale to be added to the repository.
65
+ * @throws Error if setting the locale fails.
66
+ */
67
+ createCustomLocale(locale: CustomLocale): Promise<void>;
68
+ private failIfNot200;
69
+ /**
70
+ * Delete a locale from a repository.
71
+ *
72
+ * @param locale - Locale to remove from the repository configuration.
73
+ * @throws Error if deleting the locale fails.
74
+ */
75
+ deleteLocale(locale: string): Promise<void>;
76
+ /**
77
+ * Create or update the default (master) locale for a repository in Wroom, the locale needs to
78
+ * exist in the repository.
79
+ *
80
+ * @param locale - The locale to be set as the default.
81
+ * @param endpoint - "createMasterLang" to create it, "defineAsMaster" to update it.
82
+ * @throws Error if setting the default locale fails.
83
+ */
84
+ setDefaultLocale(locale: string, action: "create" | "update"): Promise<void>;
85
+ /**
86
+ * Retrieves documents.
87
+ *
88
+ * @param args - Configure which documents are retrieved.
89
+ * @returns A paginated set of documents.
90
+ */
91
+ getDocuments(args: CoreApiDocumentsPayload): Promise<CoreApiDocumentsResponse>;
92
+ /**
93
+ * Creates a release.
94
+ *
95
+ * @param label - The label for the release.
96
+ * @returns A Promise that resolves when the release is created.
97
+ */
98
+ createRelease(label: string): Promise<{
99
+ id: string;
100
+ }>;
101
+ /**
102
+ * Retrieves the migration release.
103
+ *
104
+ * @returns The migration relese metadata.
105
+ */
106
+ getMigrationRelease(): Promise<Release>;
107
+ /**
108
+ * Publishes a release.
109
+ *
110
+ * @param id - The ID of the release.
111
+ * @returns A Promise that resolves when the release is published and a new master ref is
112
+ * available.
113
+ */
114
+ publishRelease(id: string): Promise<void>;
115
+ /**
116
+ * Deletes a repository release.
117
+ *
118
+ * @param id - The ID of the release to be deleted.
119
+ */
120
+ deleteRelease(id: string): Promise<void>;
121
+ /**
122
+ * Creates a preview for a repository.
123
+ *
124
+ * @param data - The data for creating the preview.
125
+ */
126
+ createPreview(data: Preview): Promise<void>;
127
+ /**
128
+ * Set the simulator URL (table of slices) for a repository.
129
+ *
130
+ * @param data - The simulator URL to set.
131
+ */
132
+ setSimulatorURL(simulatorURL: string): Promise<void>;
133
+ /**
134
+ * Deletes a preview from a repository.
135
+ *
136
+ * @param id - The ID of the preview to be deleted.
137
+ */
138
+ deletePreview(id: string): Promise<void>;
139
+ /**
140
+ * Create a webhook.
141
+ *
142
+ * @returns A Promise that resolves with the webhook id.
143
+ */
144
+ createWebhook(name: string, url: string, secret: string, triggers: {
145
+ documentsPublished?: boolean;
146
+ documentsUnpublished?: boolean;
147
+ releasesCreated?: boolean;
148
+ releasesUpdated?: boolean;
149
+ tagsCreated?: boolean;
150
+ tagsDeleted?: boolean;
151
+ }, active: boolean): Promise<string>;
152
+ /**
153
+ * Deletes a webhook.
154
+ *
155
+ * @param id - The webhook ID.
156
+ */
157
+ deleteWebhook(id: string): Promise<void>;
158
+ /**
159
+ * Create Custom Types using the Custom types api.
160
+ *
161
+ * @param customTypes
162
+ */
163
+ createCustomTypes(customTypes: DynamicCustomTypeModel[]): Promise<void>;
164
+ deleteCustomType(customTypeId: string): Promise<void>;
165
+ /**
166
+ * Create slices using the Custom types api.
167
+ *
168
+ * @param slices
169
+ */
170
+ createSlices(slices: SharedSliceModel[]): Promise<void>;
171
+ /**
172
+ * Create an access token to query private items of the Content api.
173
+ *
174
+ * @param appName - Mandatory authorized application name
175
+ * @param tokenScope - Access token scope. Use "master" to when your content api is fully private
176
+ * or "master+releases" to access private releases
177
+ */
178
+ createContentAPIToken(appName: string, tokenScope?: "master" | "master+releases"): Promise<string>;
179
+ /** Create a permanent access token to authenticate to Prismic public apis. */
180
+ createPermanentAccessToken(): Promise<string>;
181
+ /**
182
+ * Toggle the Role per Locale workflow
183
+ *
184
+ * @param enabled - The feature new status
185
+ */
186
+ toggleRolePerLocal(enabled: boolean): Promise<void>;
187
+ /**
188
+ * Toggle the Custom Roles workflow
189
+ *
190
+ * @param enabled - The feature new status
191
+ */
192
+ toggleCustomRoles(enabled: boolean): Promise<void>;
193
+ /**
194
+ * Toggle the Integration Fields feature
195
+ *
196
+ * @param enabled - The feature new status
197
+ */
198
+ toggleIntegrationFields(enabled: boolean): Promise<void>;
199
+ /**
200
+ * Change the Repository Plan
201
+ *
202
+ * @param {string} newPlanId - The Id of the new Plan to apply
203
+ */
204
+ changePlan(newPlanId: string): Promise<void>;
205
+ /**
206
+ * Add a new user to the repository
207
+ *
208
+ * @param {string} email - The email of the user
209
+ */
210
+ addUser(email: string): Promise<void>;
211
+ /**
212
+ * Remove a user from the repository
213
+ *
214
+ * @param {string} email - The email of the user
215
+ */
216
+ removeUser(email: string): Promise<void>;
217
+ /**
218
+ * Update the role of a user in a repository
219
+ *
220
+ * @param {string} email - The email of the user
221
+ * @param {string | Record<string, string>} role - The new Role of the user, either a string for
222
+ * basic workflow or an object such as `{ "lang_id": "Writer" }`
223
+ *
224
+ * Example of roles are
225
+ *
226
+ * - Administrator
227
+ * - Writer
228
+ * - Contributor
229
+ * - Manager (publisher)
230
+ */
231
+ updateUserRole(email: string, role: string | Record<string, string>): Promise<void>;
232
+ /**
233
+ * Creates a document using the core api. If the Core api format is too specific, use the
234
+ * migration api client to create a document with the MigrationApiClient. See the
235
+ * `getMigrationApiClient()` method.
236
+ *
237
+ * @example
238
+ * To create a document by converting it from the Page Builder to
239
+ * Core api format
240
+ *
241
+ * ```js
242
+ * import { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';
243
+ *
244
+ * const document = {
245
+ * title: 'A new document',
246
+ * custom_type_id: 'home-page',
247
+ * locale: 'en-gb',
248
+ * integration_field_ids: [],
249
+ * tags: [],
250
+ * data: DocumentLegacy.encode({
251
+ * uid: {
252
+ * __TYPE__: UIDContentType,
253
+ * value: 'home-page',
254
+ * },
255
+ * })
256
+ * }
257
+ * await repository.createDocument(document, 'published');
258
+ * * ```
259
+ * ```
260
+ *
261
+ * @returns
262
+ *
263
+ * @param document - in the core api format.
264
+ *
265
+ * @param status - status of the document, if published, the function will
266
+ * wait for a new content api master ref to be created
267
+ */
268
+ createDocument(document: CoreApiDocumentCreationPayload, status: "draft" | "published"): Promise<CoreApiDocumentCreationResponse>;
269
+ /**
270
+ * Updates an existing document using the core api by creating a new draft version on top of the
271
+ * given base version. If the status is published, the function will, unless disabled, wait for a
272
+ * new content api master ref to be created.
273
+ *
274
+ * @param documentId - The id of the document to update.
275
+ * @param data - The new version payload in the core api format.
276
+ * @param baseVersionId - The id of the version the draft is created from.
277
+ * @param status - Status of the new version, if published, the function will wait for a new
278
+ * content api master ref to be created.
279
+ * @param options - Additional options.
280
+ * @param options.skipMasterRefWait - When publishing, skip waiting for a new content api master
281
+ * ref to be available (default false). Set to true to return without waiting for the
282
+ * projection.
283
+ * @returns The updated document, including the new version's id. When publishing, the document is
284
+ * retrieved again after publication so that the returned versions reflect the published state.
285
+ */
286
+ updateDocument(documentId: string, data: CoreApiDocumentUpdatePayload, baseVersionId: string, status: "draft" | "published", options?: {
287
+ skipMasterRefWait?: boolean;
288
+ }): Promise<CoreApiDocumentCreationResponse>;
289
+ /**
290
+ * Unpublishes (archives) a live document using the core api. Unless disabled, waits for a new
291
+ * content api master ref to be available.
292
+ *
293
+ * @param documentId - The id of the document to unpublish.
294
+ * @param options - Additional options.
295
+ * @param options.skipMasterRefWait - Skip waiting for a new content api master ref to be
296
+ * available (default false). Set to true to return without waiting for the projection.
297
+ */
298
+ unpublishDocument(documentId: string, options?: {
299
+ skipMasterRefWait?: boolean;
300
+ }): Promise<void>;
301
+ /**
302
+ * Retrieves data for a specific document version.
303
+ *
304
+ * @param versionId - The document's version ID.
305
+ * @returns The document's version data.
306
+ */
307
+ getDocumentData(versionId: string): Promise<CoreApiDocumentData>;
308
+ setupIntegrationFields(integrationFields: IntegrationFieldConfig[]): Promise<void>;
309
+ private waitForNewMasterRef;
310
+ }
311
+ type RepositoryConfig = {
312
+ customLocale?: CustomLocale;
313
+ locales?: string[];
314
+ defaultLocale?: string;
315
+ slices?: SharedSliceModel[];
316
+ customTypes?: DynamicCustomTypeModel[];
317
+ preview?: Preview;
318
+ simulatorURL?: string;
319
+ rolePerLocal?: boolean;
320
+ customRoles?: boolean;
321
+ integrationFields?: IntegrationFieldConfig[];
322
+ };
323
+ type Preview = {
324
+ name: string;
325
+ websiteURL: string;
326
+ resolverPath: string;
327
+ };
328
+ type CustomLocale = {
329
+ lang: {
330
+ label: string;
331
+ id: string;
332
+ useStandardAnalyzer?: boolean;
333
+ };
334
+ region: {
335
+ label: string;
336
+ id: string;
337
+ };
338
+ };
339
+ //#endregion
340
+ export { CustomLocale, Preview, RepositoryConfig, RepositoryManager };
341
+ //# sourceMappingURL=repository.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.d.cts","names":[],"sources":["../../src/managers/repository.ts"],"mappings":";;;;;;;;;;;;;;cA2Ba,iBAAA;EAAA,SAEF,IAAA;EAAA,iBACQ,aAAA;EAAA,iBACA,aAAA;EAAA,iBACA,WAAA;EAAA,iBACA,oBAAA;EAAA,iBACA,kBAAA;EAAA,iBACA,cAAA;EAAA,iBACA,cAAA;EAAA,iBACA,uBAAA;cARR,IAAA,UACQ,aAAA,EAAe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