@prismicio/e2e-tests-utils 2.0.0-alpha.1 → 2.0.0-alpha.10
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/apiClient.cjs +4 -1
- package/dist/clients/apiClient.cjs.map +1 -1
- package/dist/clients/apiClient.js +4 -1
- package/dist/clients/apiClient.js.map +1 -1
- package/dist/clients/assetApi.cjs.map +1 -1
- package/dist/clients/assetApi.d.ts +1 -0
- package/dist/clients/assetApi.js.map +1 -1
- package/dist/clients/authenticationApi.cjs +7 -11
- package/dist/clients/authenticationApi.cjs.map +1 -1
- package/dist/clients/authenticationApi.js +7 -11
- package/dist/clients/authenticationApi.js.map +1 -1
- package/dist/clients/contentApi.cjs +4 -1
- package/dist/clients/contentApi.cjs.map +1 -1
- package/dist/clients/contentApi.js +4 -1
- package/dist/clients/contentApi.js.map +1 -1
- package/dist/clients/coreApi.cjs.map +1 -1
- package/dist/clients/coreApi.js.map +1 -1
- package/dist/clients/customTypesApi.cjs.map +1 -1
- package/dist/clients/customTypesApi.js.map +1 -1
- package/dist/clients/manageV2.cjs +22 -6
- package/dist/clients/manageV2.cjs.map +1 -1
- package/dist/clients/manageV2.d.ts +16 -6
- package/dist/clients/manageV2.js +22 -6
- package/dist/clients/manageV2.js.map +1 -1
- package/dist/clients/migrationApi.cjs.map +1 -1
- package/dist/clients/migrationApi.js.map +1 -1
- package/dist/clients/wroom.cjs +15 -18
- package/dist/clients/wroom.cjs.map +1 -1
- package/dist/clients/wroom.d.ts +6 -6
- package/dist/clients/wroom.js +15 -18
- package/dist/clients/wroom.js.map +1 -1
- package/dist/managers/repositories.cjs +5 -2
- package/dist/managers/repositories.cjs.map +1 -1
- package/dist/managers/repositories.js +5 -2
- package/dist/managers/repositories.js.map +1 -1
- package/dist/managers/repository.cjs +30 -9
- package/dist/managers/repository.cjs.map +1 -1
- package/dist/managers/repository.d.ts +14 -8
- package/dist/managers/repository.js +30 -9
- package/dist/managers/repository.js.map +1 -1
- package/dist/utils/authentication.cjs +38 -0
- package/dist/utils/authentication.cjs.map +1 -0
- package/dist/utils/authentication.d.ts +4 -0
- package/dist/utils/authentication.js +38 -0
- package/dist/utils/authentication.js.map +1 -0
- package/dist/utils/cookies.cjs.map +1 -1
- package/dist/utils/cookies.js.map +1 -1
- package/dist/utils/envVariableManager.cjs +4 -1
- package/dist/utils/envVariableManager.cjs.map +1 -1
- package/dist/utils/envVariableManager.js +4 -1
- package/dist/utils/envVariableManager.js.map +1 -1
- package/dist/utils/log.cjs.map +1 -1
- package/dist/utils/log.js +1 -1
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/urls.cjs.map +1 -1
- package/dist/utils/urls.js.map +1 -1
- package/package.json +3 -2
- package/src/clients/authenticationApi.ts +7 -10
- package/src/clients/manageV2.ts +21 -5
- package/src/clients/wroom.ts +15 -18
- package/src/managers/repositories.ts +1 -1
- package/src/managers/repository.ts +36 -8
- package/src/utils/authentication.ts +58 -0
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
-
var __publicField = (obj, key, value) =>
|
|
4
|
+
var __publicField = (obj, key, value) => {
|
|
5
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
+
return value;
|
|
7
|
+
};
|
|
5
8
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
9
|
const test = require("@playwright/test");
|
|
7
10
|
const urls = require("../utils/urls.cjs");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiClient.cjs","sources":["../../../src/clients/apiClient.ts"],"sourcesContent":["import { APIRequestContext, request } from \"@playwright/test\";\n\nimport { appendTrailingSlash } from \"../utils/urls\";\n\n/**\n * The authentication token. Can be a string or a function that returns a\n * promise resolving to the token.\n */\nexport type AuthServerToken = string | (() => Promise<string>);\n\n/**\n * Abstract class for Prismic api clients that use the Prismic authentication\n * server. This class takes care or creating the Playwright context with the\n * necessary authorization headers.\n *\n * This class performs requests with Playwright instead of a library like Axios\n * which has the advantage of tracing all the network details in the Playwright\n * reports making test failures investigation easier for projects that use\n * Playwright.\n */\nexport abstract class AuthenticatedApiClient {\n\tprivate _context?: APIRequestContext;\n\n\tconstructor(\n\t\tprivate readonly baseURL: string,\n\t\tprivate readonly token: AuthServerToken,\n\t\tprivate readonly headers?: { [key: string]: string } | undefined,\n\t) {}\n\n\t/**\n\t * Returns a Playwright ApiRequestContext instance with the necessary\n\t * authorization headers.\n\t */\n\tprotected async getContext(): Promise<APIRequestContext> {\n\t\tif (!this._context) {\n\t\t\tconst token =\n\t\t\t\ttypeof this.token === \"string\" ? this.token : await this.token();\n\n\t\t\tthis._context = await request.newContext({\n\t\t\t\tbaseURL: appendTrailingSlash(this.baseURL),\n\t\t\t\textraHTTPHeaders: {\n\t\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t\t...this.headers,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\treturn this._context;\n\t}\n}\n"],"names":["request","appendTrailingSlash"],"mappings":"
|
|
1
|
+
{"version":3,"file":"apiClient.cjs","sources":["../../../src/clients/apiClient.ts"],"sourcesContent":["import { APIRequestContext, request } from \"@playwright/test\";\n\nimport { appendTrailingSlash } from \"../utils/urls\";\n\n/**\n * The authentication token. Can be a string or a function that returns a\n * promise resolving to the token.\n */\nexport type AuthServerToken = string | (() => Promise<string>);\n\n/**\n * Abstract class for Prismic api clients that use the Prismic authentication\n * server. This class takes care or creating the Playwright context with the\n * necessary authorization headers.\n *\n * This class performs requests with Playwright instead of a library like Axios\n * which has the advantage of tracing all the network details in the Playwright\n * reports making test failures investigation easier for projects that use\n * Playwright.\n */\nexport abstract class AuthenticatedApiClient {\n\tprivate _context?: APIRequestContext;\n\n\tconstructor(\n\t\tprivate readonly baseURL: string,\n\t\tprivate readonly token: AuthServerToken,\n\t\tprivate readonly headers?: { [key: string]: string } | undefined,\n\t) {}\n\n\t/**\n\t * Returns a Playwright ApiRequestContext instance with the necessary\n\t * authorization headers.\n\t */\n\tprotected async getContext(): Promise<APIRequestContext> {\n\t\tif (!this._context) {\n\t\t\tconst token =\n\t\t\t\ttypeof this.token === \"string\" ? this.token : await this.token();\n\n\t\t\tthis._context = await request.newContext({\n\t\t\t\tbaseURL: appendTrailingSlash(this.baseURL),\n\t\t\t\textraHTTPHeaders: {\n\t\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t\t...this.headers,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\treturn this._context;\n\t}\n}\n"],"names":["request","appendTrailingSlash"],"mappings":";;;;;;;;;;MAoBsB,uBAAsB;AAAA,EAG3C,YACkB,SACA,OACA,SAA+C;AAF/C;AACA;AACA;AALV;AAGU,SAAO,UAAP;AACA,SAAK,QAAL;AACA,SAAO,UAAP;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,MAAM,aAAU;AACrB,QAAA,CAAC,KAAK,UAAU;AACb,YAAA,QACL,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ,MAAM,KAAK;AAErD,WAAA,WAAW,MAAMA,KAAA,QAAQ,WAAW;AAAA,QACxC,SAASC,KAAAA,oBAAoB,KAAK,OAAO;AAAA,QACzC,kBAAkB;AAAA,UACjB,eAAe,UAAU,KAAK;AAAA,UAC9B,GAAG,KAAK;AAAA,QACR;AAAA,MAAA,CACD;AAAA,IACF;AAEA,WAAO,KAAK;AAAA,EACb;AACA;;"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) =>
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
4
7
|
import { request } from "@playwright/test";
|
|
5
8
|
import { appendTrailingSlash } from "../utils/urls.js";
|
|
6
9
|
class AuthenticatedApiClient {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiClient.js","sources":["../../../src/clients/apiClient.ts"],"sourcesContent":["import { APIRequestContext, request } from \"@playwright/test\";\n\nimport { appendTrailingSlash } from \"../utils/urls\";\n\n/**\n * The authentication token. Can be a string or a function that returns a\n * promise resolving to the token.\n */\nexport type AuthServerToken = string | (() => Promise<string>);\n\n/**\n * Abstract class for Prismic api clients that use the Prismic authentication\n * server. This class takes care or creating the Playwright context with the\n * necessary authorization headers.\n *\n * This class performs requests with Playwright instead of a library like Axios\n * which has the advantage of tracing all the network details in the Playwright\n * reports making test failures investigation easier for projects that use\n * Playwright.\n */\nexport abstract class AuthenticatedApiClient {\n\tprivate _context?: APIRequestContext;\n\n\tconstructor(\n\t\tprivate readonly baseURL: string,\n\t\tprivate readonly token: AuthServerToken,\n\t\tprivate readonly headers?: { [key: string]: string } | undefined,\n\t) {}\n\n\t/**\n\t * Returns a Playwright ApiRequestContext instance with the necessary\n\t * authorization headers.\n\t */\n\tprotected async getContext(): Promise<APIRequestContext> {\n\t\tif (!this._context) {\n\t\t\tconst token =\n\t\t\t\ttypeof this.token === \"string\" ? this.token : await this.token();\n\n\t\t\tthis._context = await request.newContext({\n\t\t\t\tbaseURL: appendTrailingSlash(this.baseURL),\n\t\t\t\textraHTTPHeaders: {\n\t\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t\t...this.headers,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\treturn this._context;\n\t}\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apiClient.js","sources":["../../../src/clients/apiClient.ts"],"sourcesContent":["import { APIRequestContext, request } from \"@playwright/test\";\n\nimport { appendTrailingSlash } from \"../utils/urls\";\n\n/**\n * The authentication token. Can be a string or a function that returns a\n * promise resolving to the token.\n */\nexport type AuthServerToken = string | (() => Promise<string>);\n\n/**\n * Abstract class for Prismic api clients that use the Prismic authentication\n * server. This class takes care or creating the Playwright context with the\n * necessary authorization headers.\n *\n * This class performs requests with Playwright instead of a library like Axios\n * which has the advantage of tracing all the network details in the Playwright\n * reports making test failures investigation easier for projects that use\n * Playwright.\n */\nexport abstract class AuthenticatedApiClient {\n\tprivate _context?: APIRequestContext;\n\n\tconstructor(\n\t\tprivate readonly baseURL: string,\n\t\tprivate readonly token: AuthServerToken,\n\t\tprivate readonly headers?: { [key: string]: string } | undefined,\n\t) {}\n\n\t/**\n\t * Returns a Playwright ApiRequestContext instance with the necessary\n\t * authorization headers.\n\t */\n\tprotected async getContext(): Promise<APIRequestContext> {\n\t\tif (!this._context) {\n\t\t\tconst token =\n\t\t\t\ttypeof this.token === \"string\" ? this.token : await this.token();\n\n\t\t\tthis._context = await request.newContext({\n\t\t\t\tbaseURL: appendTrailingSlash(this.baseURL),\n\t\t\t\textraHTTPHeaders: {\n\t\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t\t...this.headers,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\treturn this._context;\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;MAoBsB,uBAAsB;AAAA,EAG3C,YACkB,SACA,OACA,SAA+C;AAF/C;AACA;AACA;AALV;AAGU,SAAO,UAAP;AACA,SAAK,QAAL;AACA,SAAO,UAAP;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,MAAM,aAAU;AACrB,QAAA,CAAC,KAAK,UAAU;AACb,YAAA,QACL,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ,MAAM,KAAK;AAErD,WAAA,WAAW,MAAM,QAAQ,WAAW;AAAA,QACxC,SAAS,oBAAoB,KAAK,OAAO;AAAA,QACzC,kBAAkB;AAAA,UACjB,eAAe,UAAU,KAAK;AAAA,UAC9B,GAAG,KAAK;AAAA,QACR;AAAA,MAAA,CACD;AAAA,IACF;AAEA,WAAO,KAAK;AAAA,EACb;AACA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetApi.cjs","sources":["../../../src/clients/assetApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\nexport interface AssetApiCreatePayload {\n\tname: string;\n\tmimeType: string;\n\tbuffer: Buffer;\n}\n\nexport interface AssetApiCreateResponse {\n\tid: string;\n\turl: string;\n\tfilename: string;\n\tsize: number;\n\twidth: number;\n\theight: number;\n\tlast_modified: number;\n\tkind: string;\n\textension: string;\n\tcreated_at: number;\n\tuploader_id: string;\n\ttags: string[];\n}\n\nexport class AssetApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new AssetApiClient(\"https://asset-api.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \trepository: \"my-repo-name\",\n\t * });\n\t * ```\n\t *\n\t * @param baseURL - The API base URL, such as https://asset-api.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.authToken}: API token generated from the auth service or a\n\t * function to fetch it when it's needed.\n\t * - {@link config.repository}: Repository name.\n\t */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { authToken: AuthServerToken; repository: string },\n\t) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository });\n\t}\n\n\t/**\n\t * Uploads an asset file to the server.\n\t *\n\t * @param data - The payload containing the file and filename.\n\t *\n\t * @returns The API response containing asset information.\n\t *\n\t * @throws An error if the upload fails.\n\t */\n\tasync createAsset(\n\t\tdata: AssetApiCreatePayload,\n\t): Promise<AssetApiCreateResponse> {\n\t\tconst context = await this.getContext();\n\n\t\tconst result = await context.post(\"assets\", {\n\t\t\tmultipart: { file: data },\n\t\t});\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not upload the asset with the asset API.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n}\n"],"names":["AuthenticatedApiClient","logPlaywrightApiResponse"],"mappings":";;;;AAyBM,MAAO,uBAAuBA,UAAAA,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBzD,YACC,SACA,QAA0D;AAE1D,UAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,YAAY;AAAA,
|
|
1
|
+
{"version":3,"file":"assetApi.cjs","sources":["../../../src/clients/assetApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\nexport interface AssetApiCreatePayload {\n\tname: string;\n\tmimeType: string;\n\tbuffer: Buffer;\n}\n\nexport interface AssetApiCreateResponse {\n\tid: string;\n\turl: string;\n\tfilename: string;\n\tsize: number;\n\twidth: number;\n\theight: number;\n\tlast_modified: number;\n\tkind: string;\n\textension: string;\n\tcreated_at: number;\n\tuploader_id: string;\n\ttags: string[];\n}\n\nexport class AssetApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new AssetApiClient(\"https://asset-api.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \trepository: \"my-repo-name\",\n\t * });\n\t * ```\n\t *\n\t * @param baseURL - The API base URL, such as https://asset-api.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.authToken}: API token generated from the auth service or a\n\t * function to fetch it when it's needed.\n\t * - {@link config.repository}: Repository name.\n\t */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { authToken: AuthServerToken; repository: string },\n\t) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository });\n\t}\n\n\t/**\n\t * Uploads an asset file to the server.\n\t *\n\t * @param data - The payload containing the file and filename.\n\t *\n\t * @returns The API response containing asset information.\n\t *\n\t * @throws An error if the upload fails.\n\t */\n\tasync createAsset(\n\t\tdata: AssetApiCreatePayload,\n\t): Promise<AssetApiCreateResponse> {\n\t\tconst context = await this.getContext();\n\n\t\tconst result = await context.post(\"assets\", {\n\t\t\tmultipart: { file: data },\n\t\t});\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not upload the asset with the asset API.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n}\n"],"names":["AuthenticatedApiClient","logPlaywrightApiResponse"],"mappings":";;;;AAyBM,MAAO,uBAAuBA,UAAAA,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBzD,YACC,SACA,QAA0D;AAE1D,UAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,YAAY;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,YACL,MAA2B;AAErB,UAAA,UAAU,MAAM,KAAK;AAE3B,UAAM,SAAS,MAAM,QAAQ,KAAK,UAAU;AAAA,MAC3C,WAAW,EAAE,MAAM,KAAM;AAAA,IAAA,CACzB;AAEG,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAMC,IAAAA,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,gDAAgD;AAAA,IACjE;AAEA,WAAO,OAAO;EACf;AACA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetApi.js","sources":["../../../src/clients/assetApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\nexport interface AssetApiCreatePayload {\n\tname: string;\n\tmimeType: string;\n\tbuffer: Buffer;\n}\n\nexport interface AssetApiCreateResponse {\n\tid: string;\n\turl: string;\n\tfilename: string;\n\tsize: number;\n\twidth: number;\n\theight: number;\n\tlast_modified: number;\n\tkind: string;\n\textension: string;\n\tcreated_at: number;\n\tuploader_id: string;\n\ttags: string[];\n}\n\nexport class AssetApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new AssetApiClient(\"https://asset-api.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \trepository: \"my-repo-name\",\n\t * });\n\t * ```\n\t *\n\t * @param baseURL - The API base URL, such as https://asset-api.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.authToken}: API token generated from the auth service or a\n\t * function to fetch it when it's needed.\n\t * - {@link config.repository}: Repository name.\n\t */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { authToken: AuthServerToken; repository: string },\n\t) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository });\n\t}\n\n\t/**\n\t * Uploads an asset file to the server.\n\t *\n\t * @param data - The payload containing the file and filename.\n\t *\n\t * @returns The API response containing asset information.\n\t *\n\t * @throws An error if the upload fails.\n\t */\n\tasync createAsset(\n\t\tdata: AssetApiCreatePayload,\n\t): Promise<AssetApiCreateResponse> {\n\t\tconst context = await this.getContext();\n\n\t\tconst result = await context.post(\"assets\", {\n\t\t\tmultipart: { file: data },\n\t\t});\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not upload the asset with the asset API.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n}\n"],"names":[],"mappings":";;AAyBM,MAAO,uBAAuB,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBzD,YACC,SACA,QAA0D;AAE1D,UAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,YAAY;AAAA,
|
|
1
|
+
{"version":3,"file":"assetApi.js","sources":["../../../src/clients/assetApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\nexport interface AssetApiCreatePayload {\n\tname: string;\n\tmimeType: string;\n\tbuffer: Buffer;\n}\n\nexport interface AssetApiCreateResponse {\n\tid: string;\n\turl: string;\n\tfilename: string;\n\tsize: number;\n\twidth: number;\n\theight: number;\n\tlast_modified: number;\n\tkind: string;\n\textension: string;\n\tcreated_at: number;\n\tuploader_id: string;\n\ttags: string[];\n}\n\nexport class AssetApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new AssetApiClient(\"https://asset-api.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \trepository: \"my-repo-name\",\n\t * });\n\t * ```\n\t *\n\t * @param baseURL - The API base URL, such as https://asset-api.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.authToken}: API token generated from the auth service or a\n\t * function to fetch it when it's needed.\n\t * - {@link config.repository}: Repository name.\n\t */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { authToken: AuthServerToken; repository: string },\n\t) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository });\n\t}\n\n\t/**\n\t * Uploads an asset file to the server.\n\t *\n\t * @param data - The payload containing the file and filename.\n\t *\n\t * @returns The API response containing asset information.\n\t *\n\t * @throws An error if the upload fails.\n\t */\n\tasync createAsset(\n\t\tdata: AssetApiCreatePayload,\n\t): Promise<AssetApiCreateResponse> {\n\t\tconst context = await this.getContext();\n\n\t\tconst result = await context.post(\"assets\", {\n\t\t\tmultipart: { file: data },\n\t\t});\n\n\t\tif (200 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not upload the asset with the asset API.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n}\n"],"names":[],"mappings":";;AAyBM,MAAO,uBAAuB,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBzD,YACC,SACA,QAA0D;AAE1D,UAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,YAAY;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,YACL,MAA2B;AAErB,UAAA,UAAU,MAAM,KAAK;AAE3B,UAAM,SAAS,MAAM,QAAQ,KAAK,UAAU;AAAA,MAC3C,WAAW,EAAE,MAAM,KAAM;AAAA,IAAA,CACzB;AAEG,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAM,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,gDAAgD;AAAA,IACjE;AAEA,WAAO,OAAO;EACf;AACA;"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
-
var __publicField = (obj, key, value) =>
|
|
4
|
+
var __publicField = (obj, key, value) => {
|
|
5
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
+
return value;
|
|
7
|
+
};
|
|
5
8
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
9
|
const test = require("@playwright/test");
|
|
10
|
+
const authentication = require("../utils/authentication.cjs");
|
|
7
11
|
const log = require("../utils/log.cjs");
|
|
8
12
|
class AuthenticationApiClient {
|
|
9
13
|
constructor(baseURL, auth) {
|
|
@@ -24,16 +28,8 @@ class AuthenticationApiClient {
|
|
|
24
28
|
}
|
|
25
29
|
async login() {
|
|
26
30
|
const profiler = log.logger.startTimer();
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
data: {
|
|
30
|
-
email: this.auth.email,
|
|
31
|
-
password: this.auth.password
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
const token = await result.text();
|
|
35
|
-
if (!result.ok() || !token) {
|
|
36
|
-
log.logPlaywrightApiResponse(result);
|
|
31
|
+
const { token } = await authentication.login(this.baseURL, this.auth.email, this.auth.password);
|
|
32
|
+
if (!token) {
|
|
37
33
|
throw new Error("Authentication failed, no token received.");
|
|
38
34
|
}
|
|
39
35
|
profiler.done({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticationApi.cjs","sources":["../../../src/clients/authenticationApi.ts"],"sourcesContent":["import { APIRequestContext, request } from \"@playwright/test\";\n\nimport { AuthConfig } from \"../types\";\n\nimport { logPlaywrightApiResponse, logger } from \"../utils/log\";\n\n/** Client for interacting with the authentication service to manage tokens */\nexport class AuthenticationApiClient {\n\tprivate authToken?: string;\n\tprivate _context?: APIRequestContext;\n\n\tconstructor(\n\t\tprivate readonly baseURL: string,\n\t\tprivate readonly auth: AuthConfig,\n\t) {}\n\n\tprivate async getContext(): Promise<APIRequestContext> {\n\t\tif (!this._context) {\n\t\t\tthis._context = await request.newContext({\n\t\t\t\tbaseURL: this.baseURL,\n\t\t\t});\n\t\t}\n\n\t\treturn this._context;\n\t}\n\n\tprivate async login(): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst
|
|
1
|
+
{"version":3,"file":"authenticationApi.cjs","sources":["../../../src/clients/authenticationApi.ts"],"sourcesContent":["import { APIRequestContext, request } from \"@playwright/test\";\n\nimport { AuthConfig } from \"../types\";\n\nimport { login as authenticateWithLambda } from \"../utils/authentication\";\nimport { logPlaywrightApiResponse, logger } from \"../utils/log\";\n\n/** Client for interacting with the authentication service to manage tokens */\nexport class AuthenticationApiClient {\n\tprivate authToken?: string;\n\tprivate _context?: APIRequestContext;\n\n\tconstructor(\n\t\tprivate readonly baseURL: string,\n\t\tprivate readonly auth: AuthConfig,\n\t) {}\n\n\tprivate async getContext(): Promise<APIRequestContext> {\n\t\tif (!this._context) {\n\t\t\tthis._context = await request.newContext({\n\t\t\t\tbaseURL: this.baseURL,\n\t\t\t});\n\t\t}\n\n\t\treturn this._context;\n\t}\n\n\tprivate async login(): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst { token } = await authenticateWithLambda(\n\t\t\tthis.baseURL,\n\t\t\tthis.auth.email,\n\t\t\tthis.auth.password,\n\t\t);\n\n\t\tif (!token) {\n\t\t\tthrow new Error(\"Authentication failed, no token received.\");\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `generated user token for ${this.auth.email} from auth service`,\n\t\t});\n\n\t\treturn token;\n\t}\n\n\t/** Return an api user token. Creates one if needed. */\n\tasync getToken(): Promise<string> {\n\t\tif (!this.authToken) {\n\t\t\tthis.authToken = await this.login();\n\t\t}\n\n\t\treturn this.authToken;\n\t}\n\n\t/** Return an api user token. Creates one if needed. */\n\tasync getMachine2MachineToken(repository: string): Promise<string> {\n\t\tif (!this.authToken) {\n\t\t\tthis.authToken = await this.login();\n\t\t}\n\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.get(\"machine2machine\", {\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${this.authToken}`,\n\t\t\t\trepository,\n\t\t\t},\n\t\t});\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\n\t\t\t\t\"Machine2Machine token generation failed, no token received.\",\n\t\t\t);\n\t\t}\n\t\tconst token = (await result.json()).token;\n\n\t\treturn token;\n\t}\n}\n"],"names":["request","logger","authenticateWithLambda","logPlaywrightApiResponse"],"mappings":";;;;;;;;;;;MAQa,wBAAuB;AAAA,EAInC,YACkB,SACA,MAAgB;AADhB;AACA;AALV;AACA;AAGU,SAAO,UAAP;AACA,SAAI,OAAJ;AAAA,EACf;AAAA,EAEK,MAAM,aAAU;AACnB,QAAA,CAAC,KAAK,UAAU;AACd,WAAA,WAAW,MAAMA,KAAA,QAAQ,WAAW;AAAA,QACxC,SAAS,KAAK;AAAA,MAAA,CACd;AAAA,IACF;AAEA,WAAO,KAAK;AAAA,EACb;AAAA,EAEQ,MAAM,QAAK;AACZ,UAAA,WAAWC,WAAO;AAExB,UAAM,EAAE,MAAU,IAAA,MAAMC,eACvB,MAAA,KAAK,SACL,KAAK,KAAK,OACV,KAAK,KAAK,QAAQ;AAGnB,QAAI,CAAC,OAAO;AACL,YAAA,IAAI,MAAM,2CAA2C;AAAA,IAC5D;AAEA,aAAS,KAAK;AAAA,MACb,SAAS,4BAA4B,KAAK,KAAK,KAAK;AAAA,IAAA,CACpD;AAEM,WAAA;AAAA,EACR;AAAA;AAAA,EAGA,MAAM,WAAQ;AACT,QAAA,CAAC,KAAK,WAAW;AACf,WAAA,YAAY,MAAM,KAAK;IAC7B;AAEA,WAAO,KAAK;AAAA,EACb;AAAA;AAAA,EAGA,MAAM,wBAAwB,YAAkB;AAC3C,QAAA,CAAC,KAAK,WAAW;AACf,WAAA,YAAY,MAAM,KAAK;IAC7B;AAEM,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,IAAI,mBAAmB;AAAA,MACnD,SAAS;AAAA,QACR,eAAe,UAAU,KAAK,SAAS;AAAA,QACvC;AAAA,MACA;AAAA,IAAA,CACD;AAEG,QAAA,CAAC,OAAO,MAAM;AACjBC,UAAA,yBAAyB,MAAM;AACzB,YAAA,IAAI,MACT,6DAA6D;AAAA,IAE/D;AACA,UAAM,SAAS,MAAM,OAAO,KAAA,GAAQ;AAE7B,WAAA;AAAA,EACR;AACA;;"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) =>
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
4
7
|
import { request } from "@playwright/test";
|
|
8
|
+
import { login } from "../utils/authentication.js";
|
|
5
9
|
import { logger, logPlaywrightApiResponse } from "../utils/log.js";
|
|
6
10
|
class AuthenticationApiClient {
|
|
7
11
|
constructor(baseURL, auth) {
|
|
@@ -22,16 +26,8 @@ class AuthenticationApiClient {
|
|
|
22
26
|
}
|
|
23
27
|
async login() {
|
|
24
28
|
const profiler = logger.startTimer();
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
data: {
|
|
28
|
-
email: this.auth.email,
|
|
29
|
-
password: this.auth.password
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
const token = await result.text();
|
|
33
|
-
if (!result.ok() || !token) {
|
|
34
|
-
logPlaywrightApiResponse(result);
|
|
29
|
+
const { token } = await login(this.baseURL, this.auth.email, this.auth.password);
|
|
30
|
+
if (!token) {
|
|
35
31
|
throw new Error("Authentication failed, no token received.");
|
|
36
32
|
}
|
|
37
33
|
profiler.done({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticationApi.js","sources":["../../../src/clients/authenticationApi.ts"],"sourcesContent":["import { APIRequestContext, request } from \"@playwright/test\";\n\nimport { AuthConfig } from \"../types\";\n\nimport { logPlaywrightApiResponse, logger } from \"../utils/log\";\n\n/** Client for interacting with the authentication service to manage tokens */\nexport class AuthenticationApiClient {\n\tprivate authToken?: string;\n\tprivate _context?: APIRequestContext;\n\n\tconstructor(\n\t\tprivate readonly baseURL: string,\n\t\tprivate readonly auth: AuthConfig,\n\t) {}\n\n\tprivate async getContext(): Promise<APIRequestContext> {\n\t\tif (!this._context) {\n\t\t\tthis._context = await request.newContext({\n\t\t\t\tbaseURL: this.baseURL,\n\t\t\t});\n\t\t}\n\n\t\treturn this._context;\n\t}\n\n\tprivate async login(): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst
|
|
1
|
+
{"version":3,"file":"authenticationApi.js","sources":["../../../src/clients/authenticationApi.ts"],"sourcesContent":["import { APIRequestContext, request } from \"@playwright/test\";\n\nimport { AuthConfig } from \"../types\";\n\nimport { login as authenticateWithLambda } from \"../utils/authentication\";\nimport { logPlaywrightApiResponse, logger } from \"../utils/log\";\n\n/** Client for interacting with the authentication service to manage tokens */\nexport class AuthenticationApiClient {\n\tprivate authToken?: string;\n\tprivate _context?: APIRequestContext;\n\n\tconstructor(\n\t\tprivate readonly baseURL: string,\n\t\tprivate readonly auth: AuthConfig,\n\t) {}\n\n\tprivate async getContext(): Promise<APIRequestContext> {\n\t\tif (!this._context) {\n\t\t\tthis._context = await request.newContext({\n\t\t\t\tbaseURL: this.baseURL,\n\t\t\t});\n\t\t}\n\n\t\treturn this._context;\n\t}\n\n\tprivate async login(): Promise<string> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst { token } = await authenticateWithLambda(\n\t\t\tthis.baseURL,\n\t\t\tthis.auth.email,\n\t\t\tthis.auth.password,\n\t\t);\n\n\t\tif (!token) {\n\t\t\tthrow new Error(\"Authentication failed, no token received.\");\n\t\t}\n\n\t\tprofiler.done({\n\t\t\tmessage: `generated user token for ${this.auth.email} from auth service`,\n\t\t});\n\n\t\treturn token;\n\t}\n\n\t/** Return an api user token. Creates one if needed. */\n\tasync getToken(): Promise<string> {\n\t\tif (!this.authToken) {\n\t\t\tthis.authToken = await this.login();\n\t\t}\n\n\t\treturn this.authToken;\n\t}\n\n\t/** Return an api user token. Creates one if needed. */\n\tasync getMachine2MachineToken(repository: string): Promise<string> {\n\t\tif (!this.authToken) {\n\t\t\tthis.authToken = await this.login();\n\t\t}\n\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.get(\"machine2machine\", {\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${this.authToken}`,\n\t\t\t\trepository,\n\t\t\t},\n\t\t});\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\n\t\t\t\t\"Machine2Machine token generation failed, no token received.\",\n\t\t\t);\n\t\t}\n\t\tconst token = (await result.json()).token;\n\n\t\treturn token;\n\t}\n}\n"],"names":["authenticateWithLambda"],"mappings":";;;;;;;;;MAQa,wBAAuB;AAAA,EAInC,YACkB,SACA,MAAgB;AADhB;AACA;AALV;AACA;AAGU,SAAO,UAAP;AACA,SAAI,OAAJ;AAAA,EACf;AAAA,EAEK,MAAM,aAAU;AACnB,QAAA,CAAC,KAAK,UAAU;AACd,WAAA,WAAW,MAAM,QAAQ,WAAW;AAAA,QACxC,SAAS,KAAK;AAAA,MAAA,CACd;AAAA,IACF;AAEA,WAAO,KAAK;AAAA,EACb;AAAA,EAEQ,MAAM,QAAK;AACZ,UAAA,WAAW,OAAO;AAExB,UAAM,EAAE,MAAU,IAAA,MAAMA,MACvB,KAAK,SACL,KAAK,KAAK,OACV,KAAK,KAAK,QAAQ;AAGnB,QAAI,CAAC,OAAO;AACL,YAAA,IAAI,MAAM,2CAA2C;AAAA,IAC5D;AAEA,aAAS,KAAK;AAAA,MACb,SAAS,4BAA4B,KAAK,KAAK,KAAK;AAAA,IAAA,CACpD;AAEM,WAAA;AAAA,EACR;AAAA;AAAA,EAGA,MAAM,WAAQ;AACT,QAAA,CAAC,KAAK,WAAW;AACf,WAAA,YAAY,MAAM,KAAK;IAC7B;AAEA,WAAO,KAAK;AAAA,EACb;AAAA;AAAA,EAGA,MAAM,wBAAwB,YAAkB;AAC3C,QAAA,CAAC,KAAK,WAAW;AACf,WAAA,YAAY,MAAM,KAAK;IAC7B;AAEM,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,IAAI,mBAAmB;AAAA,MACnD,SAAS;AAAA,QACR,eAAe,UAAU,KAAK,SAAS;AAAA,QACvC;AAAA,MACA;AAAA,IAAA,CACD;AAEG,QAAA,CAAC,OAAO,MAAM;AACjB,+BAAyB,MAAM;AACzB,YAAA,IAAI,MACT,6DAA6D;AAAA,IAE/D;AACA,UAAM,SAAS,MAAM,OAAO,KAAA,GAAQ;AAE7B,WAAA;AAAA,EACR;AACA;"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
-
var __publicField = (obj, key, value) =>
|
|
4
|
+
var __publicField = (obj, key, value) => {
|
|
5
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
+
return value;
|
|
7
|
+
};
|
|
5
8
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
9
|
const apiClient = require("./apiClient.cjs");
|
|
7
10
|
class ContentApiClient extends apiClient.AuthenticatedApiClient {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentApi.cjs","sources":["../../../src/clients/contentApi.ts"],"sourcesContent":["import { APIResponse } from \"@playwright/test\";\n\nimport { AuthenticatedApiClient } from \"./apiClient\";\n\nexport interface ContentApiError {\n\ttype: string;\n\tmessage: string;\n}\nexport interface ContentApiSearchResponse {\n\tpage: number;\n\tresults_per_page: number;\n\tresults_size: number;\n\ttotal_results_size: number;\n\ttotal_pages: number;\n\tnext_page: string | null;\n\tprev_page: string | null;\n\tresults: ContentApiDocument[];\n}\n\nexport interface ContentApiDocument {\n\tid: string;\n\tuid: string | null;\n\turl: string | null;\n\ttype: string;\n\thref: string;\n\ttags: string[];\n\tfirst_publication_date: string;\n\tlast_publication_date: string;\n\tslugs: string[];\n\tlinked_documents: unknown[];\n\tlang: string;\n\talternate_languages: string[];\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdata: Record<string, any>;\n}\n\nexport interface ContentApiGraphQLResponse {\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdata: Record<string, any>;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\terrors?: { message: string; locations: any }[];\n}\n\nexport interface ContentApiRef {\n\tid: string;\n\tref: string;\n\tlabel: string;\n\tisMasterRef?: boolean;\n\tscheduledAt?: number | undefined;\n}\n\ninterface ContentApiRepoConfigResponse {\n\trefs: ContentApiRef[];\n\tbookmarks: Record<string, unknown>;\n\ttypes: Record<string, string>;\n\tlanguages: {\n\t\tid: string;\n\t\tname: string;\n\t\tis_master: boolean;\n\t}[];\n\toauth_initiate: string;\n\toauth_token: string;\n\ttags: string[];\n\tlicense: string;\n\tversion: string;\n}\n\ntype SearchQueryParams = {\n\tref?: string;\n\tquery?: string;\n\tq?: string;\n\tgraphQuery?: string;\n\tfetchLinks?: string;\n\torderings?: string;\n\tpageSize?: number;\n\tpage?: number;\n\tlang?: string;\n\tafter?: string;\n\troutes?: string;\n};\n\ntype ApiVersions = \"v1\" | \"v2\";\n\n/**\n * Client to query the Prismic content api. Uses Playwright to benefit from\n * network request traces in your reports. See api docs:\n * https://prismic.io/docs/rest-api-technical-reference\n */\nexport class ContentApiClient extends AuthenticatedApiClient {\n\tprivate version: ApiVersions;\n\tprivate accessToken: string | undefined;\n\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new ContentApiClient(\"https://my-repo.cdn.prismic.io\", {\n\t * \tversion: \"v2\",\n\t * \taccessToken: \"my-secret-token\",\n\t * });\n\t * ```\n\t *\n\t * @param baseURL - the api base URL like https://my-repo.cdn.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.version}: Api version, default is \"v2\"\n\t * - {@link config.accessToken}: Access token for the content api -\n\t * https://prismic.io/docs/access-token\n\t */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { version?: ApiVersions; accessToken?: string } = {},\n\t) {\n\t\t// Use an empty string as Authorization header in case it is already set globally in the project Playwright config file.\n\t\t// This is because the content api returns an error in case it gets an non-empty invalid Authorization\n\t\t// even though it actually checks authorization from the access_token query parameter.\n\t\tsuper(baseURL, config.accessToken || \"\");\n\t\tthis.version = config.version || \"v2\";\n\t\tthis.accessToken = config.accessToken;\n\t}\n\n\tasync get(\n\t\tpath: string,\n\t\tparams?: SearchQueryParams,\n\t\theaders?: Record<string, string>,\n\t): Promise<APIResponse> {\n\t\tconst context = await this.getContext();\n\t\tconst securityParams = {\n\t\t\t...(this.accessToken ? { access_token: this.accessToken } : {}),\n\t\t};\n\n\t\treturn context.get(path, {\n\t\t\tparams: { ...securityParams, ...params },\n\t\t\theaders,\n\t\t});\n\t}\n\n\tasync getAsJson<T>(\n\t\turl: string,\n\t\tparams?: SearchQueryParams,\n\t\theaders?: Record<string, string>,\n\t): Promise<T> {\n\t\tconst response = await this.get(url, params, headers);\n\n\t\treturn response.json() as T;\n\t}\n\n\t/** Query the graphql api - https://prismic.io/docs/graphql-technical-reference */\n\tasync graphql(\n\t\tref: string,\n\t\tquery: string,\n\t): Promise<ContentApiGraphQLResponse> {\n\t\treturn this.getAsJson<ContentApiGraphQLResponse>(\n\t\t\t\"graphql\",\n\t\t\t{ query },\n\t\t\t{ \"Prismic-ref\": ref },\n\t\t);\n\t}\n\n\tasync getRefs(): Promise<ContentApiRef[]> {\n\t\tconst data = await this.getAsJson<ContentApiRepoConfigResponse>(\n\t\t\t`api/${this.version}`,\n\t\t);\n\n\t\treturn data.refs;\n\t}\n\n\tasync getMasterRef(): Promise<string> {\n\t\tconst refs = await this.getRefs();\n\n\t\tconst masterRef = refs.find(({ isMasterRef }) => isMasterRef === true);\n\t\tif (!masterRef) {\n\t\t\tthrow \"No master ref found\";\n\t\t}\n\n\t\treturn masterRef.ref;\n\t}\n\n\tasync getRefByReleaseID(releaseID: string): Promise<string> {\n\t\tconst refs = await this.getRefs();\n\t\tconst release = refs.find(({ id }) => id === releaseID);\n\t\tif (!release) {\n\t\t\tthrow `No ref found for release ${releaseID}`;\n\t\t}\n\n\t\treturn release.ref;\n\t}\n\n\t/** Search documents from the `/api/v<version>/documents/search` endpoint. */\n\tasync search(filters?: SearchQueryParams): Promise<ContentApiSearchResponse> {\n\t\tlet ref = filters?.ref;\n\t\tif (!ref) {\n\t\t\tref = await this.getMasterRef();\n\t\t}\n\n\t\treturn this.getAsJson<ContentApiSearchResponse>(\n\t\t\t`api/${this.version}/documents/search`,\n\t\t\t{\n\t\t\t\t...filters,\n\t\t\t\tref,\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Search for a single document by its it, using the\n\t * `/api/v<version>/documents/search` endpoint and a default filter.\n\t */\n\tasync searchByID(\n\t\tid: string,\n\t\tfilters?: SearchQueryParams,\n\t): Promise<ContentApiSearchResponse> {\n\t\treturn this.search({ ...filters, q: `[[at(document.id, \"${id}\")]]` });\n\t}\n\n\t/** Retrieve a single document or undefined if not found. */\n\tasync getDocumentByID(\n\t\tid: string,\n\t\tfilters?: SearchQueryParams,\n\t): Promise<ContentApiDocument | undefined> {\n\t\tconst data = await this.searchByID(id, filters);\n\t\tswitch (data.results_size) {\n\t\t\tcase 0:\n\t\t\t\treturn;\n\t\t\tcase 1:\n\t\t\t\treturn data.results[0];\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Too many documents returned with the same id ${id}`);\n\t\t}\n\t}\n}\n"],"names":["AuthenticatedApiClient"],"mappings":"
|
|
1
|
+
{"version":3,"file":"contentApi.cjs","sources":["../../../src/clients/contentApi.ts"],"sourcesContent":["import { APIResponse } from \"@playwright/test\";\n\nimport { AuthenticatedApiClient } from \"./apiClient\";\n\nexport interface ContentApiError {\n\ttype: string;\n\tmessage: string;\n}\nexport interface ContentApiSearchResponse {\n\tpage: number;\n\tresults_per_page: number;\n\tresults_size: number;\n\ttotal_results_size: number;\n\ttotal_pages: number;\n\tnext_page: string | null;\n\tprev_page: string | null;\n\tresults: ContentApiDocument[];\n}\n\nexport interface ContentApiDocument {\n\tid: string;\n\tuid: string | null;\n\turl: string | null;\n\ttype: string;\n\thref: string;\n\ttags: string[];\n\tfirst_publication_date: string;\n\tlast_publication_date: string;\n\tslugs: string[];\n\tlinked_documents: unknown[];\n\tlang: string;\n\talternate_languages: string[];\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdata: Record<string, any>;\n}\n\nexport interface ContentApiGraphQLResponse {\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdata: Record<string, any>;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\terrors?: { message: string; locations: any }[];\n}\n\nexport interface ContentApiRef {\n\tid: string;\n\tref: string;\n\tlabel: string;\n\tisMasterRef?: boolean;\n\tscheduledAt?: number | undefined;\n}\n\ninterface ContentApiRepoConfigResponse {\n\trefs: ContentApiRef[];\n\tbookmarks: Record<string, unknown>;\n\ttypes: Record<string, string>;\n\tlanguages: {\n\t\tid: string;\n\t\tname: string;\n\t\tis_master: boolean;\n\t}[];\n\toauth_initiate: string;\n\toauth_token: string;\n\ttags: string[];\n\tlicense: string;\n\tversion: string;\n}\n\ntype SearchQueryParams = {\n\tref?: string;\n\tquery?: string;\n\tq?: string;\n\tgraphQuery?: string;\n\tfetchLinks?: string;\n\torderings?: string;\n\tpageSize?: number;\n\tpage?: number;\n\tlang?: string;\n\tafter?: string;\n\troutes?: string;\n};\n\ntype ApiVersions = \"v1\" | \"v2\";\n\n/**\n * Client to query the Prismic content api. Uses Playwright to benefit from\n * network request traces in your reports. See api docs:\n * https://prismic.io/docs/rest-api-technical-reference\n */\nexport class ContentApiClient extends AuthenticatedApiClient {\n\tprivate version: ApiVersions;\n\tprivate accessToken: string | undefined;\n\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new ContentApiClient(\"https://my-repo.cdn.prismic.io\", {\n\t * \tversion: \"v2\",\n\t * \taccessToken: \"my-secret-token\",\n\t * });\n\t * ```\n\t *\n\t * @param baseURL - the api base URL like https://my-repo.cdn.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.version}: Api version, default is \"v2\"\n\t * - {@link config.accessToken}: Access token for the content api -\n\t * https://prismic.io/docs/access-token\n\t */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { version?: ApiVersions; accessToken?: string } = {},\n\t) {\n\t\t// Use an empty string as Authorization header in case it is already set globally in the project Playwright config file.\n\t\t// This is because the content api returns an error in case it gets an non-empty invalid Authorization\n\t\t// even though it actually checks authorization from the access_token query parameter.\n\t\tsuper(baseURL, config.accessToken || \"\");\n\t\tthis.version = config.version || \"v2\";\n\t\tthis.accessToken = config.accessToken;\n\t}\n\n\tasync get(\n\t\tpath: string,\n\t\tparams?: SearchQueryParams,\n\t\theaders?: Record<string, string>,\n\t): Promise<APIResponse> {\n\t\tconst context = await this.getContext();\n\t\tconst securityParams = {\n\t\t\t...(this.accessToken ? { access_token: this.accessToken } : {}),\n\t\t};\n\n\t\treturn context.get(path, {\n\t\t\tparams: { ...securityParams, ...params },\n\t\t\theaders,\n\t\t});\n\t}\n\n\tasync getAsJson<T>(\n\t\turl: string,\n\t\tparams?: SearchQueryParams,\n\t\theaders?: Record<string, string>,\n\t): Promise<T> {\n\t\tconst response = await this.get(url, params, headers);\n\n\t\treturn response.json() as T;\n\t}\n\n\t/** Query the graphql api - https://prismic.io/docs/graphql-technical-reference */\n\tasync graphql(\n\t\tref: string,\n\t\tquery: string,\n\t): Promise<ContentApiGraphQLResponse> {\n\t\treturn this.getAsJson<ContentApiGraphQLResponse>(\n\t\t\t\"graphql\",\n\t\t\t{ query },\n\t\t\t{ \"Prismic-ref\": ref },\n\t\t);\n\t}\n\n\tasync getRefs(): Promise<ContentApiRef[]> {\n\t\tconst data = await this.getAsJson<ContentApiRepoConfigResponse>(\n\t\t\t`api/${this.version}`,\n\t\t);\n\n\t\treturn data.refs;\n\t}\n\n\tasync getMasterRef(): Promise<string> {\n\t\tconst refs = await this.getRefs();\n\n\t\tconst masterRef = refs.find(({ isMasterRef }) => isMasterRef === true);\n\t\tif (!masterRef) {\n\t\t\tthrow \"No master ref found\";\n\t\t}\n\n\t\treturn masterRef.ref;\n\t}\n\n\tasync getRefByReleaseID(releaseID: string): Promise<string> {\n\t\tconst refs = await this.getRefs();\n\t\tconst release = refs.find(({ id }) => id === releaseID);\n\t\tif (!release) {\n\t\t\tthrow `No ref found for release ${releaseID}`;\n\t\t}\n\n\t\treturn release.ref;\n\t}\n\n\t/** Search documents from the `/api/v<version>/documents/search` endpoint. */\n\tasync search(filters?: SearchQueryParams): Promise<ContentApiSearchResponse> {\n\t\tlet ref = filters?.ref;\n\t\tif (!ref) {\n\t\t\tref = await this.getMasterRef();\n\t\t}\n\n\t\treturn this.getAsJson<ContentApiSearchResponse>(\n\t\t\t`api/${this.version}/documents/search`,\n\t\t\t{\n\t\t\t\t...filters,\n\t\t\t\tref,\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Search for a single document by its it, using the\n\t * `/api/v<version>/documents/search` endpoint and a default filter.\n\t */\n\tasync searchByID(\n\t\tid: string,\n\t\tfilters?: SearchQueryParams,\n\t): Promise<ContentApiSearchResponse> {\n\t\treturn this.search({ ...filters, q: `[[at(document.id, \"${id}\")]]` });\n\t}\n\n\t/** Retrieve a single document or undefined if not found. */\n\tasync getDocumentByID(\n\t\tid: string,\n\t\tfilters?: SearchQueryParams,\n\t): Promise<ContentApiDocument | undefined> {\n\t\tconst data = await this.searchByID(id, filters);\n\t\tswitch (data.results_size) {\n\t\t\tcase 0:\n\t\t\t\treturn;\n\t\t\tcase 1:\n\t\t\t\treturn data.results[0];\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Too many documents returned with the same id ${id}`);\n\t\t}\n\t}\n}\n"],"names":["AuthenticatedApiClient"],"mappings":";;;;;;;;;AAwFM,MAAO,yBAAyBA,UAAAA,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqB3D,YACC,SACA,SAA0D,IAAE;AAKtD,UAAA,SAAS,OAAO,eAAe,EAAE;AA3BhC;AACA;AA2BF,SAAA,UAAU,OAAO,WAAW;AACjC,SAAK,cAAc,OAAO;AAAA,EAC3B;AAAA,EAEA,MAAM,IACL,MACA,QACA,SAAgC;AAE1B,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,iBAAiB;AAAA,MACtB,GAAI,KAAK,cAAc,EAAE,cAAc,KAAK,YAAA,IAAgB;;AAGtD,WAAA,QAAQ,IAAI,MAAM;AAAA,MACxB,QAAQ,EAAE,GAAG,gBAAgB,GAAG,OAAQ;AAAA,MACxC;AAAA,IAAA,CACA;AAAA,EACF;AAAA,EAEA,MAAM,UACL,KACA,QACA,SAAgC;AAEhC,UAAM,WAAW,MAAM,KAAK,IAAI,KAAK,QAAQ,OAAO;AAEpD,WAAO,SAAS;EACjB;AAAA;AAAA,EAGA,MAAM,QACL,KACA,OAAa;AAEN,WAAA,KAAK,UACX,WACA,EAAE,SACF,EAAE,eAAe,IAAA,CAAK;AAAA,EAExB;AAAA,EAEA,MAAM,UAAO;AACZ,UAAM,OAAO,MAAM,KAAK,UACvB,OAAO,KAAK,OAAO,EAAE;AAGtB,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,MAAM,eAAY;AACX,UAAA,OAAO,MAAM,KAAK;AAElB,UAAA,YAAY,KAAK,KAAK,CAAC,EAAE,kBAAkB,gBAAgB,IAAI;AACrE,QAAI,CAAC,WAAW;AACT,YAAA;AAAA,IACP;AAEA,WAAO,UAAU;AAAA,EAClB;AAAA,EAEA,MAAM,kBAAkB,WAAiB;AAClC,UAAA,OAAO,MAAM,KAAK;AAClB,UAAA,UAAU,KAAK,KAAK,CAAC,EAAE,SAAS,OAAO,SAAS;AACtD,QAAI,CAAC,SAAS;AACb,YAAM,4BAA4B,SAAS;AAAA,IAC5C;AAEA,WAAO,QAAQ;AAAA,EAChB;AAAA;AAAA,EAGA,MAAM,OAAO,SAA2B;AACvC,QAAI,MAAM,mCAAS;AACnB,QAAI,CAAC,KAAK;AACH,YAAA,MAAM,KAAK;IAClB;AAEA,WAAO,KAAK,UACX,OAAO,KAAK,OAAO,qBACnB;AAAA,MACC,GAAG;AAAA,MACH;AAAA,IAAA,CACA;AAAA,EAEH;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WACL,IACA,SAA2B;AAEpB,WAAA,KAAK,OAAO,EAAE,GAAG,SAAS,GAAG,sBAAsB,EAAE,OAAA,CAAQ;AAAA,EACrE;AAAA;AAAA,EAGA,MAAM,gBACL,IACA,SAA2B;AAE3B,UAAM,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO;AAC9C,YAAQ,KAAK,cAAc;AAAA,MAC1B,KAAK;AACJ;AAAA,MACD,KAAK;AACG,eAAA,KAAK,QAAQ,CAAC;AAAA,MACtB;AACC,cAAM,IAAI,MAAM,gDAAgD,EAAE,EAAE;AAAA,IACtE;AAAA,EACD;AACA;;"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) =>
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
4
7
|
import { AuthenticatedApiClient } from "./apiClient.js";
|
|
5
8
|
class ContentApiClient extends AuthenticatedApiClient {
|
|
6
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentApi.js","sources":["../../../src/clients/contentApi.ts"],"sourcesContent":["import { APIResponse } from \"@playwright/test\";\n\nimport { AuthenticatedApiClient } from \"./apiClient\";\n\nexport interface ContentApiError {\n\ttype: string;\n\tmessage: string;\n}\nexport interface ContentApiSearchResponse {\n\tpage: number;\n\tresults_per_page: number;\n\tresults_size: number;\n\ttotal_results_size: number;\n\ttotal_pages: number;\n\tnext_page: string | null;\n\tprev_page: string | null;\n\tresults: ContentApiDocument[];\n}\n\nexport interface ContentApiDocument {\n\tid: string;\n\tuid: string | null;\n\turl: string | null;\n\ttype: string;\n\thref: string;\n\ttags: string[];\n\tfirst_publication_date: string;\n\tlast_publication_date: string;\n\tslugs: string[];\n\tlinked_documents: unknown[];\n\tlang: string;\n\talternate_languages: string[];\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdata: Record<string, any>;\n}\n\nexport interface ContentApiGraphQLResponse {\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdata: Record<string, any>;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\terrors?: { message: string; locations: any }[];\n}\n\nexport interface ContentApiRef {\n\tid: string;\n\tref: string;\n\tlabel: string;\n\tisMasterRef?: boolean;\n\tscheduledAt?: number | undefined;\n}\n\ninterface ContentApiRepoConfigResponse {\n\trefs: ContentApiRef[];\n\tbookmarks: Record<string, unknown>;\n\ttypes: Record<string, string>;\n\tlanguages: {\n\t\tid: string;\n\t\tname: string;\n\t\tis_master: boolean;\n\t}[];\n\toauth_initiate: string;\n\toauth_token: string;\n\ttags: string[];\n\tlicense: string;\n\tversion: string;\n}\n\ntype SearchQueryParams = {\n\tref?: string;\n\tquery?: string;\n\tq?: string;\n\tgraphQuery?: string;\n\tfetchLinks?: string;\n\torderings?: string;\n\tpageSize?: number;\n\tpage?: number;\n\tlang?: string;\n\tafter?: string;\n\troutes?: string;\n};\n\ntype ApiVersions = \"v1\" | \"v2\";\n\n/**\n * Client to query the Prismic content api. Uses Playwright to benefit from\n * network request traces in your reports. See api docs:\n * https://prismic.io/docs/rest-api-technical-reference\n */\nexport class ContentApiClient extends AuthenticatedApiClient {\n\tprivate version: ApiVersions;\n\tprivate accessToken: string | undefined;\n\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new ContentApiClient(\"https://my-repo.cdn.prismic.io\", {\n\t * \tversion: \"v2\",\n\t * \taccessToken: \"my-secret-token\",\n\t * });\n\t * ```\n\t *\n\t * @param baseURL - the api base URL like https://my-repo.cdn.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.version}: Api version, default is \"v2\"\n\t * - {@link config.accessToken}: Access token for the content api -\n\t * https://prismic.io/docs/access-token\n\t */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { version?: ApiVersions; accessToken?: string } = {},\n\t) {\n\t\t// Use an empty string as Authorization header in case it is already set globally in the project Playwright config file.\n\t\t// This is because the content api returns an error in case it gets an non-empty invalid Authorization\n\t\t// even though it actually checks authorization from the access_token query parameter.\n\t\tsuper(baseURL, config.accessToken || \"\");\n\t\tthis.version = config.version || \"v2\";\n\t\tthis.accessToken = config.accessToken;\n\t}\n\n\tasync get(\n\t\tpath: string,\n\t\tparams?: SearchQueryParams,\n\t\theaders?: Record<string, string>,\n\t): Promise<APIResponse> {\n\t\tconst context = await this.getContext();\n\t\tconst securityParams = {\n\t\t\t...(this.accessToken ? { access_token: this.accessToken } : {}),\n\t\t};\n\n\t\treturn context.get(path, {\n\t\t\tparams: { ...securityParams, ...params },\n\t\t\theaders,\n\t\t});\n\t}\n\n\tasync getAsJson<T>(\n\t\turl: string,\n\t\tparams?: SearchQueryParams,\n\t\theaders?: Record<string, string>,\n\t): Promise<T> {\n\t\tconst response = await this.get(url, params, headers);\n\n\t\treturn response.json() as T;\n\t}\n\n\t/** Query the graphql api - https://prismic.io/docs/graphql-technical-reference */\n\tasync graphql(\n\t\tref: string,\n\t\tquery: string,\n\t): Promise<ContentApiGraphQLResponse> {\n\t\treturn this.getAsJson<ContentApiGraphQLResponse>(\n\t\t\t\"graphql\",\n\t\t\t{ query },\n\t\t\t{ \"Prismic-ref\": ref },\n\t\t);\n\t}\n\n\tasync getRefs(): Promise<ContentApiRef[]> {\n\t\tconst data = await this.getAsJson<ContentApiRepoConfigResponse>(\n\t\t\t`api/${this.version}`,\n\t\t);\n\n\t\treturn data.refs;\n\t}\n\n\tasync getMasterRef(): Promise<string> {\n\t\tconst refs = await this.getRefs();\n\n\t\tconst masterRef = refs.find(({ isMasterRef }) => isMasterRef === true);\n\t\tif (!masterRef) {\n\t\t\tthrow \"No master ref found\";\n\t\t}\n\n\t\treturn masterRef.ref;\n\t}\n\n\tasync getRefByReleaseID(releaseID: string): Promise<string> {\n\t\tconst refs = await this.getRefs();\n\t\tconst release = refs.find(({ id }) => id === releaseID);\n\t\tif (!release) {\n\t\t\tthrow `No ref found for release ${releaseID}`;\n\t\t}\n\n\t\treturn release.ref;\n\t}\n\n\t/** Search documents from the `/api/v<version>/documents/search` endpoint. */\n\tasync search(filters?: SearchQueryParams): Promise<ContentApiSearchResponse> {\n\t\tlet ref = filters?.ref;\n\t\tif (!ref) {\n\t\t\tref = await this.getMasterRef();\n\t\t}\n\n\t\treturn this.getAsJson<ContentApiSearchResponse>(\n\t\t\t`api/${this.version}/documents/search`,\n\t\t\t{\n\t\t\t\t...filters,\n\t\t\t\tref,\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Search for a single document by its it, using the\n\t * `/api/v<version>/documents/search` endpoint and a default filter.\n\t */\n\tasync searchByID(\n\t\tid: string,\n\t\tfilters?: SearchQueryParams,\n\t): Promise<ContentApiSearchResponse> {\n\t\treturn this.search({ ...filters, q: `[[at(document.id, \"${id}\")]]` });\n\t}\n\n\t/** Retrieve a single document or undefined if not found. */\n\tasync getDocumentByID(\n\t\tid: string,\n\t\tfilters?: SearchQueryParams,\n\t): Promise<ContentApiDocument | undefined> {\n\t\tconst data = await this.searchByID(id, filters);\n\t\tswitch (data.results_size) {\n\t\t\tcase 0:\n\t\t\t\treturn;\n\t\t\tcase 1:\n\t\t\t\treturn data.results[0];\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Too many documents returned with the same id ${id}`);\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contentApi.js","sources":["../../../src/clients/contentApi.ts"],"sourcesContent":["import { APIResponse } from \"@playwright/test\";\n\nimport { AuthenticatedApiClient } from \"./apiClient\";\n\nexport interface ContentApiError {\n\ttype: string;\n\tmessage: string;\n}\nexport interface ContentApiSearchResponse {\n\tpage: number;\n\tresults_per_page: number;\n\tresults_size: number;\n\ttotal_results_size: number;\n\ttotal_pages: number;\n\tnext_page: string | null;\n\tprev_page: string | null;\n\tresults: ContentApiDocument[];\n}\n\nexport interface ContentApiDocument {\n\tid: string;\n\tuid: string | null;\n\turl: string | null;\n\ttype: string;\n\thref: string;\n\ttags: string[];\n\tfirst_publication_date: string;\n\tlast_publication_date: string;\n\tslugs: string[];\n\tlinked_documents: unknown[];\n\tlang: string;\n\talternate_languages: string[];\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdata: Record<string, any>;\n}\n\nexport interface ContentApiGraphQLResponse {\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdata: Record<string, any>;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\terrors?: { message: string; locations: any }[];\n}\n\nexport interface ContentApiRef {\n\tid: string;\n\tref: string;\n\tlabel: string;\n\tisMasterRef?: boolean;\n\tscheduledAt?: number | undefined;\n}\n\ninterface ContentApiRepoConfigResponse {\n\trefs: ContentApiRef[];\n\tbookmarks: Record<string, unknown>;\n\ttypes: Record<string, string>;\n\tlanguages: {\n\t\tid: string;\n\t\tname: string;\n\t\tis_master: boolean;\n\t}[];\n\toauth_initiate: string;\n\toauth_token: string;\n\ttags: string[];\n\tlicense: string;\n\tversion: string;\n}\n\ntype SearchQueryParams = {\n\tref?: string;\n\tquery?: string;\n\tq?: string;\n\tgraphQuery?: string;\n\tfetchLinks?: string;\n\torderings?: string;\n\tpageSize?: number;\n\tpage?: number;\n\tlang?: string;\n\tafter?: string;\n\troutes?: string;\n};\n\ntype ApiVersions = \"v1\" | \"v2\";\n\n/**\n * Client to query the Prismic content api. Uses Playwright to benefit from\n * network request traces in your reports. See api docs:\n * https://prismic.io/docs/rest-api-technical-reference\n */\nexport class ContentApiClient extends AuthenticatedApiClient {\n\tprivate version: ApiVersions;\n\tprivate accessToken: string | undefined;\n\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new ContentApiClient(\"https://my-repo.cdn.prismic.io\", {\n\t * \tversion: \"v2\",\n\t * \taccessToken: \"my-secret-token\",\n\t * });\n\t * ```\n\t *\n\t * @param baseURL - the api base URL like https://my-repo.cdn.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.version}: Api version, default is \"v2\"\n\t * - {@link config.accessToken}: Access token for the content api -\n\t * https://prismic.io/docs/access-token\n\t */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { version?: ApiVersions; accessToken?: string } = {},\n\t) {\n\t\t// Use an empty string as Authorization header in case it is already set globally in the project Playwright config file.\n\t\t// This is because the content api returns an error in case it gets an non-empty invalid Authorization\n\t\t// even though it actually checks authorization from the access_token query parameter.\n\t\tsuper(baseURL, config.accessToken || \"\");\n\t\tthis.version = config.version || \"v2\";\n\t\tthis.accessToken = config.accessToken;\n\t}\n\n\tasync get(\n\t\tpath: string,\n\t\tparams?: SearchQueryParams,\n\t\theaders?: Record<string, string>,\n\t): Promise<APIResponse> {\n\t\tconst context = await this.getContext();\n\t\tconst securityParams = {\n\t\t\t...(this.accessToken ? { access_token: this.accessToken } : {}),\n\t\t};\n\n\t\treturn context.get(path, {\n\t\t\tparams: { ...securityParams, ...params },\n\t\t\theaders,\n\t\t});\n\t}\n\n\tasync getAsJson<T>(\n\t\turl: string,\n\t\tparams?: SearchQueryParams,\n\t\theaders?: Record<string, string>,\n\t): Promise<T> {\n\t\tconst response = await this.get(url, params, headers);\n\n\t\treturn response.json() as T;\n\t}\n\n\t/** Query the graphql api - https://prismic.io/docs/graphql-technical-reference */\n\tasync graphql(\n\t\tref: string,\n\t\tquery: string,\n\t): Promise<ContentApiGraphQLResponse> {\n\t\treturn this.getAsJson<ContentApiGraphQLResponse>(\n\t\t\t\"graphql\",\n\t\t\t{ query },\n\t\t\t{ \"Prismic-ref\": ref },\n\t\t);\n\t}\n\n\tasync getRefs(): Promise<ContentApiRef[]> {\n\t\tconst data = await this.getAsJson<ContentApiRepoConfigResponse>(\n\t\t\t`api/${this.version}`,\n\t\t);\n\n\t\treturn data.refs;\n\t}\n\n\tasync getMasterRef(): Promise<string> {\n\t\tconst refs = await this.getRefs();\n\n\t\tconst masterRef = refs.find(({ isMasterRef }) => isMasterRef === true);\n\t\tif (!masterRef) {\n\t\t\tthrow \"No master ref found\";\n\t\t}\n\n\t\treturn masterRef.ref;\n\t}\n\n\tasync getRefByReleaseID(releaseID: string): Promise<string> {\n\t\tconst refs = await this.getRefs();\n\t\tconst release = refs.find(({ id }) => id === releaseID);\n\t\tif (!release) {\n\t\t\tthrow `No ref found for release ${releaseID}`;\n\t\t}\n\n\t\treturn release.ref;\n\t}\n\n\t/** Search documents from the `/api/v<version>/documents/search` endpoint. */\n\tasync search(filters?: SearchQueryParams): Promise<ContentApiSearchResponse> {\n\t\tlet ref = filters?.ref;\n\t\tif (!ref) {\n\t\t\tref = await this.getMasterRef();\n\t\t}\n\n\t\treturn this.getAsJson<ContentApiSearchResponse>(\n\t\t\t`api/${this.version}/documents/search`,\n\t\t\t{\n\t\t\t\t...filters,\n\t\t\t\tref,\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Search for a single document by its it, using the\n\t * `/api/v<version>/documents/search` endpoint and a default filter.\n\t */\n\tasync searchByID(\n\t\tid: string,\n\t\tfilters?: SearchQueryParams,\n\t): Promise<ContentApiSearchResponse> {\n\t\treturn this.search({ ...filters, q: `[[at(document.id, \"${id}\")]]` });\n\t}\n\n\t/** Retrieve a single document or undefined if not found. */\n\tasync getDocumentByID(\n\t\tid: string,\n\t\tfilters?: SearchQueryParams,\n\t): Promise<ContentApiDocument | undefined> {\n\t\tconst data = await this.searchByID(id, filters);\n\t\tswitch (data.results_size) {\n\t\t\tcase 0:\n\t\t\t\treturn;\n\t\t\tcase 1:\n\t\t\t\treturn data.results[0];\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Too many documents returned with the same id ${id}`);\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;;AAwFM,MAAO,yBAAyB,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqB3D,YACC,SACA,SAA0D,IAAE;AAKtD,UAAA,SAAS,OAAO,eAAe,EAAE;AA3BhC;AACA;AA2BF,SAAA,UAAU,OAAO,WAAW;AACjC,SAAK,cAAc,OAAO;AAAA,EAC3B;AAAA,EAEA,MAAM,IACL,MACA,QACA,SAAgC;AAE1B,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,iBAAiB;AAAA,MACtB,GAAI,KAAK,cAAc,EAAE,cAAc,KAAK,YAAA,IAAgB;;AAGtD,WAAA,QAAQ,IAAI,MAAM;AAAA,MACxB,QAAQ,EAAE,GAAG,gBAAgB,GAAG,OAAQ;AAAA,MACxC;AAAA,IAAA,CACA;AAAA,EACF;AAAA,EAEA,MAAM,UACL,KACA,QACA,SAAgC;AAEhC,UAAM,WAAW,MAAM,KAAK,IAAI,KAAK,QAAQ,OAAO;AAEpD,WAAO,SAAS;EACjB;AAAA;AAAA,EAGA,MAAM,QACL,KACA,OAAa;AAEN,WAAA,KAAK,UACX,WACA,EAAE,SACF,EAAE,eAAe,IAAA,CAAK;AAAA,EAExB;AAAA,EAEA,MAAM,UAAO;AACZ,UAAM,OAAO,MAAM,KAAK,UACvB,OAAO,KAAK,OAAO,EAAE;AAGtB,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,MAAM,eAAY;AACX,UAAA,OAAO,MAAM,KAAK;AAElB,UAAA,YAAY,KAAK,KAAK,CAAC,EAAE,kBAAkB,gBAAgB,IAAI;AACrE,QAAI,CAAC,WAAW;AACT,YAAA;AAAA,IACP;AAEA,WAAO,UAAU;AAAA,EAClB;AAAA,EAEA,MAAM,kBAAkB,WAAiB;AAClC,UAAA,OAAO,MAAM,KAAK;AAClB,UAAA,UAAU,KAAK,KAAK,CAAC,EAAE,SAAS,OAAO,SAAS;AACtD,QAAI,CAAC,SAAS;AACb,YAAM,4BAA4B,SAAS;AAAA,IAC5C;AAEA,WAAO,QAAQ;AAAA,EAChB;AAAA;AAAA,EAGA,MAAM,OAAO,SAA2B;AACvC,QAAI,MAAM,mCAAS;AACnB,QAAI,CAAC,KAAK;AACH,YAAA,MAAM,KAAK;IAClB;AAEA,WAAO,KAAK,UACX,OAAO,KAAK,OAAO,qBACnB;AAAA,MACC,GAAG;AAAA,MACH;AAAA,IAAA,CACA;AAAA,EAEH;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WACL,IACA,SAA2B;AAEpB,WAAA,KAAK,OAAO,EAAE,GAAG,SAAS,GAAG,sBAAsB,EAAE,OAAA,CAAQ;AAAA,EACrE;AAAA;AAAA,EAGA,MAAM,gBACL,IACA,SAA2B;AAE3B,UAAM,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO;AAC9C,YAAQ,KAAK,cAAc;AAAA,MAC1B,KAAK;AACJ;AAAA,MACD,KAAK;AACG,eAAA,KAAK,QAAQ,CAAC;AAAA,MACtB;AACC,cAAM,IAAI,MAAM,gDAAgD,EAAE,EAAE;AAAA,IACtE;AAAA,EACD;AACA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreApi.cjs","sources":["../../../src/clients/coreApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse, logger } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\ntype Language = {\n\tid: string;\n\tname: string;\n\tis_master: 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 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 class CoreApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new CoreApiClient(\"https://my-repo.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * });\n\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\n\t * function to fetch it 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\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\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"],"names":["AuthenticatedApiClient","logger","logPlaywrightApiResponse"],"mappings":";;;;AAiDM,MAAO,sBAAsBA,UAAAA,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBxD,YAAY,SAAiB,QAAuB;AACnD,UAAM,SAAS,MAAM;AAAA,
|
|
1
|
+
{"version":3,"file":"coreApi.cjs","sources":["../../../src/clients/coreApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse, logger } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\ntype Language = {\n\tid: string;\n\tname: string;\n\tis_master: 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 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 class CoreApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new CoreApiClient(\"https://my-repo.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * });\n\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\n\t * function to fetch it 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\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\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"],"names":["AuthenticatedApiClient","logger","logPlaywrightApiResponse"],"mappings":";;;;AAiDM,MAAO,sBAAsBA,UAAAA,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBxD,YAAY,SAAiB,QAAuB;AACnD,UAAM,SAAS,MAAM;AAAA,EACtB;AAAA,EAEA,MAAM,eAAY;AACX,UAAA,WAAWC,WAAO;AAClB,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,IAAI,iBAAiB;AAE9C,QAAA,QAAQ,OAAO,OAAM,KAAM,EAAE,MAAM,OAAO,KAAI,GAAI,WAAW;AAChE,YAAMC,IAAAA,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,4CAA4C;AAAA,IAC7D;AAEA,aAAS,KAAK,EAAE,SAAS,oCAAqC,CAAA;AAEtD,YAAA,MAAM,OAAO,KAAA,GAAQ;AAAA,EAC9B;AAAA,EAEA,MAAM,YACL,MAAoC;AAE9B,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,KAAK,kBAAkB;AAAA,MACnD;AAAA,IAAA,CACA;AAEG,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAMA,IAAAA,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,iCAAiC;AAAA,IAClD;AAEA,WAAO,OAAO;EACf;AAAA,EAEA,MAAM,aAAa,YAAkB;AAC9B,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,MAAM,kBAAkB,UAAU,UAAU;AAAA,MACxE,MAAM;AAAA,QACL,QAAQ;AAAA,MACR;AAAA,IAAA,CACD;AAEG,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAMA,IAAAA,yBAAyB,MAAM;AACrC,YAAM,IAAI,MAAM,sCAAsC,UAAU,EAAE;AAAA,IACnE;AAAA,EACD;AACA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreApi.js","sources":["../../../src/clients/coreApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse, logger } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\ntype Language = {\n\tid: string;\n\tname: string;\n\tis_master: 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 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 class CoreApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new CoreApiClient(\"https://my-repo.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * });\n\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\n\t * function to fetch it 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\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\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"],"names":[],"mappings":";;AAiDM,MAAO,sBAAsB,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBxD,YAAY,SAAiB,QAAuB;AACnD,UAAM,SAAS,MAAM;AAAA,
|
|
1
|
+
{"version":3,"file":"coreApi.js","sources":["../../../src/clients/coreApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse, logger } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\ntype Language = {\n\tid: string;\n\tname: string;\n\tis_master: 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 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 class CoreApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new CoreApiClient(\"https://my-repo.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * });\n\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\n\t * function to fetch it 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\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\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"],"names":[],"mappings":";;AAiDM,MAAO,sBAAsB,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBxD,YAAY,SAAiB,QAAuB;AACnD,UAAM,SAAS,MAAM;AAAA,EACtB;AAAA,EAEA,MAAM,eAAY;AACX,UAAA,WAAW,OAAO;AAClB,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,IAAI,iBAAiB;AAE9C,QAAA,QAAQ,OAAO,OAAM,KAAM,EAAE,MAAM,OAAO,KAAI,GAAI,WAAW;AAChE,YAAM,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,4CAA4C;AAAA,IAC7D;AAEA,aAAS,KAAK,EAAE,SAAS,oCAAqC,CAAA;AAEtD,YAAA,MAAM,OAAO,KAAA,GAAQ;AAAA,EAC9B;AAAA,EAEA,MAAM,YACL,MAAoC;AAE9B,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,KAAK,kBAAkB;AAAA,MACnD;AAAA,IAAA,CACA;AAEG,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAM,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,iCAAiC;AAAA,IAClD;AAEA,WAAO,OAAO;EACf;AAAA,EAEA,MAAM,aAAa,YAAkB;AAC9B,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,MAAM,kBAAkB,UAAU,UAAU;AAAA,MACxE,MAAM;AAAA,QACL,QAAQ;AAAA,MACR;AAAA,IAAA,CACD;AAEG,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAM,yBAAyB,MAAM;AACrC,YAAM,IAAI,MAAM,sCAAsC,UAAU,EAAE;AAAA,IACnE;AAAA,EACD;AACA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customTypesApi.cjs","sources":["../../../src/clients/customTypesApi.ts"],"sourcesContent":["import isEqual from \"lodash.isequal\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { logPlaywrightApiResponse, logger } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\ntype ItemType = CustomType | SharedSlice;\ntype ItemTypePath = \"customtypes\" | \"slices\";\ntype ItemOperation = \"insert\" | \"update\";\n\n/**\n * Client for interacting with the Custom Types API to create/update custom\n * types and slices.\n */\nexport class CustomTypesApiClient extends AuthenticatedApiClient {\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { authToken: AuthServerToken; repository: string },\n\t) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository });\n\t}\n\n\t/**\n\t * Create or update a custom type or slice.\n\t *\n\t * @param endpoint - - The API endpoint for custom types or slices\n\t * ('customtypes' or 'slices').\n\t * @param data - - The data representing the custom type or slice.\n\t *\n\t * @throws Error if the item status cannot be retrieved or the item cannot be\n\t * created/updated.\n\t */\n\tprivate async upsert(\n\t\tendpoint: ItemTypePath,\n\t\toperation: ItemOperation,\n\t\tdata: ItemType,\n\t) {\n\t\tconst profiler = logger.startTimer();\n\t\tconst path = `${endpoint}/${operation}`;\n\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.post(path, { data });\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result);\n\t\t\tthrow new Error(`Could not ${operation} item`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `called customtypes api /${path} for item with id '${data.id}'`,\n\t\t});\n\t}\n\n\tprivate async getRemoteItems(\n\t\tendpoint: ItemTypePath,\n\t): Promise<CustomType[] | SharedSlice[]> {\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.get(endpoint);\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not get items status from the Custom Type api.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n\n\tprivate async getDifference(\n\t\tremoteItems: CustomType[] | SharedSlice[],\n\t\tlocal: ItemType,\n\t): Promise<ItemOperation | undefined> {\n\t\tconst remoteItem = remoteItems.find(\n\t\t\t(remote: CustomType | SharedSlice) => remote.id === local.id,\n\t\t);\n\t\tif (!remoteItem) {\n\t\t\treturn \"insert\";\n\t\t}\n\t\tif (!isEqual(local, remoteItem)) {\n\t\t\treturn \"update\";\n\t\t}\n\n\t\treturn;\n\t}\n\n\t/** Create items only if they have changed compared to their remote status */\n\tprivate async upsertIfChanged(\n\t\titemType: ItemTypePath,\n\t\tlocalItems: ItemType[] = [],\n\t): Promise<void> {\n\t\tconst remoteItems = await this.getRemoteItems(itemType);\n\t\tawait Promise.all(\n\t\t\tlocalItems.map(async (localItem) => {\n\t\t\t\tconst operation = await this.getDifference(remoteItems, localItem);\n\n\t\t\t\treturn operation && this.upsert(itemType, operation, localItem);\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes -\n\t */\n\tasync createCustomTypes(customTypes: CustomType[] = []): Promise<void> {\n\t\tawait this.upsertIfChanged(\"customtypes\", customTypes);\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices -\n\t */\n\tasync createSlices(slices: SharedSlice[] = []): Promise<void> {\n\t\tawait this.upsertIfChanged(\"slices\", slices);\n\t}\n}\n"],"names":["AuthenticatedApiClient","logger","logPlaywrightApiResponse"],"mappings":";;;;;AAmBM,MAAO,6BAA6BA,UAAAA,uBAAsB;AAAA,EAC/D,YACC,SACA,QAA0D;AAE1D,UAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,YAAY;AAAA,
|
|
1
|
+
{"version":3,"file":"customTypesApi.cjs","sources":["../../../src/clients/customTypesApi.ts"],"sourcesContent":["import isEqual from \"lodash.isequal\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { logPlaywrightApiResponse, logger } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\ntype ItemType = CustomType | SharedSlice;\ntype ItemTypePath = \"customtypes\" | \"slices\";\ntype ItemOperation = \"insert\" | \"update\";\n\n/**\n * Client for interacting with the Custom Types API to create/update custom\n * types and slices.\n */\nexport class CustomTypesApiClient extends AuthenticatedApiClient {\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { authToken: AuthServerToken; repository: string },\n\t) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository });\n\t}\n\n\t/**\n\t * Create or update a custom type or slice.\n\t *\n\t * @param endpoint - - The API endpoint for custom types or slices\n\t * ('customtypes' or 'slices').\n\t * @param data - - The data representing the custom type or slice.\n\t *\n\t * @throws Error if the item status cannot be retrieved or the item cannot be\n\t * created/updated.\n\t */\n\tprivate async upsert(\n\t\tendpoint: ItemTypePath,\n\t\toperation: ItemOperation,\n\t\tdata: ItemType,\n\t) {\n\t\tconst profiler = logger.startTimer();\n\t\tconst path = `${endpoint}/${operation}`;\n\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.post(path, { data });\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result);\n\t\t\tthrow new Error(`Could not ${operation} item`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `called customtypes api /${path} for item with id '${data.id}'`,\n\t\t});\n\t}\n\n\tprivate async getRemoteItems(\n\t\tendpoint: ItemTypePath,\n\t): Promise<CustomType[] | SharedSlice[]> {\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.get(endpoint);\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not get items status from the Custom Type api.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n\n\tprivate async getDifference(\n\t\tremoteItems: CustomType[] | SharedSlice[],\n\t\tlocal: ItemType,\n\t): Promise<ItemOperation | undefined> {\n\t\tconst remoteItem = remoteItems.find(\n\t\t\t(remote: CustomType | SharedSlice) => remote.id === local.id,\n\t\t);\n\t\tif (!remoteItem) {\n\t\t\treturn \"insert\";\n\t\t}\n\t\tif (!isEqual(local, remoteItem)) {\n\t\t\treturn \"update\";\n\t\t}\n\n\t\treturn;\n\t}\n\n\t/** Create items only if they have changed compared to their remote status */\n\tprivate async upsertIfChanged(\n\t\titemType: ItemTypePath,\n\t\tlocalItems: ItemType[] = [],\n\t): Promise<void> {\n\t\tconst remoteItems = await this.getRemoteItems(itemType);\n\t\tawait Promise.all(\n\t\t\tlocalItems.map(async (localItem) => {\n\t\t\t\tconst operation = await this.getDifference(remoteItems, localItem);\n\n\t\t\t\treturn operation && this.upsert(itemType, operation, localItem);\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes -\n\t */\n\tasync createCustomTypes(customTypes: CustomType[] = []): Promise<void> {\n\t\tawait this.upsertIfChanged(\"customtypes\", customTypes);\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices -\n\t */\n\tasync createSlices(slices: SharedSlice[] = []): Promise<void> {\n\t\tawait this.upsertIfChanged(\"slices\", slices);\n\t}\n}\n"],"names":["AuthenticatedApiClient","logger","logPlaywrightApiResponse"],"mappings":";;;;;AAmBM,MAAO,6BAA6BA,UAAAA,uBAAsB;AAAA,EAC/D,YACC,SACA,QAA0D;AAE1D,UAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,YAAY;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYQ,MAAM,OACb,UACA,WACA,MAAc;AAER,UAAA,WAAWC,WAAO;AACxB,UAAM,OAAO,GAAG,QAAQ,IAAI,SAAS;AAE/B,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,KAAK,MAAM,EAAE,MAAM;AAC5C,QAAA,CAAC,OAAO,MAAM;AACjBC,UAAA,yBAAyB,MAAM;AAC/B,YAAM,IAAI,MAAM,aAAa,SAAS,OAAO;AAAA,IAC9C;AACA,aAAS,KAAK;AAAA,MACb,SAAS,2BAA2B,IAAI,sBAAsB,KAAK,EAAE;AAAA,IAAA,CACrE;AAAA,EACF;AAAA,EAEQ,MAAM,eACb,UAAsB;AAEhB,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,IAAI,QAAQ;AAErC,QAAA,CAAC,OAAO,MAAM;AACjBA,UAAA,yBAAyB,MAAM;AACzB,YAAA,IAAI,MAAM,sDAAsD;AAAA,IACvE;AAEA,WAAO,OAAO;EACf;AAAA,EAEQ,MAAM,cACb,aACA,OAAe;AAET,UAAA,aAAa,YAAY,KAC9B,CAAC,WAAqC,OAAO,OAAO,MAAM,EAAE;AAE7D,QAAI,CAAC,YAAY;AACT,aAAA;AAAA,IACR;AACA,QAAI,CAAC,QAAQ,OAAO,UAAU,GAAG;AACzB,aAAA;AAAA,IACR;AAEA;AAAA,EACD;AAAA;AAAA,EAGQ,MAAM,gBACb,UACA,aAAyB,IAAE;AAE3B,UAAM,cAAc,MAAM,KAAK,eAAe,QAAQ;AACtD,UAAM,QAAQ,IACb,WAAW,IAAI,OAAO,cAAa;AAClC,YAAM,YAAY,MAAM,KAAK,cAAc,aAAa,SAAS;AAEjE,aAAO,aAAa,KAAK,OAAO,UAAU,WAAW,SAAS;AAAA,IAC9D,CAAA,CAAC;AAAA,EAEJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,kBAAkB,cAA4B,IAAE;AAC/C,UAAA,KAAK,gBAAgB,eAAe,WAAW;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,SAAwB,IAAE;AACtC,UAAA,KAAK,gBAAgB,UAAU,MAAM;AAAA,EAC5C;AACA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customTypesApi.js","sources":["../../../src/clients/customTypesApi.ts"],"sourcesContent":["import isEqual from \"lodash.isequal\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { logPlaywrightApiResponse, logger } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\ntype ItemType = CustomType | SharedSlice;\ntype ItemTypePath = \"customtypes\" | \"slices\";\ntype ItemOperation = \"insert\" | \"update\";\n\n/**\n * Client for interacting with the Custom Types API to create/update custom\n * types and slices.\n */\nexport class CustomTypesApiClient extends AuthenticatedApiClient {\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { authToken: AuthServerToken; repository: string },\n\t) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository });\n\t}\n\n\t/**\n\t * Create or update a custom type or slice.\n\t *\n\t * @param endpoint - - The API endpoint for custom types or slices\n\t * ('customtypes' or 'slices').\n\t * @param data - - The data representing the custom type or slice.\n\t *\n\t * @throws Error if the item status cannot be retrieved or the item cannot be\n\t * created/updated.\n\t */\n\tprivate async upsert(\n\t\tendpoint: ItemTypePath,\n\t\toperation: ItemOperation,\n\t\tdata: ItemType,\n\t) {\n\t\tconst profiler = logger.startTimer();\n\t\tconst path = `${endpoint}/${operation}`;\n\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.post(path, { data });\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result);\n\t\t\tthrow new Error(`Could not ${operation} item`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `called customtypes api /${path} for item with id '${data.id}'`,\n\t\t});\n\t}\n\n\tprivate async getRemoteItems(\n\t\tendpoint: ItemTypePath,\n\t): Promise<CustomType[] | SharedSlice[]> {\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.get(endpoint);\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not get items status from the Custom Type api.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n\n\tprivate async getDifference(\n\t\tremoteItems: CustomType[] | SharedSlice[],\n\t\tlocal: ItemType,\n\t): Promise<ItemOperation | undefined> {\n\t\tconst remoteItem = remoteItems.find(\n\t\t\t(remote: CustomType | SharedSlice) => remote.id === local.id,\n\t\t);\n\t\tif (!remoteItem) {\n\t\t\treturn \"insert\";\n\t\t}\n\t\tif (!isEqual(local, remoteItem)) {\n\t\t\treturn \"update\";\n\t\t}\n\n\t\treturn;\n\t}\n\n\t/** Create items only if they have changed compared to their remote status */\n\tprivate async upsertIfChanged(\n\t\titemType: ItemTypePath,\n\t\tlocalItems: ItemType[] = [],\n\t): Promise<void> {\n\t\tconst remoteItems = await this.getRemoteItems(itemType);\n\t\tawait Promise.all(\n\t\t\tlocalItems.map(async (localItem) => {\n\t\t\t\tconst operation = await this.getDifference(remoteItems, localItem);\n\n\t\t\t\treturn operation && this.upsert(itemType, operation, localItem);\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes -\n\t */\n\tasync createCustomTypes(customTypes: CustomType[] = []): Promise<void> {\n\t\tawait this.upsertIfChanged(\"customtypes\", customTypes);\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices -\n\t */\n\tasync createSlices(slices: SharedSlice[] = []): Promise<void> {\n\t\tawait this.upsertIfChanged(\"slices\", slices);\n\t}\n}\n"],"names":[],"mappings":";;;AAmBM,MAAO,6BAA6B,uBAAsB;AAAA,EAC/D,YACC,SACA,QAA0D;AAE1D,UAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,YAAY;AAAA,
|
|
1
|
+
{"version":3,"file":"customTypesApi.js","sources":["../../../src/clients/customTypesApi.ts"],"sourcesContent":["import isEqual from \"lodash.isequal\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { logPlaywrightApiResponse, logger } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\ntype ItemType = CustomType | SharedSlice;\ntype ItemTypePath = \"customtypes\" | \"slices\";\ntype ItemOperation = \"insert\" | \"update\";\n\n/**\n * Client for interacting with the Custom Types API to create/update custom\n * types and slices.\n */\nexport class CustomTypesApiClient extends AuthenticatedApiClient {\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { authToken: AuthServerToken; repository: string },\n\t) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository });\n\t}\n\n\t/**\n\t * Create or update a custom type or slice.\n\t *\n\t * @param endpoint - - The API endpoint for custom types or slices\n\t * ('customtypes' or 'slices').\n\t * @param data - - The data representing the custom type or slice.\n\t *\n\t * @throws Error if the item status cannot be retrieved or the item cannot be\n\t * created/updated.\n\t */\n\tprivate async upsert(\n\t\tendpoint: ItemTypePath,\n\t\toperation: ItemOperation,\n\t\tdata: ItemType,\n\t) {\n\t\tconst profiler = logger.startTimer();\n\t\tconst path = `${endpoint}/${operation}`;\n\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.post(path, { data });\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result);\n\t\t\tthrow new Error(`Could not ${operation} item`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `called customtypes api /${path} for item with id '${data.id}'`,\n\t\t});\n\t}\n\n\tprivate async getRemoteItems(\n\t\tendpoint: ItemTypePath,\n\t): Promise<CustomType[] | SharedSlice[]> {\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.get(endpoint);\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not get items status from the Custom Type api.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n\n\tprivate async getDifference(\n\t\tremoteItems: CustomType[] | SharedSlice[],\n\t\tlocal: ItemType,\n\t): Promise<ItemOperation | undefined> {\n\t\tconst remoteItem = remoteItems.find(\n\t\t\t(remote: CustomType | SharedSlice) => remote.id === local.id,\n\t\t);\n\t\tif (!remoteItem) {\n\t\t\treturn \"insert\";\n\t\t}\n\t\tif (!isEqual(local, remoteItem)) {\n\t\t\treturn \"update\";\n\t\t}\n\n\t\treturn;\n\t}\n\n\t/** Create items only if they have changed compared to their remote status */\n\tprivate async upsertIfChanged(\n\t\titemType: ItemTypePath,\n\t\tlocalItems: ItemType[] = [],\n\t): Promise<void> {\n\t\tconst remoteItems = await this.getRemoteItems(itemType);\n\t\tawait Promise.all(\n\t\t\tlocalItems.map(async (localItem) => {\n\t\t\t\tconst operation = await this.getDifference(remoteItems, localItem);\n\n\t\t\t\treturn operation && this.upsert(itemType, operation, localItem);\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes -\n\t */\n\tasync createCustomTypes(customTypes: CustomType[] = []): Promise<void> {\n\t\tawait this.upsertIfChanged(\"customtypes\", customTypes);\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices -\n\t */\n\tasync createSlices(slices: SharedSlice[] = []): Promise<void> {\n\t\tawait this.upsertIfChanged(\"slices\", slices);\n\t}\n}\n"],"names":[],"mappings":";;;AAmBM,MAAO,6BAA6B,uBAAsB;AAAA,EAC/D,YACC,SACA,QAA0D;AAE1D,UAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,YAAY;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYQ,MAAM,OACb,UACA,WACA,MAAc;AAER,UAAA,WAAW,OAAO;AACxB,UAAM,OAAO,GAAG,QAAQ,IAAI,SAAS;AAE/B,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,KAAK,MAAM,EAAE,MAAM;AAC5C,QAAA,CAAC,OAAO,MAAM;AACjB,+BAAyB,MAAM;AAC/B,YAAM,IAAI,MAAM,aAAa,SAAS,OAAO;AAAA,IAC9C;AACA,aAAS,KAAK;AAAA,MACb,SAAS,2BAA2B,IAAI,sBAAsB,KAAK,EAAE;AAAA,IAAA,CACrE;AAAA,EACF;AAAA,EAEQ,MAAM,eACb,UAAsB;AAEhB,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,IAAI,QAAQ;AAErC,QAAA,CAAC,OAAO,MAAM;AACjB,+BAAyB,MAAM;AACzB,YAAA,IAAI,MAAM,sDAAsD;AAAA,IACvE;AAEA,WAAO,OAAO;EACf;AAAA,EAEQ,MAAM,cACb,aACA,OAAe;AAET,UAAA,aAAa,YAAY,KAC9B,CAAC,WAAqC,OAAO,OAAO,MAAM,EAAE;AAE7D,QAAI,CAAC,YAAY;AACT,aAAA;AAAA,IACR;AACA,QAAI,CAAC,QAAQ,OAAO,UAAU,GAAG;AACzB,aAAA;AAAA,IACR;AAEA;AAAA,EACD;AAAA;AAAA,EAGQ,MAAM,gBACb,UACA,aAAyB,IAAE;AAE3B,UAAM,cAAc,MAAM,KAAK,eAAe,QAAQ;AACtD,UAAM,QAAQ,IACb,WAAW,IAAI,OAAO,cAAa;AAClC,YAAM,YAAY,MAAM,KAAK,cAAc,aAAa,SAAS;AAEjE,aAAO,aAAa,KAAK,OAAO,UAAU,WAAW,SAAS;AAAA,IAC9D,CAAA,CAAC;AAAA,EAEJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,kBAAkB,cAA4B,IAAE;AAC/C,UAAA,KAAK,gBAAgB,eAAe,WAAW;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,SAAwB,IAAE;AACtC,UAAA,KAAK,gBAAgB,UAAU,MAAM;AAAA,EAC5C;AACA;"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
-
var __publicField = (obj, key, value) =>
|
|
4
|
+
var __publicField = (obj, key, value) => {
|
|
5
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
+
return value;
|
|
7
|
+
};
|
|
5
8
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
9
|
const axios = require("axios");
|
|
7
10
|
const jwt = require("jsonwebtoken");
|
|
@@ -17,8 +20,8 @@ class ManageV2Client {
|
|
|
17
20
|
// Not private to have it available on tests
|
|
18
21
|
__publicField(this, "token", null);
|
|
19
22
|
/**
|
|
20
|
-
* The function `toggleRolePerLocal`
|
|
21
|
-
*
|
|
23
|
+
* The function `toggleRolePerLocal` enables or disables the RolesPerLocale
|
|
24
|
+
* workflow
|
|
22
25
|
*
|
|
23
26
|
* @param repository - The Repository name
|
|
24
27
|
* @param enabled - The feature new status
|
|
@@ -30,6 +33,20 @@ class ManageV2Client {
|
|
|
30
33
|
author: ManageV2StaticAuthor
|
|
31
34
|
});
|
|
32
35
|
}));
|
|
36
|
+
/**
|
|
37
|
+
* The function `toggleCustomRoles` enables or disables the CustomRoles
|
|
38
|
+
* workflow
|
|
39
|
+
*
|
|
40
|
+
* @param repository - The Repository name
|
|
41
|
+
* @param enabled - The feature new status
|
|
42
|
+
*/
|
|
43
|
+
__publicField(this, "toggleCustomRoles", this.assertTokenExist((params) => {
|
|
44
|
+
return this.client.post("/repository/toggleCustomRoles", {
|
|
45
|
+
domain: params.repository,
|
|
46
|
+
enabled: params.enabled,
|
|
47
|
+
author: ManageV2StaticAuthor
|
|
48
|
+
});
|
|
49
|
+
}));
|
|
33
50
|
/**
|
|
34
51
|
* The function `changePlan` changes the plan of a repository the database
|
|
35
52
|
*
|
|
@@ -95,9 +112,8 @@ class ManageV2Client {
|
|
|
95
112
|
* The function generates a JWT token using the provided configuration
|
|
96
113
|
* parameters.
|
|
97
114
|
*
|
|
98
|
-
* @param
|
|
99
|
-
*
|
|
100
|
-
* following properties:
|
|
115
|
+
* @param config - The `config` parameter in the `generateToken` function is
|
|
116
|
+
* of type `ManageV2Config`. It contains the following properties:
|
|
101
117
|
*
|
|
102
118
|
* @returns A JSON Web Token (JWT) is being returned by the `generateToken`
|
|
103
119
|
* function. The token is signed using the provided `config.secret` with the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manageV2.cjs","sources":["../../../src/clients/manageV2.ts"],"sourcesContent":["import axios, { AxiosInstance, AxiosResponse } from \"axios\";\nimport jwt from \"jsonwebtoken\";\n\nimport { ManageV2Config } from \"../types\";\n\nimport { extractCookie } from \"../utils/cookies\";\n\nconst ManageV2StaticAuthor = \"prismic-e2e-tests-utils\";\n\n/**\n * Client for interacting with ManageV2 routes to perform operations on\n * repositories.\n */\nexport class ManageV2Client {\n\treadonly client: AxiosInstance; // Not private to have it available on tests\n\tprivate token: string | null = null;\n\n\t/**\n\t * @param baseURL - The base URL of the Wroom app. ex: https://prismic.io\n\t * @param config - ManageV2 configuration variable to call ManageV2.\n\t */\n\tconstructor(baseUrl: string, config?: ManageV2Config | undefined) {\n\t\tthis.token = config ? this.generateToken(config) : null;\n\n\t\tthis.client = axios.create({\n\t\t\tbaseURL: `${baseUrl}/manageroutes/`,\n\t\t\twithCredentials: true,\n\t\t\tvalidateStatus: () => true,\n\t\t\theaders: {\n\t\t\t\t\"User-Agent\": \"prismic-cli/prismic-e2e-tests-utils\",\n\t\t\t\tAuthorization: `Bearer ${this.token}`,\n\t\t\t},\n\t\t});\n\n\t\t// cookies are not forwarded automatically in a non-browser env\n\t\tthis.client.interceptors.response.use((response) => {\n\t\t\tconst cookies = response.headers[\"set-cookie\"];\n\t\t\tif (cookies && extractCookie(cookies, \"prismic-auth\")) {\n\t\t\t\tthis.client.defaults.headers[\"Cookie\"] = cookies;\n\t\t\t}\n\n\t\t\treturn response;\n\t\t});\n\t}\n\n\t/**\n\t * The function generates a JWT token using the provided configuration\n\t * parameters.\n\t *\n\t * @param
|
|
1
|
+
{"version":3,"file":"manageV2.cjs","sources":["../../../src/clients/manageV2.ts"],"sourcesContent":["import axios, { AxiosInstance, AxiosResponse } from \"axios\";\nimport jwt from \"jsonwebtoken\";\n\nimport { ManageV2Config } from \"../types\";\n\nimport { extractCookie } from \"../utils/cookies\";\n\nconst ManageV2StaticAuthor = \"prismic-e2e-tests-utils\";\n\n/**\n * Client for interacting with ManageV2 routes to perform operations on\n * repositories.\n */\nexport class ManageV2Client {\n\treadonly client: AxiosInstance; // Not private to have it available on tests\n\tprivate token: string | null = null;\n\n\t/**\n\t * @param baseURL - The base URL of the Wroom app. ex: https://prismic.io\n\t * @param config - ManageV2 configuration variable to call ManageV2.\n\t */\n\tconstructor(baseUrl: string, config?: ManageV2Config | undefined) {\n\t\tthis.token = config ? this.generateToken(config) : null;\n\n\t\tthis.client = axios.create({\n\t\t\tbaseURL: `${baseUrl}/manageroutes/`,\n\t\t\twithCredentials: true,\n\t\t\tvalidateStatus: () => true,\n\t\t\theaders: {\n\t\t\t\t\"User-Agent\": \"prismic-cli/prismic-e2e-tests-utils\",\n\t\t\t\tAuthorization: `Bearer ${this.token}`,\n\t\t\t},\n\t\t});\n\n\t\t// cookies are not forwarded automatically in a non-browser env\n\t\tthis.client.interceptors.response.use((response) => {\n\t\t\tconst cookies = response.headers[\"set-cookie\"];\n\t\t\tif (cookies && extractCookie(cookies, \"prismic-auth\")) {\n\t\t\t\tthis.client.defaults.headers[\"Cookie\"] = cookies;\n\t\t\t}\n\n\t\t\treturn response;\n\t\t});\n\t}\n\n\t/**\n\t * The function generates a JWT token using the provided configuration\n\t * parameters.\n\t *\n\t * @param config - The `config` parameter in the `generateToken` function is\n\t * of type `ManageV2Config`. It contains the following properties:\n\t *\n\t * @returns A JSON Web Token (JWT) is being returned by the `generateToken`\n\t * function. The token is signed using the provided `config.secret` with the\n\t * HS256 algorithm and includes the specified audience and issuer values.\n\t */\n\tprivate generateToken(config: ManageV2Config): string {\n\t\treturn jwt.sign({}, config.secret, {\n\t\t\talgorithm: \"HS256\",\n\t\t\taudience: config.audience,\n\t\t\tissuer: \"prismic.io\",\n\t\t});\n\t}\n\n\t/**\n\t * The function `assertTokenExist` checks if a token exists before executing a\n\t * given function.\n\t *\n\t * @param f - The `assertTokenExist` function takes a function `f` as a\n\t * parameter. This function `f` should accept a parameter of type\n\t * `Parameters` and return a Promise that resolves to an AxiosResponse. The\n\t * `assertTokenExist` function ensures that a token is not null before\n\t * calling the provided\n\t *\n\t * @returns A function is being returned that takes a parameter of type\n\t * Parameters and checks if the token is null. If the token is null, an\n\t * error is thrown. Otherwise, the function f is called with the provided\n\t * parameters.\n\t */\n\tprivate assertTokenExist<Parameters>(\n\t\tf: (_: Parameters) => Promise<AxiosResponse>,\n\t) {\n\t\treturn (params: Parameters) => {\n\t\t\tif (this.token === null) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Undefined configuration for ManageV2 while trying to use it's routes\",\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\treturn f(params);\n\t\t\t}\n\t\t};\n\t}\n\n\tgetBaseURL(): string {\n\t\treturn this.client.getUri();\n\t}\n\n\t/**\n\t * The function `toggleRolePerLocal` enables or disables the RolesPerLocale\n\t * workflow\n\t *\n\t * @param repository - The Repository name\n\t * @param enabled - The feature new status\n\t */\n\ttoggleRolePerLocal = this.assertTokenExist(\n\t\t(params: { repository: string; enabled: boolean }) => {\n\t\t\treturn this.client.post(\"/repository/toggleRolesPerLocale\", {\n\t\t\t\tdomain: params.repository,\n\t\t\t\tenabled: params.enabled,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n\n\t/**\n\t * The function `toggleCustomRoles` enables or disables the CustomRoles\n\t * workflow\n\t *\n\t * @param repository - The Repository name\n\t * @param enabled - The feature new status\n\t */\n\ttoggleCustomRoles = this.assertTokenExist(\n\t\t(params: { repository: string; enabled: boolean }) => {\n\t\t\treturn this.client.post(\"/repository/toggleCustomRoles\", {\n\t\t\t\tdomain: params.repository,\n\t\t\t\tenabled: params.enabled,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n\n\t/**\n\t * The function `changePlan` changes the plan of a repository the database\n\t *\n\t * @param repository - The Repository name\n\t * @param newPlanId - The new planId\n\t * @param bypassManualBilling - Beware that using this will not verify that\n\t * the database and Stripe are in sync\n\t */\n\tchangePlan = this.assertTokenExist(\n\t\t({\n\t\t\trepository,\n\t\t\tnewPlanId,\n\t\t\tbypassManualBilling = false,\n\t\t}: {\n\t\t\trepository: string;\n\t\t\tnewPlanId: string;\n\t\t\tbypassManualBilling?: boolean;\n\t\t}) => {\n\t\t\treturn this.client.post(\n\t\t\t\t`/repository/changePlan?bypassManualBilling=${bypassManualBilling}`,\n\t\t\t\t{\n\t\t\t\t\tdomain: repository,\n\t\t\t\t\tnewPlan: newPlanId,\n\t\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t);\n\n\t/**\n\t * The function `addUserToRepository` adds a user corresponding to the email\n\t * to the given repository\n\t *\n\t * @param repository - The Repository name\n\t * @param email - The user email\n\t */\n\taddUserToRepository = this.assertTokenExist(\n\t\t({ repository, email }: { repository: string; email: string }) => {\n\t\t\treturn this.client.post(\"/repository/addUser\", {\n\t\t\t\tdomain: repository,\n\t\t\t\temail: email,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n\n\t/**\n\t * The function `removeUserFromRepository` removes a user corresponding to the\n\t * email from the given repository\n\t *\n\t * @param repository - The Repository name\n\t * @param email - The user email\n\t */\n\tremoveUserFromRepository = this.assertTokenExist(\n\t\t({ repository, email }: { repository: string; email: string }) => {\n\t\t\treturn this.client.post(\"/repository/removeUser\", {\n\t\t\t\tdomain: repository,\n\t\t\t\temail: email,\n\t\t\t\tauthor: ManageV2StaticAuthor,\n\t\t\t});\n\t\t},\n\t);\n}\n"],"names":["cookies","extractCookie"],"mappings":";;;;;;;;;;;AAOA,MAAM,uBAAuB;MAMhB,eAAc;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ1B,YAAY,SAAiB,QAAmC;AAPvD;AACD;AAAA,iCAAuB;AAyF/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8CAAqB,KAAK,iBACzB,CAAC,WAAoD;AAC7C,aAAA,KAAK,OAAO,KAAK,oCAAoC;AAAA,QAC3D,QAAQ,OAAO;AAAA,QACf,SAAS,OAAO;AAAA,QAChB,QAAQ;AAAA,MAAA,CACR;AAAA,IAAA,CACD;AAUF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6CAAoB,KAAK,iBACxB,CAAC,WAAoD;AAC7C,aAAA,KAAK,OAAO,KAAK,iCAAiC;AAAA,QACxD,QAAQ,OAAO;AAAA,QACf,SAAS,OAAO;AAAA,QAChB,QAAQ;AAAA,MAAA,CACR;AAAA,IAAA,CACD;AAWF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAAa,KAAK,iBACjB,CAAC,EACA,YACA,WACA,sBAAsB,YAKlB;AACJ,aAAO,KAAK,OAAO,KAClB,8CAA8C,mBAAmB,IACjE;AAAA,QACC,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,QAAQ;AAAA,MAAA,CACR;AAAA,IAAA,CAEF;AAUF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+CAAsB,KAAK,iBAC1B,CAAC,EAAE,YAAY,YAAkD;AACzD,aAAA,KAAK,OAAO,KAAK,uBAAuB;AAAA,QAC9C,QAAQ;AAAA,QACR;AAAA,QACA,QAAQ;AAAA,MAAA,CACR;AAAA,IAAA,CACD;AAUF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oDAA2B,KAAK,iBAC/B,CAAC,EAAE,YAAY,YAAkD;AACzD,aAAA,KAAK,OAAO,KAAK,0BAA0B;AAAA,QACjD,QAAQ;AAAA,QACR;AAAA,QACA,QAAQ;AAAA,MAAA,CACR;AAAA,IAAA,CACD;AAzKD,SAAK,QAAQ,SAAS,KAAK,cAAc,MAAM,IAAI;AAE9C,SAAA,SAAS,MAAM,OAAO;AAAA,MAC1B,SAAS,GAAG,OAAO;AAAA,MACnB,iBAAiB;AAAA,MACjB,gBAAgB,MAAM;AAAA,MACtB,SAAS;AAAA,QACR,cAAc;AAAA,QACd,eAAe,UAAU,KAAK,KAAK;AAAA,MACnC;AAAA,IAAA,CACD;AAGD,SAAK,OAAO,aAAa,SAAS,IAAI,CAAC,aAAY;AAC5C,YAAAA,YAAU,SAAS,QAAQ,YAAY;AAC7C,UAAIA,aAAWC,QAAAA,cAAcD,WAAS,cAAc,GAAG;AACtD,aAAK,OAAO,SAAS,QAAQ,QAAQ,IAAIA;AAAAA,MAC1C;AAEO,aAAA;AAAA,IAAA,CACP;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaQ,cAAc,QAAsB;AAC3C,WAAO,IAAI,KAAK,IAAI,OAAO,QAAQ;AAAA,MAClC,WAAW;AAAA,MACX,UAAU,OAAO;AAAA,MACjB,QAAQ;AAAA,IAAA,CACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBQ,iBACP,GAA4C;AAE5C,WAAO,CAAC,WAAsB;AACzB,UAAA,KAAK,UAAU,MAAM;AAClB,cAAA,IAAI,MACT,sEAAsE;AAAA,MAAA,OAEjE;AACN,eAAO,EAAE,MAAM;AAAA,MAChB;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,aAAU;AACF,WAAA,KAAK,OAAO;EACpB;AAkGA;;"}
|
|
@@ -16,9 +16,8 @@ export declare class ManageV2Client {
|
|
|
16
16
|
* The function generates a JWT token using the provided configuration
|
|
17
17
|
* parameters.
|
|
18
18
|
*
|
|
19
|
-
* @param
|
|
20
|
-
*
|
|
21
|
-
* following properties:
|
|
19
|
+
* @param config - The `config` parameter in the `generateToken` function is
|
|
20
|
+
* of type `ManageV2Config`. It contains the following properties:
|
|
22
21
|
*
|
|
23
22
|
* @returns A JSON Web Token (JWT) is being returned by the `generateToken`
|
|
24
23
|
* function. The token is signed using the provided `config.secret` with the
|
|
@@ -43,8 +42,8 @@ export declare class ManageV2Client {
|
|
|
43
42
|
private assertTokenExist;
|
|
44
43
|
getBaseURL(): string;
|
|
45
44
|
/**
|
|
46
|
-
* The function `toggleRolePerLocal`
|
|
47
|
-
*
|
|
45
|
+
* The function `toggleRolePerLocal` enables or disables the RolesPerLocale
|
|
46
|
+
* workflow
|
|
48
47
|
*
|
|
49
48
|
* @param repository - The Repository name
|
|
50
49
|
* @param enabled - The feature new status
|
|
@@ -53,6 +52,17 @@ export declare class ManageV2Client {
|
|
|
53
52
|
repository: string;
|
|
54
53
|
enabled: boolean;
|
|
55
54
|
}) => Promise<AxiosResponse<any, any>>;
|
|
55
|
+
/**
|
|
56
|
+
* The function `toggleCustomRoles` enables or disables the CustomRoles
|
|
57
|
+
* workflow
|
|
58
|
+
*
|
|
59
|
+
* @param repository - The Repository name
|
|
60
|
+
* @param enabled - The feature new status
|
|
61
|
+
*/
|
|
62
|
+
toggleCustomRoles: (params: {
|
|
63
|
+
repository: string;
|
|
64
|
+
enabled: boolean;
|
|
65
|
+
}) => Promise<AxiosResponse<any, any>>;
|
|
56
66
|
/**
|
|
57
67
|
* The function `changePlan` changes the plan of a repository the database
|
|
58
68
|
*
|
|
@@ -64,7 +74,7 @@ export declare class ManageV2Client {
|
|
|
64
74
|
changePlan: (params: {
|
|
65
75
|
repository: string;
|
|
66
76
|
newPlanId: string;
|
|
67
|
-
bypassManualBilling?: boolean;
|
|
77
|
+
bypassManualBilling?: boolean | undefined;
|
|
68
78
|
}) => Promise<AxiosResponse<any, any>>;
|
|
69
79
|
/**
|
|
70
80
|
* The function `addUserToRepository` adds a user corresponding to the email
|