@prismicio/e2e-tests-utils 1.19.0-pr.37.6283e4a → 1.20.0-pr.39.f7fb7be
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clients/coreApi.cjs.map +1 -1
- package/dist/clients/coreApi.d.cts +1 -0
- package/dist/clients/coreApi.d.cts.map +1 -1
- package/dist/clients/coreApi.d.ts +1 -0
- package/dist/clients/coreApi.d.ts.map +1 -1
- package/dist/clients/coreApi.js.map +1 -1
- package/dist/managers/repository.cjs +36 -32
- package/dist/managers/repository.cjs.map +1 -1
- package/dist/managers/repository.d.cts +10 -7
- package/dist/managers/repository.d.cts.map +1 -1
- package/dist/managers/repository.d.ts +10 -7
- package/dist/managers/repository.d.ts.map +1 -1
- package/dist/managers/repository.js +36 -32
- package/dist/managers/repository.js.map +1 -1
- package/package.json +1 -1
- package/src/clients/coreApi.ts +1 -0
- package/src/managers/repository.ts +54 -47
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreApi.cjs","names":["AuthenticatedApiClient","logger","logPlaywrightApiResponse"],"sources":["../../src/clients/coreApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse, logger } from \"../utils/log\"\nimport type { AuthServerToken } from \"./apiClient\"\nimport { AuthenticatedApiClient } from \"./apiClient\"\n\ntype Language = {\n\tid: string\n\tname: string\n\tis_master: boolean\n}\n\nexport type Release = {\n\tid: string\n\tlabel: string\n\tmigration: boolean\n}\n\nexport type CoreApiDocumentCreationPayload = {\n\ttitle: string\n\tlocale?: string\n\tgroup_lang_id?: string\n\trelease_id?: string\n\tintegration_field_ids: string[]\n\tdata: Record<string, unknown>\n\tcustom_type_id: string\n\ttags: string[]\n}\n\nexport type CoreApiDocumentUpdatePayload = {\n\tdata: Record<string, unknown>\n\tintegration_field_ids: string[]\n\ttags: string[]\n}\n\nexport type CoreApiRepository = Record<string, unknown> & {\n\tsimulator_url?: string\n}\n\nexport type CoreApiDocumentCreationResponse = {\n\tid: string\n\tgroup_lang_id: string\n\tcustom_type_id: string\n\tlocale: string\n\tlanguage: { id: string; name: string }\n\tfirst_publication_date: number | null\n\tlast_publication_date: number | null\n\ttitle: string\n\tversions: {\n\t\tstatus: string\n\t\tversion_id: string\n\t\tauthor: {\n\t\t\tid: string\n\t\t\tfirst_name: string | null\n\t\t\tlast_name: string | null\n\t\t\temail: string\n\t\t}\n\t\trelease_id: string | null\n\t\tlast_modified_date: number\n\t\ttags: string[]\n\t\tcustom_type_label: string\n\t\tpreview_summary?: string\n\t\tpreview_image?: string\n\t\tuid?: string\n\t}[]\n}\n\nexport type CoreApiDocumentsPayload = {\n\tlanguage?: string\n\tlimit?: number\n\tstatuses?: string[]\n\tgroupLangIds?: string[]\n}\n\nexport type CoreApiDocumentsResponse = {\n\ttotal: number\n\tcursor: string\n\tresults: CoreApiDocumentCreationResponse[]\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type CoreApiDocumentData = Record<string, any>\n\nexport class CoreApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example\n\t * \tTo instantiate the class:\n\t *\n\t * \t```js\n\t * \tnew CoreApiClient(\"https://my-repo.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \t});\n\t * \t```\n\t *\n\t * @param baseURL - The api base URL like https://my-repo.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.authToken}: Api token generated from the auth service or a function to fetch it\n\t * when it's needed.\n\t */\n\tconstructor(baseURL: string, config: AuthServerToken) {\n\t\tsuper(baseURL, config)\n\t}\n\n\tasync getLanguages(): Promise<Language[]> {\n\t\tconst profiler = logger.startTimer()\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(\"core/repository\")\n\n\t\tif (200 !== result.status() || !(await result.json()).languages) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not get languages from the core api.\")\n\t\t}\n\n\t\tprofiler.done({ message: \"retrieved languages configuration\" })\n\n\t\treturn (await result.json()).languages\n\t}\n\n\t/**\n\t * Retrieves all releases, including the migration release.\n\t *\n\t * @returns An array of release metadata.\n\t */\n\tasync getReleases(): Promise<Release[]> {\n\t\tconst profiler = logger.startTimer()\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(\"core/releases\", {\n\t\t\tparams: { include_migration_releases: true },\n\t\t})\n\n\t\tif (200 !== result.status() || !(await result.json()).results) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not get releases from the core api.\")\n\t\t}\n\n\t\tprofiler.done({ message: \"retrieved releases\" })\n\n\t\treturn (await result.json()).results\n\t}\n\n\tasync createDraft(\n\t\tdata: CoreApiDocumentCreationPayload,\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(\"core/documents\", {\n\t\t\tdata,\n\t\t})\n\n\t\tif (201 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not create draft document\")\n\t\t}\n\n\t\treturn result.json()\n\t}\n\n\t/**\n\t * Creates a new draft version of an existing document, on top of the given base version.\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 * @returns The updated document, including the new version's id.\n\t */\n\tasync updateDraft(\n\t\tdocumentId: string,\n\t\tdata: CoreApiDocumentUpdatePayload,\n\t\tbaseVersionId: string,\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.put(`core/documents/${documentId}/draft`, {\n\t\t\tparams: { base_version_id: baseVersionId },\n\t\t\tdata,\n\t\t})\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not update draft for document with id ${documentId}`)\n\t\t}\n\n\t\treturn result.json()\n\t}\n\n\tasync publishDraft(documentId: string): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.patch(`core/documents/${documentId}/draft`, {\n\t\t\tdata: {\n\t\t\t\tstatus: \"published\",\n\t\t\t},\n\t\t})\n\n\t\tif (204 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not publish document with id ${documentId}`)\n\t\t}\n\t}\n\n\t/**\n\t * Unpublishes (archives) a live document.\n\t *\n\t * @param documentId - The id of the document to unpublish.\n\t */\n\tasync unpublishDocument(documentId: string): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.patch(`core/documents/${documentId}/live`, {\n\t\t\tdata: {\n\t\t\t\tstatus: \"archived\",\n\t\t\t},\n\t\t})\n\n\t\tif (204 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not unpublish document with id ${documentId}`)\n\t\t}\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\tconst context = await this.getContext()\n\t\tconst result = await context.post(\"core/documents/search\", {\n\t\t\tdata: args,\n\t\t})\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not search documents\")\n\t\t}\n\n\t\treturn result.json()\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\tconst context = await this.getContext()\n\t\tconst result = await context.get(`core/documents/data/${versionId}`)\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not retrieve document data\")\n\t\t}\n\n\t\treturn result.json()\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.\n\t */\n\tasync publishRelease(id: string): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(`core/releases/${id}/publish`)\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not publish release ${id}\")\n\t\t}\n\t}\n\n\tasync getRepository(): Promise<CoreApiRepository> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(`core/repository`)\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not get repository`)\n\t\t}\n\n\t\treturn result.json()\n\t}\n\n\tasync updateRepository(data: CoreApiRepository): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.patch(`core/repository`, {\n\t\t\tdata,\n\t\t})\n\n\t\tif (204 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not update repository`)\n\t\t}\n\t}\n}\n"],"mappings":";;;AAiFA,IAAa,gBAAb,cAAmCA,kBAAAA,uBAAuB;;;;;;;;;;;;;;;;;CAiBzD,YAAY,SAAiB,QAAyB;EACrD,MAAM,SAAS,MAAM;CACtB;CAEA,MAAM,eAAoC;EACzC,MAAM,WAAWC,YAAAA,OAAO,WAAW;EAEnC,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,IAAI,iBAAiB;EAElD,IAAI,QAAQ,OAAO,OAAO,KAAK,EAAE,MAAM,OAAO,KAAK,EAAA,CAAG,WAAW;GAChE,MAAMC,YAAAA,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,4CAA4C;EAC7D;EAEA,SAAS,KAAK,EAAE,SAAS,oCAAoC,CAAC;EAE9D,QAAQ,MAAM,OAAO,KAAK,EAAA,CAAG;CAC9B;;;;;;CAOA,MAAM,cAAkC;EACvC,MAAM,WAAWD,YAAAA,OAAO,WAAW;EAEnC,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,IAAI,iBAAi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CACT,MAAM,mBAAmB,EACrD,KACD,CAAC;EAED,IAAI,QAAQ,OAAO,OAAO,GAAG;GAC5B,MAAMA,YAAAA,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,6BAA6B;EAC9C;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"coreApi.cjs","names":["AuthenticatedApiClient","logger","logPlaywrightApiResponse"],"sources":["../../src/clients/coreApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse, logger } from \"../utils/log\"\nimport type { AuthServerToken } from \"./apiClient\"\nimport { AuthenticatedApiClient } from \"./apiClient\"\n\ntype Language = {\n\tid: string\n\tname: string\n\tis_master: boolean\n}\n\nexport type Release = {\n\tid: string\n\tlabel: string\n\tmigration: boolean\n}\n\nexport type CoreApiDocumentCreationPayload = {\n\ttitle: string\n\tlocale?: string\n\tgroup_lang_id?: string\n\trelease_id?: string\n\tintegration_field_ids: string[]\n\tdata: Record<string, unknown>\n\tcustom_type_id: string\n\ttags: string[]\n}\n\nexport type CoreApiDocumentUpdatePayload = {\n\tdata: Record<string, unknown>\n\tintegration_field_ids: string[]\n\ttags: string[]\n}\n\nexport type CoreApiRepository = Record<string, unknown> & {\n\tsimulator_url?: string\n}\n\nexport type CoreApiDocumentCreationResponse = {\n\tid: string\n\tgroup_lang_id: string\n\tcustom_type_id: string\n\tlocale: string\n\tlanguage: { id: string; name: string }\n\tfirst_publication_date: number | null\n\tlast_publication_date: number | null\n\ttitle: string\n\tversions: {\n\t\tstatus: string\n\t\tversion_id: string\n\t\tauthor: {\n\t\t\tid: string\n\t\t\tfirst_name: string | null\n\t\t\tlast_name: string | null\n\t\t\temail: string\n\t\t}\n\t\trelease_id: string | null\n\t\tlast_modified_date: number\n\t\ttags: string[]\n\t\tcustom_type_label: string\n\t\tpreview_summary?: string\n\t\tpreview_image?: string\n\t\tuid?: string\n\t}[]\n}\n\nexport type CoreApiDocumentsPayload = {\n\tlanguage?: string\n\tlimit?: number\n\tstatuses?: string[]\n\tgroupLangIds?: string[]\n\tdocumentIds?: string[]\n}\n\nexport type CoreApiDocumentsResponse = {\n\ttotal: number\n\tcursor: string\n\tresults: CoreApiDocumentCreationResponse[]\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type CoreApiDocumentData = Record<string, any>\n\nexport class CoreApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example\n\t * \tTo instantiate the class:\n\t *\n\t * \t```js\n\t * \tnew CoreApiClient(\"https://my-repo.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \t});\n\t * \t```\n\t *\n\t * @param baseURL - The api base URL like https://my-repo.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.authToken}: Api token generated from the auth service or a function to fetch it\n\t * when it's needed.\n\t */\n\tconstructor(baseURL: string, config: AuthServerToken) {\n\t\tsuper(baseURL, config)\n\t}\n\n\tasync getLanguages(): Promise<Language[]> {\n\t\tconst profiler = logger.startTimer()\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(\"core/repository\")\n\n\t\tif (200 !== result.status() || !(await result.json()).languages) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not get languages from the core api.\")\n\t\t}\n\n\t\tprofiler.done({ message: \"retrieved languages configuration\" })\n\n\t\treturn (await result.json()).languages\n\t}\n\n\t/**\n\t * Retrieves all releases, including the migration release.\n\t *\n\t * @returns An array of release metadata.\n\t */\n\tasync getReleases(): Promise<Release[]> {\n\t\tconst profiler = logger.startTimer()\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(\"core/releases\", {\n\t\t\tparams: { include_migration_releases: true },\n\t\t})\n\n\t\tif (200 !== result.status() || !(await result.json()).results) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not get releases from the core api.\")\n\t\t}\n\n\t\tprofiler.done({ message: \"retrieved releases\" })\n\n\t\treturn (await result.json()).results\n\t}\n\n\tasync createDraft(\n\t\tdata: CoreApiDocumentCreationPayload,\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(\"core/documents\", {\n\t\t\tdata,\n\t\t})\n\n\t\tif (201 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not create draft document\")\n\t\t}\n\n\t\treturn result.json()\n\t}\n\n\t/**\n\t * Creates a new draft version of an existing document, on top of the given base version.\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 * @returns The updated document, including the new version's id.\n\t */\n\tasync updateDraft(\n\t\tdocumentId: string,\n\t\tdata: CoreApiDocumentUpdatePayload,\n\t\tbaseVersionId: string,\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.put(`core/documents/${documentId}/draft`, {\n\t\t\tparams: { base_version_id: baseVersionId },\n\t\t\tdata,\n\t\t})\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not update draft for document with id ${documentId}`)\n\t\t}\n\n\t\treturn result.json()\n\t}\n\n\tasync publishDraft(documentId: string): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.patch(`core/documents/${documentId}/draft`, {\n\t\t\tdata: {\n\t\t\t\tstatus: \"published\",\n\t\t\t},\n\t\t})\n\n\t\tif (204 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not publish document with id ${documentId}`)\n\t\t}\n\t}\n\n\t/**\n\t * Unpublishes (archives) a live document.\n\t *\n\t * @param documentId - The id of the document to unpublish.\n\t */\n\tasync unpublishDocument(documentId: string): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.patch(`core/documents/${documentId}/live`, {\n\t\t\tdata: {\n\t\t\t\tstatus: \"archived\",\n\t\t\t},\n\t\t})\n\n\t\tif (204 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not unpublish document with id ${documentId}`)\n\t\t}\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\tconst context = await this.getContext()\n\t\tconst result = await context.post(\"core/documents/search\", {\n\t\t\tdata: args,\n\t\t})\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not search documents\")\n\t\t}\n\n\t\treturn result.json()\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\tconst context = await this.getContext()\n\t\tconst result = await context.get(`core/documents/data/${versionId}`)\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not retrieve document data\")\n\t\t}\n\n\t\treturn result.json()\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.\n\t */\n\tasync publishRelease(id: string): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(`core/releases/${id}/publish`)\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not publish release ${id}\")\n\t\t}\n\t}\n\n\tasync getRepository(): Promise<CoreApiRepository> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(`core/repository`)\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not get repository`)\n\t\t}\n\n\t\treturn result.json()\n\t}\n\n\tasync updateRepository(data: CoreApiRepository): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.patch(`core/repository`, {\n\t\t\tdata,\n\t\t})\n\n\t\tif (204 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not update repository`)\n\t\t}\n\t}\n}\n"],"mappings":";;;AAkFA,IAAa,gBAAb,cAAmCA,kBAAAA,uBAAuB;;;;;;;;;;;;;;;;;CAiBzD,YAAY,SAAiB,QAAyB;EACrD,MAAM,SAAS,MAAM;CACtB;CAEA,MAAM,eAAoC;EACzC,MAAM,WAAWC,YAAAA,OAAO,WAAW;EAEnC,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,IAAI,iBAAiB;EAElD,IAAI,QAAQ,OAAO,OAAO,KAAK,EAAE,MAAM,OAAO,KAAK,EAAA,CAAG,WAAW;GAChE,MAAMC,YAAAA,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,4CAA4C;EAC7D;EAEA,SAAS,KAAK,EAAE,SAAS,oCAAoC,CAAC;EAE9D,QAAQ,MAAM,OAAO,KAAK,EAAA,CAAG;CAC9B;;;;;;CAOA,MAAM,cAAkC;EACvC,MAAM,WAAWD,YAAAA,OAAO,WAAW;EAEnC,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,IAAI,iBAAiB,EACjD,QAAQ,EAAE,4BAA4B,KAAK,EAC5C,CAAC;EAED,IAAI,QAAQ,OAAO,OAAO,KAAK,EAAE,MAAM,OAAO,KAAK,EAAA,CAAG,SAAS;GAC9D,MAAMC,YAAAA,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,2CAA2C;EAC5D;EAEA,SAAS,KAAK,EAAE,SAAS,qBAAqB,CAAC;EAE/C,QAAQ,MAAM,OAAO,KAAK,EAAA,CAAG;CAC9B;CAEA,MAAM,YACL,MAC2C;EAE3C,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,KAAK,kBAAkB,EACnD,KACD,CAAC;EAED,IAAI,QAAQ,OAAO,OAAO,G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;EACA,IAAA,EAAM,MAAM;EACZ,cAAA;EACA,IAAA;AAAA;AAAA,KAGW,4BAAA;EACX,IAAA,EAAM,MAAM;EACZ,qBAAA;EACA,IAAA;AAAA;AAAA,KAGW,iBAAA,GAAoB,MAAM;EACrC,aAAa;AAAA;AAAA,KAGF,+BAAA;EACX,EAAA;EACA,aAAA;EACA,cAAA;EACA,MAAA;EACA,QAAA;IAAY,EAAA;IAAY,IAAA;EAAA;EACxB,sBAAA;EACA,qBAAA;EACA,KAAA;EACA,QAAA;IACC,MAAA;IACA,UAAA;IACA,MAAA;MACC,EAAA;MACA,UAAA;MACA,SAAA;MACA,KAAA;IAAA;IAED,UAAA;IACA,kBAAA;IACA,IAAA;IACA,iBAAA;IACA,eAAA;IACA,aAAA;IACA,GAAA;EAAA;AAAA;AAAA,KAIU,uBAAA;EACX,QAAA;EACA,KAAA;EACA,QAAA;EACA,YAAA;AAAA;AAAA,KAGW,wBAAA;EACX,KAAA;EACA,MAAA;EACA,OAAA,EAAS,+BAA+B;AAAA;AAAA,KAI7B,mBAAA,GAAsB,MAAM;AAAA,cAE3B,aAAA,SAAsB,sBAAA;EA1BjC
|
|
1
|
+
{"version":3,"file":"coreApi.d.cts","names":[],"sources":["../../src/clients/coreApi.ts"],"mappings":";;;KAIK,QAAA;EACJ,EAAA;EACA,IAAA;EACA,SAAA;AAAA;AAAA,KAGW,OAAA;EACX,EAAA;EACA,KAAA;EACA,SAAA;AAAA;AAAA,KAGW,8BAAA;EACX,KAAA;EACA,MAAA;EACA,aAAA;EACA,UAAA;EACA,qBAAA;EACA,IAAA,EAAM,MAAM;EACZ,cAAA;EACA,IAAA;AAAA;AAAA,KAGW,4BAAA;EACX,IAAA,EAAM,MAAM;EACZ,qBAAA;EACA,IAAA;AAAA;AAAA,KAGW,iBAAA,GAAoB,MAAM;EACrC,aAAa;AAAA;AAAA,KAGF,+BAAA;EACX,EAAA;EACA,aAAA;EACA,cAAA;EACA,MAAA;EACA,QAAA;IAAY,EAAA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|
-
{"version":3,"file":"coreApi.d.ts","names":[],"sources":["../../src/clients/coreApi.ts"],"mappings":";;;KAIK,QAAA;EACJ,EAAA;EACA,IAAA;EACA,SAAA;AAAA;AAAA,KAGW,OAAA;EACX,EAAA;EACA,KAAA;EACA,SAAA;AAAA;AAAA,KAGW,8BAAA;EACX,KAAA;EACA,MAAA;EACA,aAAA;EACA,UAAA;EACA,qBAAA;EACA,IAAA,EAAM,MAAM;EACZ,cAAA;EACA,IAAA;AAAA;AAAA,KAGW,4BAAA;EACX,IAAA,EAAM,MAAM;EACZ,qBAAA;EACA,IAAA;AAAA;AAAA,KAGW,iBAAA,GAAoB,MAAM;EACrC,aAAa;AAAA;AAAA,KAGF,+BAAA;EACX,EAAA;EACA,aAAA;EACA,cAAA;EACA,MAAA;EACA,QAAA;IAAY,EAAA;IAAY,IAAA;EAAA;EACxB,sBAAA;EACA,qBAAA;EACA,KAAA;EACA,QAAA;IACC,MAAA;IACA,UAAA;IACA,MAAA;MACC,EAAA;MACA,UAAA;MACA,SAAA;MACA,KAAA;IAAA;IAED,UAAA;IACA,kBAAA;IACA,IAAA;IACA,iBAAA;IACA,eAAA;IACA,aAAA;IACA,GAAA;EAAA;AAAA;AAAA,KAIU,uBAAA;EACX,QAAA;EACA,KAAA;EACA,QAAA;EACA,YAAA;AAAA;AAAA,KAGW,wBAAA;EACX,KAAA;EACA,MAAA;EACA,OAAA,EAAS,+BAA+B;AAAA;AAAA,KAI7B,mBAAA,GAAsB,MAAM;AAAA,cAE3B,aAAA,SAAsB,sBAAA;EA1BjC
|
|
1
|
+
{"version":3,"file":"coreApi.d.ts","names":[],"sources":["../../src/clients/coreApi.ts"],"mappings":";;;KAIK,QAAA;EACJ,EAAA;EACA,IAAA;EACA,SAAA;AAAA;AAAA,KAGW,OAAA;EACX,EAAA;EACA,KAAA;EACA,SAAA;AAAA;AAAA,KAGW,8BAAA;EACX,KAAA;EACA,MAAA;EACA,aAAA;EACA,UAAA;EACA,qBAAA;EACA,IAA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CnB;;;;;;EA2DlC,eAAA,CAAgB,SAAA,WAAoB,OAAA,CAAQ,mBAAA;EAkBhB;;;;;;EAA5B,cAAA,CAAe,EAAA,WAAa,OAAA;EAU5B,aAAA,IAAiB,OAAA,CAAQ,iBAAA;EAYzB,gBAAA,CAAiB,IAAA,EAAM,iBAAA,GAAoB,OAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreApi.js","names":[],"sources":["../../src/clients/coreApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse, logger } from \"../utils/log\"\nimport type { AuthServerToken } from \"./apiClient\"\nimport { AuthenticatedApiClient } from \"./apiClient\"\n\ntype Language = {\n\tid: string\n\tname: string\n\tis_master: boolean\n}\n\nexport type Release = {\n\tid: string\n\tlabel: string\n\tmigration: boolean\n}\n\nexport type CoreApiDocumentCreationPayload = {\n\ttitle: string\n\tlocale?: string\n\tgroup_lang_id?: string\n\trelease_id?: string\n\tintegration_field_ids: string[]\n\tdata: Record<string, unknown>\n\tcustom_type_id: string\n\ttags: string[]\n}\n\nexport type CoreApiDocumentUpdatePayload = {\n\tdata: Record<string, unknown>\n\tintegration_field_ids: string[]\n\ttags: string[]\n}\n\nexport type CoreApiRepository = Record<string, unknown> & {\n\tsimulator_url?: string\n}\n\nexport type CoreApiDocumentCreationResponse = {\n\tid: string\n\tgroup_lang_id: string\n\tcustom_type_id: string\n\tlocale: string\n\tlanguage: { id: string; name: string }\n\tfirst_publication_date: number | null\n\tlast_publication_date: number | null\n\ttitle: string\n\tversions: {\n\t\tstatus: string\n\t\tversion_id: string\n\t\tauthor: {\n\t\t\tid: string\n\t\t\tfirst_name: string | null\n\t\t\tlast_name: string | null\n\t\t\temail: string\n\t\t}\n\t\trelease_id: string | null\n\t\tlast_modified_date: number\n\t\ttags: string[]\n\t\tcustom_type_label: string\n\t\tpreview_summary?: string\n\t\tpreview_image?: string\n\t\tuid?: string\n\t}[]\n}\n\nexport type CoreApiDocumentsPayload = {\n\tlanguage?: string\n\tlimit?: number\n\tstatuses?: string[]\n\tgroupLangIds?: string[]\n}\n\nexport type CoreApiDocumentsResponse = {\n\ttotal: number\n\tcursor: string\n\tresults: CoreApiDocumentCreationResponse[]\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type CoreApiDocumentData = Record<string, any>\n\nexport class CoreApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example\n\t * \tTo instantiate the class:\n\t *\n\t * \t```js\n\t * \tnew CoreApiClient(\"https://my-repo.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \t});\n\t * \t```\n\t *\n\t * @param baseURL - The api base URL like https://my-repo.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.authToken}: Api token generated from the auth service or a function to fetch it\n\t * when it's needed.\n\t */\n\tconstructor(baseURL: string, config: AuthServerToken) {\n\t\tsuper(baseURL, config)\n\t}\n\n\tasync getLanguages(): Promise<Language[]> {\n\t\tconst profiler = logger.startTimer()\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(\"core/repository\")\n\n\t\tif (200 !== result.status() || !(await result.json()).languages) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not get languages from the core api.\")\n\t\t}\n\n\t\tprofiler.done({ message: \"retrieved languages configuration\" })\n\n\t\treturn (await result.json()).languages\n\t}\n\n\t/**\n\t * Retrieves all releases, including the migration release.\n\t *\n\t * @returns An array of release metadata.\n\t */\n\tasync getReleases(): Promise<Release[]> {\n\t\tconst profiler = logger.startTimer()\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(\"core/releases\", {\n\t\t\tparams: { include_migration_releases: true },\n\t\t})\n\n\t\tif (200 !== result.status() || !(await result.json()).results) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not get releases from the core api.\")\n\t\t}\n\n\t\tprofiler.done({ message: \"retrieved releases\" })\n\n\t\treturn (await result.json()).results\n\t}\n\n\tasync createDraft(\n\t\tdata: CoreApiDocumentCreationPayload,\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(\"core/documents\", {\n\t\t\tdata,\n\t\t})\n\n\t\tif (201 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not create draft document\")\n\t\t}\n\n\t\treturn result.json()\n\t}\n\n\t/**\n\t * Creates a new draft version of an existing document, on top of the given base version.\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 * @returns The updated document, including the new version's id.\n\t */\n\tasync updateDraft(\n\t\tdocumentId: string,\n\t\tdata: CoreApiDocumentUpdatePayload,\n\t\tbaseVersionId: string,\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.put(`core/documents/${documentId}/draft`, {\n\t\t\tparams: { base_version_id: baseVersionId },\n\t\t\tdata,\n\t\t})\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not update draft for document with id ${documentId}`)\n\t\t}\n\n\t\treturn result.json()\n\t}\n\n\tasync publishDraft(documentId: string): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.patch(`core/documents/${documentId}/draft`, {\n\t\t\tdata: {\n\t\t\t\tstatus: \"published\",\n\t\t\t},\n\t\t})\n\n\t\tif (204 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not publish document with id ${documentId}`)\n\t\t}\n\t}\n\n\t/**\n\t * Unpublishes (archives) a live document.\n\t *\n\t * @param documentId - The id of the document to unpublish.\n\t */\n\tasync unpublishDocument(documentId: string): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.patch(`core/documents/${documentId}/live`, {\n\t\t\tdata: {\n\t\t\t\tstatus: \"archived\",\n\t\t\t},\n\t\t})\n\n\t\tif (204 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not unpublish document with id ${documentId}`)\n\t\t}\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\tconst context = await this.getContext()\n\t\tconst result = await context.post(\"core/documents/search\", {\n\t\t\tdata: args,\n\t\t})\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not search documents\")\n\t\t}\n\n\t\treturn result.json()\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\tconst context = await this.getContext()\n\t\tconst result = await context.get(`core/documents/data/${versionId}`)\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not retrieve document data\")\n\t\t}\n\n\t\treturn result.json()\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.\n\t */\n\tasync publishRelease(id: string): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(`core/releases/${id}/publish`)\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not publish release ${id}\")\n\t\t}\n\t}\n\n\tasync getRepository(): Promise<CoreApiRepository> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(`core/repository`)\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not get repository`)\n\t\t}\n\n\t\treturn result.json()\n\t}\n\n\tasync updateRepository(data: CoreApiRepository): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.patch(`core/repository`, {\n\t\t\tdata,\n\t\t})\n\n\t\tif (204 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not update repository`)\n\t\t}\n\t}\n}\n"],"mappings":";;;AAiFA,IAAa,gBAAb,cAAmC,uBAAuB;;;;;;;;;;;;;;;;;CAiBzD,YAAY,SAAiB,QAAyB;EACrD,MAAM,SAAS,MAAM;CACtB;CAEA,MAAM,eAAoC;EACzC,MAAM,WAAW,OAAO,WAAW;EAEnC,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,IAAI,iBAAiB;EAElD,IAAI,QAAQ,OAAO,OAAO,KAAK,EAAE,MAAM,OAAO,KAAK,EAAA,CAAG,WAAW;GAChE,MAAM,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,4CAA4C;EAC7D;EAEA,SAAS,KAAK,EAAE,SAAS,oCAAoC,CAAC;EAE9D,QAAQ,MAAM,OAAO,KAAK,EAAA,CAAG;CAC9B;;;;;;CAOA,MAAM,cAAkC;EACvC,MAAM,WAAW,OAAO,WAAW;EAEnC,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,IAAI,iBAAiB,EACjD,QAAQ,EAAE,4BAA4B,KAAK,EAC5C,CAAC;EAED,IAAI,QAAQ,OAAO,OAAO,KAAK,EAAE,MAAM,OAAO,KAAK,EAAA,CAAG,SAAS;GAC9D,MAAM,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,2CAA2C;EAC5D;EAEA,SAAS,KAAK,EAAE,SAAS,qBAAqB,CAAC;EAE/C,QAAQ,MAAM,OAAO,KAAK,EAAA,CAAG;CAC9B;CAEA,MAAM,YACL,MAC2C;EAE3C,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,KAAK,kBAAkB,EACnD,KACD,CAAC;EAED,IAAI,QAAQ,OAAO,OAAO,GAAG;GAC5B,MA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S,OAAM,MADC,KAAK,WAAW,EAAA,CACT,IAAI,uBAAuB,WAAW;EAEnE,IAAI,QAAQ,OAAO,OAAO,GAAG;GAC5B,MAAM,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,kCAAkC;EACnD;EAEA,OAAO,OAAO,KAAK;CACpB;;;;;;;CAQA,MAAM,eAAe,IAA2B;EAE/C,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,KAAK,iBAAiB,GAAG,SAAS;EAE/D,IAAI,QAAQ,OAAO,OAAO,GAAG;GAC5B,MAAM,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,iCAAiC;EAClD;CACD;CAEA,MAAM,gBAA4C;EAEjD,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,IAAI,iBAAiB;EAElD,IAAI,QAAQ,OAAO,OAAO,GAAG;GAC5B,MAAM,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,0BAA0B;EAC3C;EAEA,OAAO,OAAO,KAAK;CACpB;CAEA,MAAM,iBAAiB,MAAwC;EAE9D,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,MAAM,mBAAmB,EACrD,KACD,CAAC;EAED,IAAI,QAAQ,OAAO,OAAO,GAAG;GAC5B,MAAM,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,6BAA6B;EAC9C;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"coreApi.js","names":[],"sources":["../../src/clients/coreApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse, logger } from \"../utils/log\"\nimport type { AuthServerToken } from \"./apiClient\"\nimport { AuthenticatedApiClient } from \"./apiClient\"\n\ntype Language = {\n\tid: string\n\tname: string\n\tis_master: boolean\n}\n\nexport type Release = {\n\tid: string\n\tlabel: string\n\tmigration: boolean\n}\n\nexport type CoreApiDocumentCreationPayload = {\n\ttitle: string\n\tlocale?: string\n\tgroup_lang_id?: string\n\trelease_id?: string\n\tintegration_field_ids: string[]\n\tdata: Record<string, unknown>\n\tcustom_type_id: string\n\ttags: string[]\n}\n\nexport type CoreApiDocumentUpdatePayload = {\n\tdata: Record<string, unknown>\n\tintegration_field_ids: string[]\n\ttags: string[]\n}\n\nexport type CoreApiRepository = Record<string, unknown> & {\n\tsimulator_url?: string\n}\n\nexport type CoreApiDocumentCreationResponse = {\n\tid: string\n\tgroup_lang_id: string\n\tcustom_type_id: string\n\tlocale: string\n\tlanguage: { id: string; name: string }\n\tfirst_publication_date: number | null\n\tlast_publication_date: number | null\n\ttitle: string\n\tversions: {\n\t\tstatus: string\n\t\tversion_id: string\n\t\tauthor: {\n\t\t\tid: string\n\t\t\tfirst_name: string | null\n\t\t\tlast_name: string | null\n\t\t\temail: string\n\t\t}\n\t\trelease_id: string | null\n\t\tlast_modified_date: number\n\t\ttags: string[]\n\t\tcustom_type_label: string\n\t\tpreview_summary?: string\n\t\tpreview_image?: string\n\t\tuid?: string\n\t}[]\n}\n\nexport type CoreApiDocumentsPayload = {\n\tlanguage?: string\n\tlimit?: number\n\tstatuses?: string[]\n\tgroupLangIds?: string[]\n\tdocumentIds?: string[]\n}\n\nexport type CoreApiDocumentsResponse = {\n\ttotal: number\n\tcursor: string\n\tresults: CoreApiDocumentCreationResponse[]\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type CoreApiDocumentData = Record<string, any>\n\nexport class CoreApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example\n\t * \tTo instantiate the class:\n\t *\n\t * \t```js\n\t * \tnew CoreApiClient(\"https://my-repo.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \t});\n\t * \t```\n\t *\n\t * @param baseURL - The api base URL like https://my-repo.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.authToken}: Api token generated from the auth service or a function to fetch it\n\t * when it's needed.\n\t */\n\tconstructor(baseURL: string, config: AuthServerToken) {\n\t\tsuper(baseURL, config)\n\t}\n\n\tasync getLanguages(): Promise<Language[]> {\n\t\tconst profiler = logger.startTimer()\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(\"core/repository\")\n\n\t\tif (200 !== result.status() || !(await result.json()).languages) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not get languages from the core api.\")\n\t\t}\n\n\t\tprofiler.done({ message: \"retrieved languages configuration\" })\n\n\t\treturn (await result.json()).languages\n\t}\n\n\t/**\n\t * Retrieves all releases, including the migration release.\n\t *\n\t * @returns An array of release metadata.\n\t */\n\tasync getReleases(): Promise<Release[]> {\n\t\tconst profiler = logger.startTimer()\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(\"core/releases\", {\n\t\t\tparams: { include_migration_releases: true },\n\t\t})\n\n\t\tif (200 !== result.status() || !(await result.json()).results) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not get releases from the core api.\")\n\t\t}\n\n\t\tprofiler.done({ message: \"retrieved releases\" })\n\n\t\treturn (await result.json()).results\n\t}\n\n\tasync createDraft(\n\t\tdata: CoreApiDocumentCreationPayload,\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(\"core/documents\", {\n\t\t\tdata,\n\t\t})\n\n\t\tif (201 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not create draft document\")\n\t\t}\n\n\t\treturn result.json()\n\t}\n\n\t/**\n\t * Creates a new draft version of an existing document, on top of the given base version.\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 * @returns The updated document, including the new version's id.\n\t */\n\tasync updateDraft(\n\t\tdocumentId: string,\n\t\tdata: CoreApiDocumentUpdatePayload,\n\t\tbaseVersionId: string,\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.put(`core/documents/${documentId}/draft`, {\n\t\t\tparams: { base_version_id: baseVersionId },\n\t\t\tdata,\n\t\t})\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not update draft for document with id ${documentId}`)\n\t\t}\n\n\t\treturn result.json()\n\t}\n\n\tasync publishDraft(documentId: string): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.patch(`core/documents/${documentId}/draft`, {\n\t\t\tdata: {\n\t\t\t\tstatus: \"published\",\n\t\t\t},\n\t\t})\n\n\t\tif (204 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not publish document with id ${documentId}`)\n\t\t}\n\t}\n\n\t/**\n\t * Unpublishes (archives) a live document.\n\t *\n\t * @param documentId - The id of the document to unpublish.\n\t */\n\tasync unpublishDocument(documentId: string): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.patch(`core/documents/${documentId}/live`, {\n\t\t\tdata: {\n\t\t\t\tstatus: \"archived\",\n\t\t\t},\n\t\t})\n\n\t\tif (204 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not unpublish document with id ${documentId}`)\n\t\t}\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\tconst context = await this.getContext()\n\t\tconst result = await context.post(\"core/documents/search\", {\n\t\t\tdata: args,\n\t\t})\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not search documents\")\n\t\t}\n\n\t\treturn result.json()\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\tconst context = await this.getContext()\n\t\tconst result = await context.get(`core/documents/data/${versionId}`)\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not retrieve document data\")\n\t\t}\n\n\t\treturn result.json()\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.\n\t */\n\tasync publishRelease(id: string): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(`core/releases/${id}/publish`)\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not publish release ${id}\")\n\t\t}\n\t}\n\n\tasync getRepository(): Promise<CoreApiRepository> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.get(`core/repository`)\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not get repository`)\n\t\t}\n\n\t\treturn result.json()\n\t}\n\n\tasync updateRepository(data: CoreApiRepository): Promise<void> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.patch(`core/repository`, {\n\t\t\tdata,\n\t\t})\n\n\t\tif (204 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(`Could not update repository`)\n\t\t}\n\t}\n}\n"],"mappings":";;;AAkFA,IAAa,gBAAb,cAAmC,uBAAuB;;;;;;;;;;;;;;;;;CAiBzD,YAAY,SAAiB,QAAyB;EACrD,MAAM,SAAS,MAAM;CACtB;CAEA,MAAM,eAAoC;EACzC,MAAM,WAAW,OAAO,WAAW;EAEnC,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,IAAI,iBAAiB;EAElD,IAAI,QAAQ,OAAO,OAAO,KAAK,EAAE,MAAM,OAAO,KAAK,EAAA,CAAG,WAAW;GAChE,MAAM,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,4CAA4C;EAC7D;EAEA,SAAS,KAAK,EAAE,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0B;EAC3C;EAEA,OAAO,OAAO,KAAK;CACpB;CAEA,MAAM,iBAAiB,MAAwC;EAE9D,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,MAAM,mBAAmB,EACrD,KACD,CAAC;EAED,IAAI,QAAQ,OAAO,OAAO,GAAG;GAC5B,MAAM,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,6BAA6B;EAC9C;CACD;AACD"}
|
|
@@ -206,10 +206,7 @@ var RepositoryManager = class {
|
|
|
206
206
|
const contentApi = this.getContentApiClient();
|
|
207
207
|
const masterRef = await contentApi.getMasterRef();
|
|
208
208
|
await this.coreApiClient.publishRelease(id);
|
|
209
|
-
await
|
|
210
|
-
timeout: 1e4,
|
|
211
|
-
message: "Waiting for new master ref to be available"
|
|
212
|
-
}).not.toBe(masterRef);
|
|
209
|
+
await this.waitForNewMasterRef(contentApi, masterRef);
|
|
213
210
|
profiler.done({ message: `release '${id}' published and new master ref available` });
|
|
214
211
|
}
|
|
215
212
|
/**
|
|
@@ -500,10 +497,7 @@ var RepositoryManager = class {
|
|
|
500
497
|
const contentApi = this.getContentApiClient();
|
|
501
498
|
const masterRef = await contentApi.getMasterRef();
|
|
502
499
|
await this.coreApiClient.publishDraft(result.id);
|
|
503
|
-
await
|
|
504
|
-
timeout: 1e4,
|
|
505
|
-
message: "Waiting for new master ref to be available"
|
|
506
|
-
}).not.toBe(masterRef);
|
|
500
|
+
await this.waitForNewMasterRef(contentApi, masterRef);
|
|
507
501
|
message += ", status 'published' and new master ref available";
|
|
508
502
|
}
|
|
509
503
|
profiler.done({ message });
|
|
@@ -520,30 +514,37 @@ var RepositoryManager = class {
|
|
|
520
514
|
* @param status - Status of the new version, if published, the function will wait for a new
|
|
521
515
|
* content api master ref to be created.
|
|
522
516
|
* @param options - Additional options.
|
|
523
|
-
* @param options.
|
|
524
|
-
* available (default
|
|
525
|
-
*
|
|
517
|
+
* @param options.skipMasterRefWait - When publishing, skip waiting for a new content api master
|
|
518
|
+
* ref to be available (default false). Set to true to return without waiting for the
|
|
519
|
+
* projection.
|
|
520
|
+
* @returns The updated document, including the new version's id. When publishing, the document is
|
|
521
|
+
* retrieved again after publication so that the returned versions reflect the published state.
|
|
526
522
|
*/
|
|
527
523
|
async updateDocument(documentId, data, baseVersionId, status, options = {}) {
|
|
528
|
-
const {
|
|
524
|
+
const { skipMasterRefWait = false } = options;
|
|
529
525
|
const profiler = require_log.logger.startTimer();
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
|
|
526
|
+
const draft = await this.coreApiClient.updateDraft(documentId, data, baseVersionId);
|
|
527
|
+
if (status === "draft") {
|
|
528
|
+
profiler.done({ message: `Document '${documentId}' updated` });
|
|
529
|
+
return draft;
|
|
530
|
+
}
|
|
531
|
+
let message = `Document '${documentId}' updated, status 'published'`;
|
|
532
|
+
if (skipMasterRefWait) await this.coreApiClient.publishDraft(documentId);
|
|
533
|
+
else {
|
|
533
534
|
const contentApi = this.getContentApiClient();
|
|
534
535
|
const masterRef = await contentApi.getMasterRef();
|
|
535
536
|
await this.coreApiClient.publishDraft(documentId);
|
|
536
|
-
await
|
|
537
|
-
|
|
538
|
-
message: "Waiting for new master ref to be available"
|
|
539
|
-
}).not.toBe(masterRef);
|
|
540
|
-
message += ", status 'published' and new master ref available";
|
|
541
|
-
} else {
|
|
542
|
-
await this.coreApiClient.publishDraft(documentId);
|
|
543
|
-
message += ", status 'published'";
|
|
537
|
+
await this.waitForNewMasterRef(contentApi, masterRef);
|
|
538
|
+
message += " and new master ref available";
|
|
544
539
|
}
|
|
540
|
+
const { results } = await this.coreApiClient.getDocuments({
|
|
541
|
+
documentIds: [documentId],
|
|
542
|
+
limit: 1
|
|
543
|
+
});
|
|
544
|
+
const publishedDocument = results[0];
|
|
545
|
+
if (!publishedDocument) throw new Error(`Could not retrieve document '${documentId}' after publication`);
|
|
545
546
|
profiler.done({ message });
|
|
546
|
-
return
|
|
547
|
+
return publishedDocument;
|
|
547
548
|
}
|
|
548
549
|
/**
|
|
549
550
|
* Unpublishes (archives) a live document using the core api. Unless disabled, waits for a new
|
|
@@ -551,13 +552,13 @@ var RepositoryManager = class {
|
|
|
551
552
|
*
|
|
552
553
|
* @param documentId - The id of the document to unpublish.
|
|
553
554
|
* @param options - Additional options.
|
|
554
|
-
* @param options.
|
|
555
|
-
* (default
|
|
555
|
+
* @param options.skipMasterRefWait - Skip waiting for a new content api master ref to be
|
|
556
|
+
* available (default false). Set to true to return without waiting for the projection.
|
|
556
557
|
*/
|
|
557
558
|
async unpublishDocument(documentId, options = {}) {
|
|
558
|
-
const {
|
|
559
|
+
const { skipMasterRefWait = false } = options;
|
|
559
560
|
const profiler = require_log.logger.startTimer();
|
|
560
|
-
if (
|
|
561
|
+
if (skipMasterRefWait) {
|
|
561
562
|
await this.coreApiClient.unpublishDocument(documentId);
|
|
562
563
|
profiler.done({ message: `Document '${documentId}' unpublished` });
|
|
563
564
|
return;
|
|
@@ -565,10 +566,7 @@ var RepositoryManager = class {
|
|
|
565
566
|
const contentApi = this.getContentApiClient();
|
|
566
567
|
const masterRef = await contentApi.getMasterRef();
|
|
567
568
|
await this.coreApiClient.unpublishDocument(documentId);
|
|
568
|
-
await
|
|
569
|
-
timeout: 1e4,
|
|
570
|
-
message: "Waiting for new master ref to be available"
|
|
571
|
-
}).not.toBe(masterRef);
|
|
569
|
+
await this.waitForNewMasterRef(contentApi, masterRef);
|
|
572
570
|
profiler.done({ message: `Document '${documentId}' unpublished and new master ref available` });
|
|
573
571
|
}
|
|
574
572
|
/**
|
|
@@ -586,6 +584,12 @@ var RepositoryManager = class {
|
|
|
586
584
|
await this.integrationFieldsClient.setupIntegrationFields(integrationFields);
|
|
587
585
|
profiler.done({ message: `Integration Fields setup` });
|
|
588
586
|
}
|
|
587
|
+
async waitForNewMasterRef(contentApi, previousMasterRef) {
|
|
588
|
+
await _playwright_test.expect.poll(async () => contentApi.getMasterRef(), {
|
|
589
|
+
timeout: 1e4,
|
|
590
|
+
message: "Waiting for new master ref to be available"
|
|
591
|
+
}).not.toBe(previousMasterRef);
|
|
592
|
+
}
|
|
589
593
|
};
|
|
590
594
|
//#endregion
|
|
591
595
|
exports.RepositoryManager = RepositoryManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.cjs","names":["getRepositoryUrl","ContentApiClient","logger","expect"],"sources":["../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\"\nimport type { 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 expect\n\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\ttimeout: 10_000,\n\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t})\n\t\t\t.not.toBe(masterRef)\n\n\t\tprofiler.done({\n\t\t\tmessage: `release '${id}' published and new master ref available`,\n\t\t})\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\n\t * @param id - The ID of the release to be deleted.\n\t */\n\tasync deleteRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(this.name, `app/releases/${id}/delete`, {})\n\n\t\tthis.failIfNot200(response, `Could not delete release with id ${id}`)\n\t\tprofiler.done({ message: `release '${id}' deleted` })\n\t}\n\n\t/**\n\t * Creates a preview for a repository.\n\t *\n\t * @param data - The data for creating the preview.\n\t */\n\tasync createPreview(data: Preview): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(this.name, `previews/new`, data)\n\n\t\tthis.failIfNot200(response, `Could not create preview ${data.name}`)\n\t\tprofiler.done({ message: `preview '${data.name}' created` })\n\n\t\treturn response.data\n\t}\n\n\t/**\n\t * Set the simulator URL (table of slices) for a repository.\n\t *\n\t * @param data - The simulator URL to set.\n\t */\n\tasync setSimulatorURL(simulatorURL: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst repository = await this.coreApiClient.getRepository()\n\t\tawait this.coreApiClient.updateRepository({\n\t\t\t...repository,\n\t\t\tsimulator_url: simulatorURL,\n\t\t})\n\n\t\tprofiler.done({\n\t\t\tmessage: `simulator preview '${simulatorURL}' created`,\n\t\t})\n\t}\n\n\t/**\n\t * Deletes a preview from a repository.\n\t *\n\t * @param id - The ID of the preview to be deleted.\n\t */\n\tasync deletePreview(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(this.name, `previews/delete/${id}`, {})\n\n\t\tthis.failIfNot200(response, `Could not delete preview with id ${id}`)\n\t\tprofiler.done({ message: `preview '${id}' deleted` })\n\t}\n\n\t/**\n\t * Create a webhook.\n\t *\n\t * @returns A Promise that resolves with the webhook id.\n\t */\n\tasync createWebhook(\n\t\tname: string,\n\t\turl: string,\n\t\tsecret: string,\n\t\ttriggers: {\n\t\t\tdocumentsPublished?: boolean\n\t\t\tdocumentsUnpublished?: boolean\n\t\t\treleasesCreated?: boolean\n\t\t\treleasesUpdated?: boolean\n\t\t\ttagsCreated?: boolean\n\t\t\ttagsDeleted?: boolean\n\t\t},\n\t\tactive: boolean,\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(this.name, \"app/settings/webhooks/create\", {\n\t\t\tname,\n\t\t\turl,\n\t\t\tsecret,\n\t\t\tactive: active ? \"on\" : \"off\",\n\t\t\t...triggers,\n\t\t})\n\t\tthis.failIfNot200(response, `Could not create webhook ${name}`)\n\t\tprofiler.done({ message: `webhook '${name}' created` })\n\n\t\treturn response.data.created\n\t}\n\n\t/**\n\t * Deletes a webhook.\n\t *\n\t * @param id - The webhook ID.\n\t */\n\tasync deleteWebhook(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/webhooks/${id}/delete`,\n\t\t\t{},\n\t\t)\n\n\t\tthis.failIfNot200(response, `Could not delete webhook with id ${id}`)\n\t\tprofiler.done({ message: `webhook '${id}' deleted` })\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes\n\t */\n\tasync createCustomTypes(customTypes: DynamicCustomTypeModel[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes)\n\t}\n\n\tasync deleteCustomType(customTypeId: string): Promise<void> {\n\t\tawait this.customTypesApiClient.deleteCustomType(customTypeId)\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices\n\t */\n\tasync createSlices(slices: SharedSliceModel[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createSlices(slices)\n\t}\n\n\t/**\n\t * Create an access token to query private items of the Content api.\n\t *\n\t * @param appName - Mandatory authorized application name\n\t * @param tokenScope - Access token scope. Use \"master\" to when your content api is fully private\n\t * or \"master+releases\" to access private releases\n\t */\n\tasync createContentAPIToken(\n\t\tappName: string,\n\t\ttokenScope: \"master\" | \"master+releases\" = \"master\",\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer()\n\t\ttype AuthorizedAppResponse = {\n\t\t\tid: string\n\t\t\tname: string\n\t\t\twroom_auths: { token: string; scope: \"master\" | \"master+releases\" }[]\n\t\t}\n\t\tconst existingApps: AxiosResponse<AuthorizedAppResponse[]> = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"settings/security/contentapi\",\n\t\t)\n\n\t\tthis.failIfNot200(\n\t\t\texistingApps,\n\t\t\t`Could not get status of existing applications to generate a content api token`,\n\t\t)\n\t\tlet app = existingApps.data.find(({ name, wroom_auths }) => {\n\t\t\treturn name === appName && wroom_auths.length > 0\n\t\t})\n\n\t\tif (!app) {\n\t\t\tconst response: AxiosResponse<AuthorizedAppResponse> = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/oauthapp\",\n\t\t\t\t{\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tthis.failIfNot200(response, `Could not create content api app ${appName}`)\n\t\t\tapp = response.data\n\t\t}\n\n\t\tlet tokenInfo = app.wroom_auths.find(({ scope }) => scope === tokenScope)\n\t\tif (!tokenInfo) {\n\t\t\tconst response = await this.wroomClient.post(this.name, \"settings/security/authorizations\", {\n\t\t\t\tapp: app.id,\n\t\t\t\tscope: tokenScope,\n\t\t\t})\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api access token for app ${appName} with scope ${tokenScope}`,\n\t\t\t)\n\t\t\ttokenInfo = response.data\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `content api access token for app '${appName}' created`,\n\t\t})\n\n\t\tif (!tokenInfo?.token) {\n\t\t\tthrow `Could not create content api access token for app ${appName} with scope ${tokenScope}`\n\t\t}\n\n\t\treturn tokenInfo.token\n\t}\n\n\t/** Create a permanent access token to authenticate to Prismic public apis. */\n\tasync createPermanentAccessToken(): Promise<string> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst token = await this.authApiClient.getMachine2MachineToken(this.name)\n\n\t\tprofiler.done({\n\t\t\tmessage: `machine2machine token created`,\n\t\t})\n\n\t\treturn token\n\t}\n\n\t/**\n\t * Toggle the Role per Locale workflow\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleRolePerLocal(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.toggleRolePerLocal({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t})\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Role per local for ${this.name}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Role per local ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t})\n\t}\n\n\t/**\n\t * Toggle the Custom Roles workflow\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleCustomRoles(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.toggleCustomRoles({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t})\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Custom Roles for ${this.name}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Custom Roles ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t})\n\t}\n\n\t/**\n\t * Toggle the Integration Fields feature\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleIntegrationFields(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.toggleIntegrationFields({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t})\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Integration Fields for ${this.name}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Integration Fields ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t})\n\t}\n\n\t/**\n\t * Change the Repository Plan\n\t *\n\t * @param {string} newPlanId - The Id of the new Plan to apply\n\t */\n\tasync changePlan(newPlanId: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.changePlan({\n\t\t\trepository: this.name,\n\t\t\tnewPlanId: newPlanId,\n\t\t\tbypassManualBilling: true, // For now the library does not support Stripe features\n\t\t})\n\n\t\tthis.failIfNot200(response, \"Could not change the Repository Plan\")\n\t\tprofiler.done({\n\t\t\tmessage: `Repository Plan changed to ${newPlanId}`,\n\t\t})\n\t}\n\n\t/**\n\t * Add a new user to the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync addUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.addUserToRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t})\n\n\t\tconst { data, status } = response\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 409 && JSON.stringify(data).includes(\"already a member of the repo\"))\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response)\n\t\t\tthrow new Error(`Could not add a new user ${email} to the repository`)\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was added to the repository`,\n\t\t})\n\t}\n\n\t/**\n\t * Remove a user from the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync removeUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.removeUserFromRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t})\n\n\t\tthis.failIfNot200(response, `Could not remove the user ${email} from the repository`)\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was removed from the repository`,\n\t\t})\n\t}\n\n\t/**\n\t * Update the role of a user in a repository\n\t *\n\t * @param {string} email - The email of the user\n\t * @param {string | Record<string, string>} role - The new Role of the user, either a string for\n\t * basic workflow or an object such as `{ \"lang_id\": \"Writer\" }`\n\t *\n\t * Example of roles are\n\t *\n\t * - Administrator\n\t * - Writer\n\t * - Contributor\n\t * - Manager (publisher)\n\t */\n\tasync updateUserRole(email: string, role: string | Record<string, string>): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response =\n\t\t\ttypeof role === \"string\"\n\t\t\t\t? await this.wroomClient.updateRole(this.name, email, role)\n\t\t\t\t: await this.wroomClient.updateRolePerLocal(this.name, email, role)\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not update the ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} of the user ${email}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Updated User's ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} for user ${email}`,\n\t\t})\n\t}\n\n\t/**\n\t * Creates a document using the core api. If the Core api format is too specific, use the\n\t * migration api client to create a document with the MigrationApiClient. See the\n\t * `getMigrationApiClient()` method.\n\t *\n\t * @example\n\t * \tTo create a document by converting it from the Page Builder to\n\t * \tCore api format\n\t *\n\t * \t```js\n\t * \timport { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';\n\t *\n\t * \tconst document = {\n\t * \ttitle: 'A new document',\n\t * \tcustom_type_id: 'home-page',\n\t * \tlocale: 'en-gb',\n\t * \tintegration_field_ids: [],\n\t * \ttags: [],\n\t * \tdata: DocumentLegacy.encode({\n\t * \tuid: {\n\t * \t__TYPE__: UIDContentType,\n\t * \tvalue: 'home-page',\n\t * \t},\n\t * \t})\n\t * \t}\n\t * \tawait repository.createDocument(document, 'published');\n\t * \t* ```\n\t * \t```\n\t *\n\t * \t@returns\n\t *\n\t * \t@param document - in the core api format.\n\t *\n\t * \t@param status - status of the document, if published, the function will\n\t * \twait for a new content api master ref to be created\n\t */\n\tasync createDocument(\n\t\tdocument: CoreApiDocumentCreationPayload,\n\t\tstatus: \"draft\" | \"published\",\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst profiler = logger.startTimer()\n\t\tconst result = await this.coreApiClient.createDraft(document)\n\n\t\tlet message = `Document created with id '${result.id}'`\n\t\tif (status === \"published\") {\n\t\t\tconst contentApi = this.getContentApiClient()\n\t\t\tconst masterRef = await contentApi.getMasterRef()\n\t\t\tawait this.coreApiClient.publishDraft(result.id)\n\t\t\tawait expect\n\t\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\t\ttimeout: 10_000,\n\t\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t\t})\n\t\t\t\t.not.toBe(masterRef)\n\t\t\tmessage += \", status 'published' and new master ref available\"\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage,\n\t\t})\n\n\t\treturn result\n\t}\n\n\t/**\n\t * 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.waitForMasterRef - When publishing, wait for a new content api master ref to be\n\t * available (default true). Set to false to return without waiting for the projection.\n\t * @returns The updated document, including the new version's id.\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: { waitForMasterRef?: boolean } = {},\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst { waitForMasterRef = true } = options\n\t\tconst profiler = logger.startTimer()\n\t\tconst result = await this.coreApiClient.updateDraft(documentId, data, baseVersionId)\n\n\t\tlet message = `Document '${documentId}' updated`\n\t\tif (status === \"published\") {\n\t\t\tif (waitForMasterRef) {\n\t\t\t\tconst contentApi = this.getContentApiClient()\n\t\t\t\tconst masterRef = await contentApi.getMasterRef()\n\t\t\t\tawait this.coreApiClient.publishDraft(documentId)\n\t\t\t\tawait expect\n\t\t\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\t\t\ttimeout: 10_000,\n\t\t\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t\t\t})\n\t\t\t\t\t.not.toBe(masterRef)\n\t\t\t\tmessage += \", status 'published' and new master ref available\"\n\t\t\t} else {\n\t\t\t\tawait this.coreApiClient.publishDraft(documentId)\n\t\t\t\tmessage += \", status 'published'\"\n\t\t\t}\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 * 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.waitForMasterRef - Wait for a new content api master ref to be available\n\t * (default true). Set to false to return without waiting for the projection.\n\t */\n\tasync unpublishDocument(\n\t\tdocumentId: string,\n\t\toptions: { waitForMasterRef?: boolean } = {},\n\t): Promise<void> {\n\t\tconst { waitForMasterRef = true } = options\n\t\tconst profiler = logger.startTimer()\n\n\t\tif (!waitForMasterRef) {\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 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: `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\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,gBAAgB,cAAc,IAAI;IACnE,IAAI,CAAC,QACJ,MAAM,KAAK,iBAAiB,OAAO,eAAe,QAAQ;SACpD,IAAI,OAAO,OAAO,OAAO,eAE/B,8BAA8B;GAEhC;GAEA,IAAI,OAAO,SAAS;IAEnB,MAAM,eAAe,OAAO,QAAQ,QAClC,OAAO,CAAC,UAAU,MAAM,aAAa,SAAS,OAAO,EAAE,CACzD;I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,cAAc,aAAa,UAAU;GAChD,WAAW;EACZ;EAED,SAAS,KAAK,EACb,QACD,CAAC;EAED,OAAO;CACR;;;;;;;;;;CAWA,MAAM,kBACL,YACA,UAA0C,CAAC,GAC3B;EAChB,MAAM,EAAE,mBAAmB,SAAS;EACpC,MAAM,WAAWD,YAAAA,OAAO,WAAW;EAEnC,IAAI,CAAC,kBAAkB;GACtB,MAAM,KAAK,cAAc,kBAAkB,UAAU;GACrD,SAAS,KAAK,EAAE,SAAS,aAAa,WAAW,eAAe,CAAC;GAEjE;EACD;EAEA,MAAM,aAAa,KAAK,oBAAoB;EAC5C,MAAM,YAAY,MAAM,WAAW,aAAa;EAChD,MAAM,KAAK,cAAc,kBAAkB,UAAU;EACrD,MAAMC,iBAAAA,OACJ,KAAK,YAAY,WAAW,aAAa,GAAG;GAC5C,SAAS;GACT,SAAS;EACV,CAAC,CAAC,CACD,IAAI,KAAK,SAAS;EAEpB,SAAS,KAAK,EACb,SAAS,aAAa,WAAW,4CAClC,CAAC;CACF;;;;;;;CAQA,MAAM,gBAAgB,WAAiD;EACtE,OAAO,MAAM,KAAK,cAAc,gBAAgB,SAAS;CAC1D;CAEA,MAAM,uBAAuB,mBAA4D;EACxF,MAAM,WAAWD,YAAAA,OAAO,WAAW;EAEnC,IAAI,CAAC,KAAK,yBACT,MAAM,IAAI,MACT,yGACD;EAGD,MAAM,KAAK,wBAAwB,uBAAuB,iBAAiB;EAC3E,SAAS,KAAK,EACb,SAAS,2BACV,CAAC;CACF;AACD"}
|
|
1
|
+
{"version":3,"file":"repository.cjs","names":["getRepositoryUrl","ContentApiClient","logger","expect"],"sources":["../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\"\nimport type { DynamicCustomTypeModel, SharedSliceModel } from \"@prismicio/types-internal\"\nimport type { AxiosResponse } from \"axios\"\n\nimport type { AssetApiClient } from \"../clients/assetApi\"\nimport type { AuthenticationApiClient } from \"../clients/authenticationApi\"\nimport { ContentApiClient } from \"../clients/contentApi\"\nimport type {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n\tCoreApiDocumentData,\n\tCoreApiDocumentsPayload,\n\tCoreApiDocumentsResponse,\n\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\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AM,WAAW,aAAa;EAChD,MAAM,KAAK,cAAc,kBAAkB,UAAU;EACrD,MAAM,KAAK,oBAAoB,YAAY,SAAS;EAEpD,SAAS,KAAK,EACb,SAAS,aAAa,WAAW,4CAClC,CAAC;CACF;;;;;;;CAQA,MAAM,gBAAgB,WAAiD;EACtE,OAAO,MAAM,KAAK,cAAc,gBAAgB,SAAS;CAC1D;CAEA,MAAM,uBAAuB,mBAA4D;EACxF,MAAM,WAAWA,YAAAA,OAAO,WAAW;EAEnC,IAAI,CAAC,KAAK,yBACT,MAAM,IAAI,MACT,yGACD;EAGD,MAAM,KAAK,wBAAwB,uBAAuB,iBAAiB;EAC3E,SAAS,KAAK,EACb,SAAS,2BACV,CAAC;CACF;CAEA,MAAc,oBACb,YACA,mBACgB;EAChB,MAAMC,iBAAAA,OACJ,KAAK,YAAY,WAAW,aAAa,GAAG;GAC5C,SAAS;GACT,SAAS;EACV,CAAC,CAAC,CACD,IAAI,KAAK,iBAAiB;CAC7B;AACD"}
|
|
@@ -277,12 +277,14 @@ declare class RepositoryManager {
|
|
|
277
277
|
* @param status - Status of the new version, if published, the function will wait for a new
|
|
278
278
|
* content api master ref to be created.
|
|
279
279
|
* @param options - Additional options.
|
|
280
|
-
* @param options.
|
|
281
|
-
* available (default
|
|
282
|
-
*
|
|
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.
|
|
283
285
|
*/
|
|
284
286
|
updateDocument(documentId: string, data: CoreApiDocumentUpdatePayload, baseVersionId: string, status: "draft" | "published", options?: {
|
|
285
|
-
|
|
287
|
+
skipMasterRefWait?: boolean;
|
|
286
288
|
}): Promise<CoreApiDocumentCreationResponse>;
|
|
287
289
|
/**
|
|
288
290
|
* Unpublishes (archives) a live document using the core api. Unless disabled, waits for a new
|
|
@@ -290,11 +292,11 @@ declare class RepositoryManager {
|
|
|
290
292
|
*
|
|
291
293
|
* @param documentId - The id of the document to unpublish.
|
|
292
294
|
* @param options - Additional options.
|
|
293
|
-
* @param options.
|
|
294
|
-
* (default
|
|
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.
|
|
295
297
|
*/
|
|
296
298
|
unpublishDocument(documentId: string, options?: {
|
|
297
|
-
|
|
299
|
+
skipMasterRefWait?: boolean;
|
|
298
300
|
}): Promise<void>;
|
|
299
301
|
/**
|
|
300
302
|
* Retrieves data for a specific document version.
|
|
@@ -304,6 +306,7 @@ declare class RepositoryManager {
|
|
|
304
306
|
*/
|
|
305
307
|
getDocumentData(versionId: string): Promise<CoreApiDocumentData>;
|
|
306
308
|
setupIntegrationFields(integrationFields: IntegrationFieldConfig[]): Promise<void>;
|
|
309
|
+
private waitForNewMasterRef;
|
|
307
310
|
}
|
|
308
311
|
type RepositoryConfig = {
|
|
309
312
|
customLocale?: CustomLocale;
|
|
@@ -1 +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,aAAA,EACf,aAAA,EAAe,uBAAA,EACf,WAAA,EAAa,WAAA,EACb,oBAAA,EAAsB,oBAAA,EACtB,kBAAA,EAAoB,kBAAA,cACpB,cAAA,EAAgB,cAAA,EAChB,cAAA,EAAgB,cAAA,EAChB,uBAAA,EAAyB,uBAAA;EAGrC,SAAA,CAAU,MAAA,EAAQ,gBAAA,GAAmB,OAAA;EAAn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;;;EA8C/B,UAAA,CAAW,KAAA,WAAgB,OAAA;EAAA;;;;;;;;;;;;;;EA4B3B,cAAA,CAAe,KAAA,UAAe,IAAA,WAAe,MAAA,mBAAyB,OAAA;EAkG3E;;;;;;;;;;;;;;;;;;;;;;AAoGgC;AAalC;;;;;;;;;;;;;EA1JO,cAAA,CACL,QAAA,EAAU,8BAAA,EACV,MAAA,0BACE,OAAA,CAAQ,+BAAA;EA2JX;;;;;;;;;;;;AAM0C;AAG3C;;;;EAhIO,cAAA,CACL,UAAA,UACA,IAAA,EAAM,4BAAA,EACN,aAAA,UACA,MAAA,yBACA,OAAA;IAAW,iBAAA;EAAA,IACT,OAAA,CAAQ,+BAAA;EA6HC;AAAA;AAGb;;;;;;;EAjFO,iBAAA,CACL,UAAA,UACA,OAAA;IAAW,iBAAA;EAAA,IACT,OAAA;EAsFF;;AAAE;;;;EA3DG,eAAA,CAAgB,SAAA,WAAoB,OAAA,CAAQ,mBAAA;EAI5C,sBAAA,CAAuB,iBAAA,EAAmB,sBAAA,KAA2B,OAAA;EAAA,QAe7D,mBAAA;AAAA;AAAA,KAaH,gBAAA;EACX,YAAA,GAAe,YAAA;EACf,OAAA;EACA,aAAA;EACA,MAAA,GAAS,gBAAA;EACT,WAAA,GAAc,sBAAA;EACd,OAAA,GAAU,OAAA;EACV,YAAA;EACA,YAAA;EACA,WAAA;EACA,iBAAA,GAAoB,sBAAA;AAAA;AAAA,KAGT,OAAA;EACX,IAAA;EACA,UAAA;EACA,YAAA;AAAA;AAAA,KAGW,YAAA;EACX,IAAA;IACC,KAAA;IACA,EAAA;IACA,mBAAA;EAAA;EAED,MAAA;IACC,KAAA;IACA,EAAA;EAAA;AAAA"}
|
|
@@ -277,12 +277,14 @@ declare class RepositoryManager {
|
|
|
277
277
|
* @param status - Status of the new version, if published, the function will wait for a new
|
|
278
278
|
* content api master ref to be created.
|
|
279
279
|
* @param options - Additional options.
|
|
280
|
-
* @param options.
|
|
281
|
-
* available (default
|
|
282
|
-
*
|
|
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.
|
|
283
285
|
*/
|
|
284
286
|
updateDocument(documentId: string, data: CoreApiDocumentUpdatePayload, baseVersionId: string, status: "draft" | "published", options?: {
|
|
285
|
-
|
|
287
|
+
skipMasterRefWait?: boolean;
|
|
286
288
|
}): Promise<CoreApiDocumentCreationResponse>;
|
|
287
289
|
/**
|
|
288
290
|
* Unpublishes (archives) a live document using the core api. Unless disabled, waits for a new
|
|
@@ -290,11 +292,11 @@ declare class RepositoryManager {
|
|
|
290
292
|
*
|
|
291
293
|
* @param documentId - The id of the document to unpublish.
|
|
292
294
|
* @param options - Additional options.
|
|
293
|
-
* @param options.
|
|
294
|
-
* (default
|
|
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.
|
|
295
297
|
*/
|
|
296
298
|
unpublishDocument(documentId: string, options?: {
|
|
297
|
-
|
|
299
|
+
skipMasterRefWait?: boolean;
|
|
298
300
|
}): Promise<void>;
|
|
299
301
|
/**
|
|
300
302
|
* Retrieves data for a specific document version.
|
|
@@ -304,6 +306,7 @@ declare class RepositoryManager {
|
|
|
304
306
|
*/
|
|
305
307
|
getDocumentData(versionId: string): Promise<CoreApiDocumentData>;
|
|
306
308
|
setupIntegrationFields(integrationFields: IntegrationFieldConfig[]): Promise<void>;
|
|
309
|
+
private waitForNewMasterRef;
|
|
307
310
|
}
|
|
308
311
|
type RepositoryConfig = {
|
|
309
312
|
customLocale?: CustomLocale;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","names":[],"sources":["../../src/managers/repository.ts"],"mappings":";;;;;;;;;;;;;;cA2Ba,iBAAA;EAAA,S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A,GAAU,OAAA;EACV,YAAA;EACA,YAAA;EACA,WAAA;EACA,iBAAA,GAAoB,sBAAA;AAAA;AAAA,KAGT,OAAA;EACX,IAAA;EACA,UAAA;EACA,YAAA;AAAA;AAAA,KAGW,YAAA;EACX,IAAA;IACC,KAAA;IACA,EAAA;IACA,mBAAA;EAAA;EAED,MAAA;IACC,KAAA;IACA,EAAA;EAAA;AAAA"}
|
|
@@ -206,10 +206,7 @@ var RepositoryManager = class {
|
|
|
206
206
|
const contentApi = this.getContentApiClient();
|
|
207
207
|
const masterRef = await contentApi.getMasterRef();
|
|
208
208
|
await this.coreApiClient.publishRelease(id);
|
|
209
|
-
await
|
|
210
|
-
timeout: 1e4,
|
|
211
|
-
message: "Waiting for new master ref to be available"
|
|
212
|
-
}).not.toBe(masterRef);
|
|
209
|
+
await this.waitForNewMasterRef(contentApi, masterRef);
|
|
213
210
|
profiler.done({ message: `release '${id}' published and new master ref available` });
|
|
214
211
|
}
|
|
215
212
|
/**
|
|
@@ -500,10 +497,7 @@ var RepositoryManager = class {
|
|
|
500
497
|
const contentApi = this.getContentApiClient();
|
|
501
498
|
const masterRef = await contentApi.getMasterRef();
|
|
502
499
|
await this.coreApiClient.publishDraft(result.id);
|
|
503
|
-
await
|
|
504
|
-
timeout: 1e4,
|
|
505
|
-
message: "Waiting for new master ref to be available"
|
|
506
|
-
}).not.toBe(masterRef);
|
|
500
|
+
await this.waitForNewMasterRef(contentApi, masterRef);
|
|
507
501
|
message += ", status 'published' and new master ref available";
|
|
508
502
|
}
|
|
509
503
|
profiler.done({ message });
|
|
@@ -520,30 +514,37 @@ var RepositoryManager = class {
|
|
|
520
514
|
* @param status - Status of the new version, if published, the function will wait for a new
|
|
521
515
|
* content api master ref to be created.
|
|
522
516
|
* @param options - Additional options.
|
|
523
|
-
* @param options.
|
|
524
|
-
* available (default
|
|
525
|
-
*
|
|
517
|
+
* @param options.skipMasterRefWait - When publishing, skip waiting for a new content api master
|
|
518
|
+
* ref to be available (default false). Set to true to return without waiting for the
|
|
519
|
+
* projection.
|
|
520
|
+
* @returns The updated document, including the new version's id. When publishing, the document is
|
|
521
|
+
* retrieved again after publication so that the returned versions reflect the published state.
|
|
526
522
|
*/
|
|
527
523
|
async updateDocument(documentId, data, baseVersionId, status, options = {}) {
|
|
528
|
-
const {
|
|
524
|
+
const { skipMasterRefWait = false } = options;
|
|
529
525
|
const profiler = logger.startTimer();
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
|
|
526
|
+
const draft = await this.coreApiClient.updateDraft(documentId, data, baseVersionId);
|
|
527
|
+
if (status === "draft") {
|
|
528
|
+
profiler.done({ message: `Document '${documentId}' updated` });
|
|
529
|
+
return draft;
|
|
530
|
+
}
|
|
531
|
+
let message = `Document '${documentId}' updated, status 'published'`;
|
|
532
|
+
if (skipMasterRefWait) await this.coreApiClient.publishDraft(documentId);
|
|
533
|
+
else {
|
|
533
534
|
const contentApi = this.getContentApiClient();
|
|
534
535
|
const masterRef = await contentApi.getMasterRef();
|
|
535
536
|
await this.coreApiClient.publishDraft(documentId);
|
|
536
|
-
await
|
|
537
|
-
|
|
538
|
-
message: "Waiting for new master ref to be available"
|
|
539
|
-
}).not.toBe(masterRef);
|
|
540
|
-
message += ", status 'published' and new master ref available";
|
|
541
|
-
} else {
|
|
542
|
-
await this.coreApiClient.publishDraft(documentId);
|
|
543
|
-
message += ", status 'published'";
|
|
537
|
+
await this.waitForNewMasterRef(contentApi, masterRef);
|
|
538
|
+
message += " and new master ref available";
|
|
544
539
|
}
|
|
540
|
+
const { results } = await this.coreApiClient.getDocuments({
|
|
541
|
+
documentIds: [documentId],
|
|
542
|
+
limit: 1
|
|
543
|
+
});
|
|
544
|
+
const publishedDocument = results[0];
|
|
545
|
+
if (!publishedDocument) throw new Error(`Could not retrieve document '${documentId}' after publication`);
|
|
545
546
|
profiler.done({ message });
|
|
546
|
-
return
|
|
547
|
+
return publishedDocument;
|
|
547
548
|
}
|
|
548
549
|
/**
|
|
549
550
|
* Unpublishes (archives) a live document using the core api. Unless disabled, waits for a new
|
|
@@ -551,13 +552,13 @@ var RepositoryManager = class {
|
|
|
551
552
|
*
|
|
552
553
|
* @param documentId - The id of the document to unpublish.
|
|
553
554
|
* @param options - Additional options.
|
|
554
|
-
* @param options.
|
|
555
|
-
* (default
|
|
555
|
+
* @param options.skipMasterRefWait - Skip waiting for a new content api master ref to be
|
|
556
|
+
* available (default false). Set to true to return without waiting for the projection.
|
|
556
557
|
*/
|
|
557
558
|
async unpublishDocument(documentId, options = {}) {
|
|
558
|
-
const {
|
|
559
|
+
const { skipMasterRefWait = false } = options;
|
|
559
560
|
const profiler = logger.startTimer();
|
|
560
|
-
if (
|
|
561
|
+
if (skipMasterRefWait) {
|
|
561
562
|
await this.coreApiClient.unpublishDocument(documentId);
|
|
562
563
|
profiler.done({ message: `Document '${documentId}' unpublished` });
|
|
563
564
|
return;
|
|
@@ -565,10 +566,7 @@ var RepositoryManager = class {
|
|
|
565
566
|
const contentApi = this.getContentApiClient();
|
|
566
567
|
const masterRef = await contentApi.getMasterRef();
|
|
567
568
|
await this.coreApiClient.unpublishDocument(documentId);
|
|
568
|
-
await
|
|
569
|
-
timeout: 1e4,
|
|
570
|
-
message: "Waiting for new master ref to be available"
|
|
571
|
-
}).not.toBe(masterRef);
|
|
569
|
+
await this.waitForNewMasterRef(contentApi, masterRef);
|
|
572
570
|
profiler.done({ message: `Document '${documentId}' unpublished and new master ref available` });
|
|
573
571
|
}
|
|
574
572
|
/**
|
|
@@ -586,6 +584,12 @@ var RepositoryManager = class {
|
|
|
586
584
|
await this.integrationFieldsClient.setupIntegrationFields(integrationFields);
|
|
587
585
|
profiler.done({ message: `Integration Fields setup` });
|
|
588
586
|
}
|
|
587
|
+
async waitForNewMasterRef(contentApi, previousMasterRef) {
|
|
588
|
+
await expect.poll(async () => contentApi.getMasterRef(), {
|
|
589
|
+
timeout: 1e4,
|
|
590
|
+
message: "Waiting for new master ref to be available"
|
|
591
|
+
}).not.toBe(previousMasterRef);
|
|
592
|
+
}
|
|
589
593
|
};
|
|
590
594
|
//#endregion
|
|
591
595
|
export { RepositoryManager };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.js","names":[],"sources":["../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\"\nimport type { DynamicCustomTypeModel, SharedSliceModel } from \"@prismicio/types-internal\"\nimport type { AxiosResponse } from \"axios\"\n\nimport type { AssetApiClient } from \"../clients/assetApi\"\nimport type { AuthenticationApiClient } from \"../clients/authenticationApi\"\nimport { ContentApiClient } from \"../clients/contentApi\"\nimport type {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n\tCoreApiDocumentData,\n\tCoreApiDocumentsPayload,\n\tCoreApiDocumentsResponse,\n\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 expect\n\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\ttimeout: 10_000,\n\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t})\n\t\t\t.not.toBe(masterRef)\n\n\t\tprofiler.done({\n\t\t\tmessage: `release '${id}' published and new master ref available`,\n\t\t})\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\n\t * @param id - The ID of the release to be deleted.\n\t */\n\tasync deleteRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(this.name, `app/releases/${id}/delete`, {})\n\n\t\tthis.failIfNot200(response, `Could not delete release with id ${id}`)\n\t\tprofiler.done({ message: `release '${id}' deleted` })\n\t}\n\n\t/**\n\t * Creates a preview for a repository.\n\t *\n\t * @param data - The data for creating the preview.\n\t */\n\tasync createPreview(data: Preview): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(this.name, `previews/new`, data)\n\n\t\tthis.failIfNot200(response, `Could not create preview ${data.name}`)\n\t\tprofiler.done({ message: `preview '${data.name}' created` })\n\n\t\treturn response.data\n\t}\n\n\t/**\n\t * Set the simulator URL (table of slices) for a repository.\n\t *\n\t * @param data - The simulator URL to set.\n\t */\n\tasync setSimulatorURL(simulatorURL: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst repository = await this.coreApiClient.getRepository()\n\t\tawait this.coreApiClient.updateRepository({\n\t\t\t...repository,\n\t\t\tsimulator_url: simulatorURL,\n\t\t})\n\n\t\tprofiler.done({\n\t\t\tmessage: `simulator preview '${simulatorURL}' created`,\n\t\t})\n\t}\n\n\t/**\n\t * Deletes a preview from a repository.\n\t *\n\t * @param id - The ID of the preview to be deleted.\n\t */\n\tasync deletePreview(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(this.name, `previews/delete/${id}`, {})\n\n\t\tthis.failIfNot200(response, `Could not delete preview with id ${id}`)\n\t\tprofiler.done({ message: `preview '${id}' deleted` })\n\t}\n\n\t/**\n\t * Create a webhook.\n\t *\n\t * @returns A Promise that resolves with the webhook id.\n\t */\n\tasync createWebhook(\n\t\tname: string,\n\t\turl: string,\n\t\tsecret: string,\n\t\ttriggers: {\n\t\t\tdocumentsPublished?: boolean\n\t\t\tdocumentsUnpublished?: boolean\n\t\t\treleasesCreated?: boolean\n\t\t\treleasesUpdated?: boolean\n\t\t\ttagsCreated?: boolean\n\t\t\ttagsDeleted?: boolean\n\t\t},\n\t\tactive: boolean,\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(this.name, \"app/settings/webhooks/create\", {\n\t\t\tname,\n\t\t\turl,\n\t\t\tsecret,\n\t\t\tactive: active ? \"on\" : \"off\",\n\t\t\t...triggers,\n\t\t})\n\t\tthis.failIfNot200(response, `Could not create webhook ${name}`)\n\t\tprofiler.done({ message: `webhook '${name}' created` })\n\n\t\treturn response.data.created\n\t}\n\n\t/**\n\t * Deletes a webhook.\n\t *\n\t * @param id - The webhook ID.\n\t */\n\tasync deleteWebhook(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/webhooks/${id}/delete`,\n\t\t\t{},\n\t\t)\n\n\t\tthis.failIfNot200(response, `Could not delete webhook with id ${id}`)\n\t\tprofiler.done({ message: `webhook '${id}' deleted` })\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes\n\t */\n\tasync createCustomTypes(customTypes: DynamicCustomTypeModel[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes)\n\t}\n\n\tasync deleteCustomType(customTypeId: string): Promise<void> {\n\t\tawait this.customTypesApiClient.deleteCustomType(customTypeId)\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices\n\t */\n\tasync createSlices(slices: SharedSliceModel[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createSlices(slices)\n\t}\n\n\t/**\n\t * Create an access token to query private items of the Content api.\n\t *\n\t * @param appName - Mandatory authorized application name\n\t * @param tokenScope - Access token scope. Use \"master\" to when your content api is fully private\n\t * or \"master+releases\" to access private releases\n\t */\n\tasync createContentAPIToken(\n\t\tappName: string,\n\t\ttokenScope: \"master\" | \"master+releases\" = \"master\",\n\t): Promise<string> {\n\t\tconst profiler = logger.startTimer()\n\t\ttype AuthorizedAppResponse = {\n\t\t\tid: string\n\t\t\tname: string\n\t\t\twroom_auths: { token: string; scope: \"master\" | \"master+releases\" }[]\n\t\t}\n\t\tconst existingApps: AxiosResponse<AuthorizedAppResponse[]> = await this.wroomClient.get(\n\t\t\tthis.name,\n\t\t\t\"settings/security/contentapi\",\n\t\t)\n\n\t\tthis.failIfNot200(\n\t\t\texistingApps,\n\t\t\t`Could not get status of existing applications to generate a content api token`,\n\t\t)\n\t\tlet app = existingApps.data.find(({ name, wroom_auths }) => {\n\t\t\treturn name === appName && wroom_auths.length > 0\n\t\t})\n\n\t\tif (!app) {\n\t\t\tconst response: AxiosResponse<AuthorizedAppResponse> = await this.wroomClient.post(\n\t\t\t\tthis.name,\n\t\t\t\t\"settings/security/oauthapp\",\n\t\t\t\t{\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tthis.failIfNot200(response, `Could not create content api app ${appName}`)\n\t\t\tapp = response.data\n\t\t}\n\n\t\tlet tokenInfo = app.wroom_auths.find(({ scope }) => scope === tokenScope)\n\t\tif (!tokenInfo) {\n\t\t\tconst response = await this.wroomClient.post(this.name, \"settings/security/authorizations\", {\n\t\t\t\tapp: app.id,\n\t\t\t\tscope: tokenScope,\n\t\t\t})\n\t\t\tthis.failIfNot200(\n\t\t\t\tresponse,\n\t\t\t\t`Could not create content api access token for app ${appName} with scope ${tokenScope}`,\n\t\t\t)\n\t\t\ttokenInfo = response.data\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `content api access token for app '${appName}' created`,\n\t\t})\n\n\t\tif (!tokenInfo?.token) {\n\t\t\tthrow `Could not create content api access token for app ${appName} with scope ${tokenScope}`\n\t\t}\n\n\t\treturn tokenInfo.token\n\t}\n\n\t/** Create a permanent access token to authenticate to Prismic public apis. */\n\tasync createPermanentAccessToken(): Promise<string> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst token = await this.authApiClient.getMachine2MachineToken(this.name)\n\n\t\tprofiler.done({\n\t\t\tmessage: `machine2machine token created`,\n\t\t})\n\n\t\treturn token\n\t}\n\n\t/**\n\t * Toggle the Role per Locale workflow\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleRolePerLocal(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.toggleRolePerLocal({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t})\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Role per local for ${this.name}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Role per local ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t})\n\t}\n\n\t/**\n\t * Toggle the Custom Roles workflow\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleCustomRoles(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.toggleCustomRoles({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t})\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Custom Roles for ${this.name}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Custom Roles ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t})\n\t}\n\n\t/**\n\t * Toggle the Integration Fields feature\n\t *\n\t * @param enabled - The feature new status\n\t */\n\tasync toggleIntegrationFields(enabled: boolean): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.toggleIntegrationFields({\n\t\t\trepository: this.name,\n\t\t\tenabled: enabled,\n\t\t})\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not ${enabled ? \"enable\" : \"disable\"} Integration Fields for ${this.name}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Integration Fields ${enabled ? \"enabled\" : \"disabled\"}`,\n\t\t})\n\t}\n\n\t/**\n\t * Change the Repository Plan\n\t *\n\t * @param {string} newPlanId - The Id of the new Plan to apply\n\t */\n\tasync changePlan(newPlanId: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.changePlan({\n\t\t\trepository: this.name,\n\t\t\tnewPlanId: newPlanId,\n\t\t\tbypassManualBilling: true, // For now the library does not support Stripe features\n\t\t})\n\n\t\tthis.failIfNot200(response, \"Could not change the Repository Plan\")\n\t\tprofiler.done({\n\t\t\tmessage: `Repository Plan changed to ${newPlanId}`,\n\t\t})\n\t}\n\n\t/**\n\t * Add a new user to the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync addUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.addUserToRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t})\n\n\t\tconst { data, status } = response\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 409 && JSON.stringify(data).includes(\"already a member of the repo\"))\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response)\n\t\t\tthrow new Error(`Could not add a new user ${email} to the repository`)\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was added to the repository`,\n\t\t})\n\t}\n\n\t/**\n\t * Remove a user from the repository\n\t *\n\t * @param {string} email - The email of the user\n\t */\n\tasync removeUser(email: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response = await this.manageV2Client.removeUserFromRepository({\n\t\t\trepository: this.name,\n\t\t\temail: email,\n\t\t})\n\n\t\tthis.failIfNot200(response, `Could not remove the user ${email} from the repository`)\n\t\tprofiler.done({\n\t\t\tmessage: `User ${email} was removed from the repository`,\n\t\t})\n\t}\n\n\t/**\n\t * Update the role of a user in a repository\n\t *\n\t * @param {string} email - The email of the user\n\t * @param {string | Record<string, string>} role - The new Role of the user, either a string for\n\t * basic workflow or an object such as `{ \"lang_id\": \"Writer\" }`\n\t *\n\t * Example of roles are\n\t *\n\t * - Administrator\n\t * - Writer\n\t * - Contributor\n\t * - Manager (publisher)\n\t */\n\tasync updateUserRole(email: string, role: string | Record<string, string>): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst response =\n\t\t\ttypeof role === \"string\"\n\t\t\t\t? await this.wroomClient.updateRole(this.name, email, role)\n\t\t\t\t: await this.wroomClient.updateRolePerLocal(this.name, email, role)\n\n\t\tthis.failIfNot200(\n\t\t\tresponse,\n\t\t\t`Could not update the ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} of the user ${email}`,\n\t\t)\n\t\tprofiler.done({\n\t\t\tmessage: `Updated User's ${\n\t\t\t\ttypeof role === \"string\" ? \"role\" : \"rolePerLocal\"\n\t\t\t} for user ${email}`,\n\t\t})\n\t}\n\n\t/**\n\t * Creates a document using the core api. If the Core api format is too specific, use the\n\t * migration api client to create a document with the MigrationApiClient. See the\n\t * `getMigrationApiClient()` method.\n\t *\n\t * @example\n\t * \tTo create a document by converting it from the Page Builder to\n\t * \tCore api format\n\t *\n\t * \t```js\n\t * \timport { DocumentLegacy, UIDContentType } from '@prismicio/types-internal/lib/content';\n\t *\n\t * \tconst document = {\n\t * \ttitle: 'A new document',\n\t * \tcustom_type_id: 'home-page',\n\t * \tlocale: 'en-gb',\n\t * \tintegration_field_ids: [],\n\t * \ttags: [],\n\t * \tdata: DocumentLegacy.encode({\n\t * \tuid: {\n\t * \t__TYPE__: UIDContentType,\n\t * \tvalue: 'home-page',\n\t * \t},\n\t * \t})\n\t * \t}\n\t * \tawait repository.createDocument(document, 'published');\n\t * \t* ```\n\t * \t```\n\t *\n\t * \t@returns\n\t *\n\t * \t@param document - in the core api format.\n\t *\n\t * \t@param status - status of the document, if published, the function will\n\t * \twait for a new content api master ref to be created\n\t */\n\tasync createDocument(\n\t\tdocument: CoreApiDocumentCreationPayload,\n\t\tstatus: \"draft\" | \"published\",\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst profiler = logger.startTimer()\n\t\tconst result = await this.coreApiClient.createDraft(document)\n\n\t\tlet message = `Document created with id '${result.id}'`\n\t\tif (status === \"published\") {\n\t\t\tconst contentApi = this.getContentApiClient()\n\t\t\tconst masterRef = await contentApi.getMasterRef()\n\t\t\tawait this.coreApiClient.publishDraft(result.id)\n\t\t\tawait expect\n\t\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\t\ttimeout: 10_000,\n\t\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t\t})\n\t\t\t\t.not.toBe(masterRef)\n\t\t\tmessage += \", status 'published' and new master ref available\"\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage,\n\t\t})\n\n\t\treturn result\n\t}\n\n\t/**\n\t * 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.waitForMasterRef - When publishing, wait for a new content api master ref to be\n\t * available (default true). Set to false to return without waiting for the projection.\n\t * @returns The updated document, including the new version's id.\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: { waitForMasterRef?: boolean } = {},\n\t): Promise<CoreApiDocumentCreationResponse> {\n\t\tconst { waitForMasterRef = true } = options\n\t\tconst profiler = logger.startTimer()\n\t\tconst result = await this.coreApiClient.updateDraft(documentId, data, baseVersionId)\n\n\t\tlet message = `Document '${documentId}' updated`\n\t\tif (status === \"published\") {\n\t\t\tif (waitForMasterRef) {\n\t\t\t\tconst contentApi = this.getContentApiClient()\n\t\t\t\tconst masterRef = await contentApi.getMasterRef()\n\t\t\t\tawait this.coreApiClient.publishDraft(documentId)\n\t\t\t\tawait expect\n\t\t\t\t\t.poll(async () => contentApi.getMasterRef(), {\n\t\t\t\t\t\ttimeout: 10_000,\n\t\t\t\t\t\tmessage: \"Waiting for new master ref to be available\",\n\t\t\t\t\t})\n\t\t\t\t\t.not.toBe(masterRef)\n\t\t\t\tmessage += \", status 'published' and new master ref available\"\n\t\t\t} else {\n\t\t\t\tawait this.coreApiClient.publishDraft(documentId)\n\t\t\t\tmessage += \", status 'published'\"\n\t\t\t}\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 * 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.waitForMasterRef - Wait for a new content api master ref to be available\n\t * (default true). Set to false to return without waiting for the projection.\n\t */\n\tasync unpublishDocument(\n\t\tdocumentId: string,\n\t\toptions: { waitForMasterRef?: boolean } = {},\n\t): Promise<void> {\n\t\tconst { waitForMasterRef = true } = options\n\t\tconst profiler = logger.startTimer()\n\n\t\tif (!waitForMasterRef) {\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 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: `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\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,gBAAgB,cAAc,IAAI;IACnE,IAAI,CAAC,QACJ,MAAM,KAAK,iBAAiB,OAAO,eAAe,QAAQ;SACpD,IAAI,OAAO,OAAO,OAAO,eAE/B,8BAA8B;GAEhC;GAEA,IAAI,OAAO,SAAS;IAEnB,MAAM,eAAe,OAAO,QAAQ,QAClC,OAAO,CAAC,UAAU,MAAM,aAAa,SAAS,OAAO,EAAE,CACzD;IACA,IAAI,aAAa,SAAS,GACzB,MAAM,KAAK,cAAc,YAAY;GAEvC;GAEA,IAAI,OAAO;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K,oBAAoB;EAC5C,MAAM,YAAY,MAAM,WAAW,aAAa;EAChD,MAAM,KAAK,cAAc,kBAAkB,UAAU;EACrD,MAAM,OACJ,KAAK,YAAY,WAAW,aAAa,GAAG;GAC5C,SAAS;GACT,SAAS;EACV,CAAC,CAAC,CACD,IAAI,KAAK,SAAS;EAEpB,SAAS,KAAK,EACb,SAAS,aAAa,WAAW,4CAClC,CAAC;CACF;;;;;;;CAQA,MAAM,gBAAgB,WAAiD;EACtE,OAAO,MAAM,KAAK,cAAc,gBAAgB,SAAS;CAC1D;CAEA,MAAM,uBAAuB,mBAA4D;EACxF,MAAM,WAAW,OAAO,WAAW;EAEnC,IAAI,CAAC,KAAK,yBACT,MAAM,IAAI,MACT,yGACD;EAGD,MAAM,KAAK,wBAAwB,uBAAuB,iBAAiB;EAC3E,SAAS,KAAK,EACb,SAAS,2BACV,CAAC;CACF;AACD"}
|
|
1
|
+
{"version":3,"file":"repository.js","names":[],"sources":["../../src/managers/repository.ts"],"sourcesContent":["import { expect } from \"@playwright/test\"\nimport type { DynamicCustomTypeModel, SharedSliceModel } from \"@prismicio/types-internal\"\nimport type { AxiosResponse } from \"axios\"\n\nimport type { AssetApiClient } from \"../clients/assetApi\"\nimport type { AuthenticationApiClient } from \"../clients/authenticationApi\"\nimport { ContentApiClient } from \"../clients/contentApi\"\nimport type {\n\tCoreApiClient,\n\tCoreApiDocumentCreationPayload,\n\tCoreApiDocumentCreationResponse,\n\tCoreApiDocumentData,\n\tCoreApiDocumentsPayload,\n\tCoreApiDocumentsResponse,\n\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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ryManager {
|
|
|
320
320
|
const contentApi = this.getContentApiClient()
|
|
321
321
|
const masterRef = await contentApi.getMasterRef()
|
|
322
322
|
await this.coreApiClient.publishRelease(id)
|
|
323
|
-
await
|
|
324
|
-
.poll(async () => contentApi.getMasterRef(), {
|
|
325
|
-
timeout: 10_000,
|
|
326
|
-
message: "Waiting for new master ref to be available",
|
|
327
|
-
})
|
|
328
|
-
.not.toBe(masterRef)
|
|
323
|
+
await this.waitForNewMasterRef(contentApi, masterRef)
|
|
329
324
|
|
|
330
325
|
profiler.done({
|
|
331
326
|
message: `release '${id}' published and new master ref available`,
|
|
@@ -763,12 +758,7 @@ export class RepositoryManager {
|
|
|
763
758
|
const contentApi = this.getContentApiClient()
|
|
764
759
|
const masterRef = await contentApi.getMasterRef()
|
|
765
760
|
await this.coreApiClient.publishDraft(result.id)
|
|
766
|
-
await
|
|
767
|
-
.poll(async () => contentApi.getMasterRef(), {
|
|
768
|
-
timeout: 10_000,
|
|
769
|
-
message: "Waiting for new master ref to be available",
|
|
770
|
-
})
|
|
771
|
-
.not.toBe(masterRef)
|
|
761
|
+
await this.waitForNewMasterRef(contentApi, masterRef)
|
|
772
762
|
message += ", status 'published' and new master ref available"
|
|
773
763
|
}
|
|
774
764
|
profiler.done({
|
|
@@ -789,44 +779,54 @@ export class RepositoryManager {
|
|
|
789
779
|
* @param status - Status of the new version, if published, the function will wait for a new
|
|
790
780
|
* content api master ref to be created.
|
|
791
781
|
* @param options - Additional options.
|
|
792
|
-
* @param options.
|
|
793
|
-
* available (default
|
|
794
|
-
*
|
|
782
|
+
* @param options.skipMasterRefWait - When publishing, skip waiting for a new content api master
|
|
783
|
+
* ref to be available (default false). Set to true to return without waiting for the
|
|
784
|
+
* projection.
|
|
785
|
+
* @returns The updated document, including the new version's id. When publishing, the document is
|
|
786
|
+
* retrieved again after publication so that the returned versions reflect the published state.
|
|
795
787
|
*/
|
|
796
788
|
async updateDocument(
|
|
797
789
|
documentId: string,
|
|
798
790
|
data: CoreApiDocumentUpdatePayload,
|
|
799
791
|
baseVersionId: string,
|
|
800
792
|
status: "draft" | "published",
|
|
801
|
-
options: {
|
|
793
|
+
options: { skipMasterRefWait?: boolean } = {},
|
|
802
794
|
): Promise<CoreApiDocumentCreationResponse> {
|
|
803
|
-
const {
|
|
795
|
+
const { skipMasterRefWait = false } = options
|
|
804
796
|
const profiler = logger.startTimer()
|
|
805
|
-
const
|
|
797
|
+
const draft = await this.coreApiClient.updateDraft(documentId, data, baseVersionId)
|
|
806
798
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
799
|
+
if (status === "draft") {
|
|
800
|
+
profiler.done({ message: `Document '${documentId}' updated` })
|
|
801
|
+
|
|
802
|
+
return draft
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
let message = `Document '${documentId}' updated, status 'published'`
|
|
806
|
+
if (skipMasterRefWait) {
|
|
807
|
+
await this.coreApiClient.publishDraft(documentId)
|
|
808
|
+
} else {
|
|
809
|
+
const contentApi = this.getContentApiClient()
|
|
810
|
+
const masterRef = await contentApi.getMasterRef()
|
|
811
|
+
await this.coreApiClient.publishDraft(documentId)
|
|
812
|
+
await this.waitForNewMasterRef(contentApi, masterRef)
|
|
813
|
+
message += " and new master ref available"
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
const { results } = await this.coreApiClient.getDocuments({
|
|
817
|
+
documentIds: [documentId],
|
|
818
|
+
limit: 1,
|
|
819
|
+
})
|
|
820
|
+
const publishedDocument = results[0]
|
|
821
|
+
if (!publishedDocument) {
|
|
822
|
+
throw new Error(`Could not retrieve document '${documentId}' after publication`)
|
|
824
823
|
}
|
|
824
|
+
|
|
825
825
|
profiler.done({
|
|
826
826
|
message,
|
|
827
827
|
})
|
|
828
828
|
|
|
829
|
-
return
|
|
829
|
+
return publishedDocument
|
|
830
830
|
}
|
|
831
831
|
|
|
832
832
|
/**
|
|
@@ -835,17 +835,17 @@ export class RepositoryManager {
|
|
|
835
835
|
*
|
|
836
836
|
* @param documentId - The id of the document to unpublish.
|
|
837
837
|
* @param options - Additional options.
|
|
838
|
-
* @param options.
|
|
839
|
-
* (default
|
|
838
|
+
* @param options.skipMasterRefWait - Skip waiting for a new content api master ref to be
|
|
839
|
+
* available (default false). Set to true to return without waiting for the projection.
|
|
840
840
|
*/
|
|
841
841
|
async unpublishDocument(
|
|
842
842
|
documentId: string,
|
|
843
|
-
options: {
|
|
843
|
+
options: { skipMasterRefWait?: boolean } = {},
|
|
844
844
|
): Promise<void> {
|
|
845
|
-
const {
|
|
845
|
+
const { skipMasterRefWait = false } = options
|
|
846
846
|
const profiler = logger.startTimer()
|
|
847
847
|
|
|
848
|
-
if (
|
|
848
|
+
if (skipMasterRefWait) {
|
|
849
849
|
await this.coreApiClient.unpublishDocument(documentId)
|
|
850
850
|
profiler.done({ message: `Document '${documentId}' unpublished` })
|
|
851
851
|
|
|
@@ -855,12 +855,7 @@ export class RepositoryManager {
|
|
|
855
855
|
const contentApi = this.getContentApiClient()
|
|
856
856
|
const masterRef = await contentApi.getMasterRef()
|
|
857
857
|
await this.coreApiClient.unpublishDocument(documentId)
|
|
858
|
-
await
|
|
859
|
-
.poll(async () => contentApi.getMasterRef(), {
|
|
860
|
-
timeout: 10_000,
|
|
861
|
-
message: "Waiting for new master ref to be available",
|
|
862
|
-
})
|
|
863
|
-
.not.toBe(masterRef)
|
|
858
|
+
await this.waitForNewMasterRef(contentApi, masterRef)
|
|
864
859
|
|
|
865
860
|
profiler.done({
|
|
866
861
|
message: `Document '${documentId}' unpublished and new master ref available`,
|
|
@@ -891,6 +886,18 @@ export class RepositoryManager {
|
|
|
891
886
|
message: `Integration Fields setup`,
|
|
892
887
|
})
|
|
893
888
|
}
|
|
889
|
+
|
|
890
|
+
private async waitForNewMasterRef(
|
|
891
|
+
contentApi: ContentApiClient,
|
|
892
|
+
previousMasterRef: string,
|
|
893
|
+
): Promise<void> {
|
|
894
|
+
await expect
|
|
895
|
+
.poll(async () => contentApi.getMasterRef(), {
|
|
896
|
+
timeout: 10_000,
|
|
897
|
+
message: "Waiting for new master ref to be available",
|
|
898
|
+
})
|
|
899
|
+
.not.toBe(previousMasterRef)
|
|
900
|
+
}
|
|
894
901
|
}
|
|
895
902
|
|
|
896
903
|
export type RepositoryConfig = {
|