@prismicio/e2e-tests-utils 1.18.0 → 1.19.0-canary.d349d21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -27
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/clients/apiClient.cjs +38 -38
- package/dist/clients/apiClient.cjs.map +1 -1
- package/dist/clients/apiClient.d.cts +30 -0
- package/dist/clients/apiClient.d.cts.map +1 -0
- package/dist/clients/apiClient.d.ts +23 -23
- package/dist/clients/apiClient.d.ts.map +1 -0
- package/dist/clients/apiClient.js +38 -38
- package/dist/clients/apiClient.js.map +1 -1
- package/dist/clients/assetApi.cjs +81 -93
- package/dist/clients/assetApi.cjs.map +1 -1
- package/dist/clients/assetApi.d.cts +105 -0
- package/dist/clients/assetApi.d.cts.map +1 -0
- package/dist/clients/assetApi.d.ts +96 -97
- package/dist/clients/assetApi.d.ts.map +1 -0
- package/dist/clients/assetApi.js +79 -91
- package/dist/clients/assetApi.js.map +1 -1
- package/dist/clients/authenticationApi.cjs +66 -73
- package/dist/clients/authenticationApi.cjs.map +1 -1
- package/dist/clients/authenticationApi.d.cts +20 -0
- package/dist/clients/authenticationApi.d.cts.map +1 -0
- package/dist/clients/authenticationApi.d.ts +18 -13
- package/dist/clients/authenticationApi.d.ts.map +1 -0
- package/dist/clients/authenticationApi.js +65 -72
- package/dist/clients/authenticationApi.js.map +1 -1
- package/dist/clients/contentApi.cjs +94 -103
- package/dist/clients/contentApi.cjs.map +1 -1
- package/dist/clients/contentApi.d.cts +116 -0
- package/dist/clients/contentApi.d.cts.map +1 -0
- package/dist/clients/contentApi.d.ts +102 -98
- package/dist/clients/contentApi.d.ts.map +1 -0
- package/dist/clients/contentApi.js +94 -103
- package/dist/clients/contentApi.js.map +1 -1
- package/dist/clients/coreApi.cjs +154 -145
- package/dist/clients/coreApi.cjs.map +1 -1
- package/dist/clients/coreApi.d.cts +143 -0
- package/dist/clients/coreApi.d.cts.map +1 -0
- package/dist/clients/coreApi.d.ts +132 -109
- package/dist/clients/coreApi.d.ts.map +1 -0
- package/dist/clients/coreApi.js +153 -144
- package/dist/clients/coreApi.js.map +1 -1
- package/dist/clients/customTypesApi.cjs +90 -99
- package/dist/clients/customTypesApi.cjs.map +1 -1
- package/dist/clients/customTypesApi.d.cts +46 -0
- package/dist/clients/customTypesApi.d.cts.map +1 -0
- package/dist/clients/customTypesApi.d.ts +45 -45
- package/dist/clients/customTypesApi.d.ts.map +1 -0
- package/dist/clients/customTypesApi.js +87 -98
- package/dist/clients/customTypesApi.js.map +1 -1
- package/dist/clients/integrationFields.cjs +96 -87
- package/dist/clients/integrationFields.cjs.map +1 -1
- package/dist/clients/integrationFields.d.cts +30 -0
- package/dist/clients/integrationFields.d.cts.map +1 -0
- package/dist/clients/integrationFields.d.ts +27 -22
- package/dist/clients/integrationFields.d.ts.map +1 -0
- package/dist/clients/integrationFields.js +93 -86
- package/dist/clients/integrationFields.js.map +1 -1
- package/dist/clients/manageV2.cjs +154 -171
- package/dist/clients/manageV2.cjs.map +1 -1
- package/dist/clients/manageV2.d.cts +105 -0
- package/dist/clients/manageV2.d.cts.map +1 -0
- package/dist/clients/manageV2.d.ts +103 -111
- package/dist/clients/manageV2.d.ts.map +1 -0
- package/dist/clients/manageV2.js +149 -169
- package/dist/clients/manageV2.js.map +1 -1
- package/dist/clients/migrationApi.cjs +37 -36
- package/dist/clients/migrationApi.cjs.map +1 -1
- package/dist/clients/migrationApi.d.cts +48 -0
- package/dist/clients/migrationApi.d.cts.map +1 -0
- package/dist/clients/migrationApi.d.ts +45 -39
- package/dist/clients/migrationApi.d.ts.map +1 -0
- package/dist/clients/migrationApi.js +35 -34
- package/dist/clients/migrationApi.js.map +1 -1
- package/dist/clients/wroom.cjs +101 -122
- package/dist/clients/wroom.cjs.map +1 -1
- package/dist/clients/wroom.d.cts +48 -0
- package/dist/clients/wroom.d.cts.map +1 -0
- package/dist/clients/wroom.d.ts +46 -47
- package/dist/clients/wroom.d.ts.map +1 -0
- package/dist/clients/wroom.js +99 -122
- package/dist/clients/wroom.js.map +1 -1
- package/dist/index.cjs +13 -15
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -7
- package/dist/index.js +5 -14
- package/dist/managers/repositories.cjs +159 -169
- package/dist/managers/repositories.cjs.map +1 -1
- package/dist/managers/repositories.d.cts +67 -0
- package/dist/managers/repositories.d.cts.map +1 -0
- package/dist/managers/repositories.d.ts +56 -63
- package/dist/managers/repositories.d.ts.map +1 -0
- package/dist/managers/repositories.js +148 -159
- package/dist/managers/repositories.js.map +1 -1
- package/dist/managers/repository.cjs +595 -616
- package/dist/managers/repository.cjs.map +1 -1
- package/dist/managers/repository.d.cts +341 -0
- package/dist/managers/repository.d.cts.map +1 -0
- package/dist/managers/repository.d.ts +336 -307
- package/dist/managers/repository.d.ts.map +1 -0
- package/dist/managers/repository.js +595 -616
- package/dist/managers/repository.js.map +1 -1
- package/dist/types.d.cts +41 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +35 -37
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/cookies.cjs +19 -17
- package/dist/utils/cookies.cjs.map +1 -1
- package/dist/utils/cookies.js +20 -18
- package/dist/utils/cookies.js.map +1 -1
- package/dist/utils/envVariableManager.cjs +33 -34
- package/dist/utils/envVariableManager.cjs.map +1 -1
- package/dist/utils/envVariableManager.js +34 -35
- package/dist/utils/envVariableManager.js.map +1 -1
- package/dist/utils/log.cjs +18 -19
- package/dist/utils/log.cjs.map +1 -1
- package/dist/utils/log.js +18 -21
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/random.cjs +13 -6
- package/dist/utils/random.cjs.map +1 -1
- package/dist/utils/random.js +13 -6
- package/dist/utils/random.js.map +1 -1
- package/dist/utils/strings.cjs +13 -7
- package/dist/utils/strings.cjs.map +1 -1
- package/dist/utils/strings.js +14 -8
- package/dist/utils/strings.js.map +1 -1
- package/dist/utils/urls.cjs +21 -10
- package/dist/utils/urls.cjs.map +1 -1
- package/dist/utils/urls.js +22 -12
- package/dist/utils/urls.js.map +1 -1
- package/package.json +42 -67
- package/src/clients/apiClient.ts +16 -21
- package/src/clients/assetApi.ts +75 -82
- package/src/clients/authenticationApi.ts +54 -27
- package/src/clients/contentApi.ts +111 -129
- package/src/clients/coreApi.ts +166 -117
- package/src/clients/customTypesApi.ts +54 -74
- package/src/clients/integrationFields.ts +59 -74
- package/src/clients/manageV2.ts +72 -96
- package/src/clients/migrationApi.ts +35 -39
- package/src/clients/wroom.ts +42 -56
- package/src/index.ts +7 -7
- package/src/managers/repositories.ts +85 -108
- package/src/managers/repository.ts +410 -378
- package/src/types.ts +31 -31
- package/src/utils/cookies.ts +8 -8
- package/src/utils/envVariableManager.ts +15 -15
- package/src/utils/log.ts +17 -21
- package/src/utils/random.ts +5 -6
- package/src/utils/strings.ts +7 -9
- package/src/utils/urls.ts +10 -12
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/utils/cookies.d.ts +0 -8
- package/dist/utils/envVariableManager.d.ts +0 -16
- package/dist/utils/log.d.ts +0 -5
- package/dist/utils/random.d.ts +0 -8
- package/dist/utils/strings.d.ts +0 -11
- package/dist/utils/urls.d.ts +0 -16
package/dist/utils/log.cjs
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const winston = require("winston");
|
|
1
|
+
let winston = require("winston");
|
|
2
|
+
//#region src/utils/log.ts
|
|
4
3
|
const logHttpResponse = (response) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const { status, data } = response;
|
|
5
|
+
const { baseURL = "", url = "" } = response.config;
|
|
6
|
+
const fullUrl = url.startsWith("http") ? url : `${baseURL}/${url}`;
|
|
7
|
+
logger.info(`Call to ${fullUrl} failed, received [${status}] ${JSON.stringify(data)}`);
|
|
9
8
|
};
|
|
10
9
|
const logPlaywrightApiResponse = async (response) => {
|
|
11
|
-
|
|
10
|
+
logger.info(`Call to ${response.url()} failed, received [${response.status()}] ${JSON.stringify(await response.text())}`);
|
|
12
11
|
};
|
|
13
12
|
const { combine, printf } = winston.format;
|
|
14
13
|
const customFormat = printf(({ message, durationMs }) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
return baseMsg;
|
|
14
|
+
const baseMsg = `[test data] ${message}`;
|
|
15
|
+
if (durationMs) return `${baseMsg} in ${durationMs}ms`;
|
|
16
|
+
return baseMsg;
|
|
20
17
|
});
|
|
21
|
-
const logger = winston.createLogger({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
const logger = (0, winston.createLogger)({
|
|
19
|
+
silent: process.env["prismic_e2e_tests_utils_silent"] === "true",
|
|
20
|
+
level: process.env["prismic_e2e_tests_utils_log_level"] || "info",
|
|
21
|
+
format: combine(customFormat),
|
|
22
|
+
transports: [new winston.transports.Console()]
|
|
26
23
|
});
|
|
24
|
+
//#endregion
|
|
27
25
|
exports.logHttpResponse = logHttpResponse;
|
|
28
26
|
exports.logPlaywrightApiResponse = logPlaywrightApiResponse;
|
|
29
27
|
exports.logger = logger;
|
|
30
|
-
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=log.cjs.map
|
package/dist/utils/log.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"log.cjs","names":["format","transports"],"sources":["../../src/utils/log.ts"],"sourcesContent":["import type { APIResponse } from \"@playwright/test\"\nimport type { AxiosResponse } from \"axios\"\nimport { createLogger, format, transports } from \"winston\"\n\nexport const logHttpResponse = (response: AxiosResponse): void => {\n\tconst { status, data } = response\n\tconst { baseURL = \"\", url = \"\" } = response.config\n\t// make sure the url always shows baseURL + path.\n\t// Depending on how the AxiosInstance was called, the url already contains the baseURL\n\tconst fullUrl = url.startsWith(\"http\") ? url : `${baseURL}/${url}`\n\n\tlogger.info(`Call to ${fullUrl} failed, received [${status}] ${JSON.stringify(data)}`)\n}\n\nexport const logPlaywrightApiResponse = async (response: APIResponse): Promise<void> => {\n\tlogger.info(\n\t\t`Call to ${response.url()} failed, received [${response.status()}] ${JSON.stringify(\n\t\t\tawait response.text(),\n\t\t)}`,\n\t)\n}\n\nconst { combine, printf } = format\n\nconst customFormat = printf(({ message, durationMs }) => {\n\tconst baseMsg = `[test data] ${message}`\n\tif (durationMs) {\n\t\treturn `${baseMsg} in ${durationMs}ms`\n\t}\n\n\treturn baseMsg\n})\n\nexport const logger = createLogger({\n\tsilent: process.env[\"prismic_e2e_tests_utils_silent\"] === \"true\",\n\tlevel: process.env[\"prismic_e2e_tests_utils_log_level\"] || \"info\",\n\tformat: combine(customFormat),\n\ttransports: [new transports.Console()],\n})\n"],"mappings":";;AAIA,MAAa,mBAAmB,aAAkC;CACjE,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,UAAU,IAAI,MAAM,OAAO,SAAS;CAG5C,MAAM,UAAU,IAAI,WAAW,MAAM,IAAI,MAAM,GAAG,QAAQ,GAAG;CAE7D,OAAO,KAAK,WAAW,QAAQ,qBAAqB,OAAO,IAAI,KAAK,UAAU,IAAI,GAAG;AACtF;AAEA,MAAa,2BAA2B,OAAO,aAAyC;CACvF,OAAO,KACN,WAAW,SAAS,IAAI,EAAE,qBAAqB,SAAS,OAAO,EAAE,IAAI,KAAK,UACzE,MAAM,SAAS,KAAK,CACrB,GACD;AACD;AAEA,MAAM,EAAE,SAAS,WAAWA,QAAAA;AAE5B,MAAM,eAAe,QAAQ,EAAE,SAAS,iBAAiB;CACxD,MAAM,UAAU,eAAe;CAC/B,IAAI,YACH,OAAO,GAAG,QAAQ,MAAM,WAAW;CAGpC,OAAO;AACR,CAAC;AAED,MAAa,UAAA,GAAA,QAAA,aAAA,CAAsB;CAClC,QAAQ,QAAQ,IAAI,sCAAsC;CAC1D,OAAO,QAAQ,IAAI,wCAAwC;CAC3D,QAAQ,QAAQ,YAAY;CAC5B,YAAY,CAAC,IAAIC,QAAAA,WAAW,QAAQ,CAAC;AACtC,CAAC"}
|
package/dist/utils/log.js
CHANGED
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
import { createLogger,
|
|
1
|
+
import { createLogger, format, transports } from "winston";
|
|
2
|
+
//#region src/utils/log.ts
|
|
2
3
|
const logHttpResponse = (response) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const { status, data } = response;
|
|
5
|
+
const { baseURL = "", url = "" } = response.config;
|
|
6
|
+
const fullUrl = url.startsWith("http") ? url : `${baseURL}/${url}`;
|
|
7
|
+
logger.info(`Call to ${fullUrl} failed, received [${status}] ${JSON.stringify(data)}`);
|
|
7
8
|
};
|
|
8
9
|
const logPlaywrightApiResponse = async (response) => {
|
|
9
|
-
|
|
10
|
+
logger.info(`Call to ${response.url()} failed, received [${response.status()}] ${JSON.stringify(await response.text())}`);
|
|
10
11
|
};
|
|
11
12
|
const { combine, printf } = format;
|
|
12
13
|
const customFormat = printf(({ message, durationMs }) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
return baseMsg;
|
|
14
|
+
const baseMsg = `[test data] ${message}`;
|
|
15
|
+
if (durationMs) return `${baseMsg} in ${durationMs}ms`;
|
|
16
|
+
return baseMsg;
|
|
18
17
|
});
|
|
19
18
|
const logger = createLogger({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
silent: process.env["prismic_e2e_tests_utils_silent"] === "true",
|
|
20
|
+
level: process.env["prismic_e2e_tests_utils_log_level"] || "info",
|
|
21
|
+
format: combine(customFormat),
|
|
22
|
+
transports: [new transports.Console()]
|
|
24
23
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=log.js.map
|
|
24
|
+
//#endregion
|
|
25
|
+
export { logHttpResponse, logPlaywrightApiResponse, logger };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=log.js.map
|
package/dist/utils/log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sources":["
|
|
1
|
+
{"version":3,"file":"log.js","names":[],"sources":["../../src/utils/log.ts"],"sourcesContent":["import type { APIResponse } from \"@playwright/test\"\nimport type { AxiosResponse } from \"axios\"\nimport { createLogger, format, transports } from \"winston\"\n\nexport const logHttpResponse = (response: AxiosResponse): void => {\n\tconst { status, data } = response\n\tconst { baseURL = \"\", url = \"\" } = response.config\n\t// make sure the url always shows baseURL + path.\n\t// Depending on how the AxiosInstance was called, the url already contains the baseURL\n\tconst fullUrl = url.startsWith(\"http\") ? url : `${baseURL}/${url}`\n\n\tlogger.info(`Call to ${fullUrl} failed, received [${status}] ${JSON.stringify(data)}`)\n}\n\nexport const logPlaywrightApiResponse = async (response: APIResponse): Promise<void> => {\n\tlogger.info(\n\t\t`Call to ${response.url()} failed, received [${response.status()}] ${JSON.stringify(\n\t\t\tawait response.text(),\n\t\t)}`,\n\t)\n}\n\nconst { combine, printf } = format\n\nconst customFormat = printf(({ message, durationMs }) => {\n\tconst baseMsg = `[test data] ${message}`\n\tif (durationMs) {\n\t\treturn `${baseMsg} in ${durationMs}ms`\n\t}\n\n\treturn baseMsg\n})\n\nexport const logger = createLogger({\n\tsilent: process.env[\"prismic_e2e_tests_utils_silent\"] === \"true\",\n\tlevel: process.env[\"prismic_e2e_tests_utils_log_level\"] || \"info\",\n\tformat: combine(customFormat),\n\ttransports: [new transports.Console()],\n})\n"],"mappings":";;AAIA,MAAa,mBAAmB,aAAkC;CACjE,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,UAAU,IAAI,MAAM,OAAO,SAAS;CAG5C,MAAM,UAAU,IAAI,WAAW,MAAM,IAAI,MAAM,GAAG,QAAQ,GAAG;CAE7D,OAAO,KAAK,WAAW,QAAQ,qBAAqB,OAAO,IAAI,KAAK,UAAU,IAAI,GAAG;AACtF;AAEA,MAAa,2BAA2B,OAAO,aAAyC;CACvF,OAAO,KACN,WAAW,SAAS,IAAI,EAAE,qBAAqB,SAAS,OAAO,EAAE,IAAI,KAAK,UACzE,MAAM,SAAS,KAAK,CACrB,GACD;AACD;AAEA,MAAM,EAAE,SAAS,WAAW;AAE5B,MAAM,eAAe,QAAQ,EAAE,SAAS,iBAAiB;CACxD,MAAM,UAAU,eAAe;CAC/B,IAAI,YACH,OAAO,GAAG,QAAQ,MAAM,WAAW;CAGpC,OAAO;AACR,CAAC;AAED,MAAa,SAAS,aAAa;CAClC,QAAQ,QAAQ,IAAI,sCAAsC;CAC1D,OAAO,QAAQ,IAAI,wCAAwC;CAC3D,QAAQ,QAAQ,YAAY;CAC5B,YAAY,CAAC,IAAI,WAAW,QAAQ,CAAC;AACtC,CAAC"}
|
package/dist/utils/random.cjs
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
let crypto = require("crypto");
|
|
2
|
+
//#region src/utils/random.ts
|
|
3
|
+
/**
|
|
4
|
+
* Generate a random string
|
|
5
|
+
*
|
|
6
|
+
* @param length - Max 32
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
4
9
|
const randomString = (length = 16) => {
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
const uniqueInput = Math.random().toString();
|
|
11
|
+
return (0, crypto.createHash)("md5").update(uniqueInput).digest("hex").slice(0, length);
|
|
7
12
|
};
|
|
13
|
+
//#endregion
|
|
8
14
|
exports.randomString = randomString;
|
|
9
|
-
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=random.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"random.cjs","names":[],"sources":["../../src/utils/random.ts"],"sourcesContent":["import { createHash } from \"crypto\"\n\n/**\n * Generate a random string\n *\n * @param length - Max 32\n * @returns\n */\nexport const randomString = (length = 16): string => {\n\tconst uniqueInput = Math.random().toString()\n\n\treturn createHash(\"md5\").update(uniqueInput).digest(\"hex\").slice(0, length)\n}\n"],"mappings":";;;;;;;;AAQA,MAAa,gBAAgB,SAAS,OAAe;CACpD,MAAM,cAAc,KAAK,OAAO,CAAC,CAAC,SAAS;CAE3C,QAAA,GAAA,OAAA,WAAA,CAAkB,KAAK,CAAC,CAAC,OAAO,WAAW,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,MAAM;AAC3E"}
|
package/dist/utils/random.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { createHash } from "crypto";
|
|
2
|
+
//#region src/utils/random.ts
|
|
3
|
+
/**
|
|
4
|
+
* Generate a random string
|
|
5
|
+
*
|
|
6
|
+
* @param length - Max 32
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
2
9
|
const randomString = (length = 16) => {
|
|
3
|
-
|
|
4
|
-
|
|
10
|
+
const uniqueInput = Math.random().toString();
|
|
11
|
+
return createHash("md5").update(uniqueInput).digest("hex").slice(0, length);
|
|
5
12
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=random.js.map
|
|
13
|
+
//#endregion
|
|
14
|
+
export { randomString };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=random.js.map
|
package/dist/utils/random.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.js","sources":["
|
|
1
|
+
{"version":3,"file":"random.js","names":[],"sources":["../../src/utils/random.ts"],"sourcesContent":["import { createHash } from \"crypto\"\n\n/**\n * Generate a random string\n *\n * @param length - Max 32\n * @returns\n */\nexport const randomString = (length = 16): string => {\n\tconst uniqueInput = Math.random().toString()\n\n\treturn createHash(\"md5\").update(uniqueInput).digest(\"hex\").slice(0, length)\n}\n"],"mappings":";;;;;;;;AAQA,MAAa,gBAAgB,SAAS,OAAe;CACpD,MAAM,cAAc,KAAK,OAAO,CAAC,CAAC,SAAS;CAE3C,OAAO,WAAW,KAAK,CAAC,CAAC,OAAO,WAAW,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,MAAM;AAC3E"}
|
package/dist/utils/strings.cjs
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/utils/strings.ts
|
|
2
|
+
/**
|
|
3
|
+
* Convert string to a slug suitable for Integration Fields.
|
|
4
|
+
*
|
|
5
|
+
* @param str - The input string to slugify.
|
|
6
|
+
* @returns The slugified string (empty string if no valid characters remain). Inspired by the Wroom
|
|
7
|
+
* slugify function:
|
|
8
|
+
* https://github.com/prismicio/wroom/blob/09452b75fa5fabdaf3cd81383741cd02d30c9c9f/subprojects/common/app/utils/String.scala#L55
|
|
9
|
+
*/
|
|
3
10
|
const slugify = (str) => {
|
|
4
|
-
|
|
5
|
-
const normalized = noWhitespace.normalize("NFD").replace(new RegExp("\\p{M}+", "gu"), "");
|
|
6
|
-
const slug = normalized.replace(/[^A-Za-z0-9_-]/g, "").toLowerCase();
|
|
7
|
-
return slug || "";
|
|
11
|
+
return str.trim().replace(/ /g, "_").normalize("NFD").replace(/\p{M}+/gu, "").replace(/[^A-Za-z0-9_-]/g, "").toLowerCase() || "";
|
|
8
12
|
};
|
|
13
|
+
//#endregion
|
|
9
14
|
exports.slugify = slugify;
|
|
10
|
-
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=strings.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"strings.cjs","names":[],"sources":["../../src/utils/strings.ts"],"sourcesContent":["/**\n * Convert string to a slug suitable for Integration Fields.\n *\n * @param str - The input string to slugify.\n * @returns The slugified string (empty string if no valid characters remain). Inspired by the Wroom\n * slugify function:\n * https://github.com/prismicio/wroom/blob/09452b75fa5fabdaf3cd81383741cd02d30c9c9f/subprojects/common/app/utils/String.scala#L55\n */\nexport const slugify = (str: string): string => {\n\tconst noWhitespace = str.trim().replace(/ /g, \"_\")\n\tconst normalized = noWhitespace.normalize(\"NFD\").replace(/\\p{M}+/gu, \"\")\n\tconst slug = normalized.replace(/[^A-Za-z0-9_-]/g, \"\").toLowerCase()\n\n\treturn slug || \"\"\n}\n"],"mappings":";;;;;;;;;AAQA,MAAa,WAAW,QAAwB;CAK/C,OAJqB,IAAI,KAAK,CAAC,CAAC,QAAQ,MAAM,GAChB,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,QAAQ,YAAY,EAC/C,CAAC,CAAC,QAAQ,mBAAmB,EAAE,CAAC,CAAC,YAE7C,KAAK;AAChB"}
|
package/dist/utils/strings.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
//#region src/utils/strings.ts
|
|
2
|
+
/**
|
|
3
|
+
* Convert string to a slug suitable for Integration Fields.
|
|
4
|
+
*
|
|
5
|
+
* @param str - The input string to slugify.
|
|
6
|
+
* @returns The slugified string (empty string if no valid characters remain). Inspired by the Wroom
|
|
7
|
+
* slugify function:
|
|
8
|
+
* https://github.com/prismicio/wroom/blob/09452b75fa5fabdaf3cd81383741cd02d30c9c9f/subprojects/common/app/utils/String.scala#L55
|
|
9
|
+
*/
|
|
1
10
|
const slugify = (str) => {
|
|
2
|
-
|
|
3
|
-
const normalized = noWhitespace.normalize("NFD").replace(new RegExp("\\p{M}+", "gu"), "");
|
|
4
|
-
const slug = normalized.replace(/[^A-Za-z0-9_-]/g, "").toLowerCase();
|
|
5
|
-
return slug || "";
|
|
11
|
+
return str.trim().replace(/ /g, "_").normalize("NFD").replace(/\p{M}+/gu, "").replace(/[^A-Za-z0-9_-]/g, "").toLowerCase() || "";
|
|
6
12
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=strings.js.map
|
|
13
|
+
//#endregion
|
|
14
|
+
export { slugify };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=strings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings.js","sources":["
|
|
1
|
+
{"version":3,"file":"strings.js","names":[],"sources":["../../src/utils/strings.ts"],"sourcesContent":["/**\n * Convert string to a slug suitable for Integration Fields.\n *\n * @param str - The input string to slugify.\n * @returns The slugified string (empty string if no valid characters remain). Inspired by the Wroom\n * slugify function:\n * https://github.com/prismicio/wroom/blob/09452b75fa5fabdaf3cd81383741cd02d30c9c9f/subprojects/common/app/utils/String.scala#L55\n */\nexport const slugify = (str: string): string => {\n\tconst noWhitespace = str.trim().replace(/ /g, \"_\")\n\tconst normalized = noWhitespace.normalize(\"NFD\").replace(/\\p{M}+/gu, \"\")\n\tconst slug = normalized.replace(/[^A-Za-z0-9_-]/g, \"\").toLowerCase()\n\n\treturn slug || \"\"\n}\n"],"mappings":";;;;;;;;;AAQA,MAAa,WAAW,QAAwB;CAK/C,OAJqB,IAAI,KAAK,CAAC,CAAC,QAAQ,MAAM,GAChB,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,QAAQ,YAAY,EAC/C,CAAC,CAAC,QAAQ,mBAAmB,EAAE,CAAC,CAAC,YAE7C,KAAK;AAChB"}
|
package/dist/utils/urls.cjs
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/utils/urls.ts
|
|
2
|
+
/**
|
|
3
|
+
* Build a repository base url from the prismic base url
|
|
4
|
+
*
|
|
5
|
+
* @param baseUrl - Prismic base url like prismic.io
|
|
6
|
+
* @param repository - The repository name
|
|
7
|
+
* @returns The repository url like https://my-repo.prismic.io
|
|
8
|
+
*/
|
|
3
9
|
function getRepositoryUrl(baseUrl, repository) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
const url = new URL(baseUrl);
|
|
11
|
+
url.hostname = `${repository}.${url.hostname}`;
|
|
12
|
+
return url.toString();
|
|
7
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Prevent issues when building urls using `URL` that contain sub path without trailing slashes.
|
|
16
|
+
*
|
|
17
|
+
* @returns The original url with a trailing slash, if needed.
|
|
18
|
+
*/
|
|
8
19
|
function appendTrailingSlash(url) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return url;
|
|
20
|
+
if (!url.endsWith("/")) return url + "/";
|
|
21
|
+
return url;
|
|
13
22
|
}
|
|
23
|
+
//#endregion
|
|
14
24
|
exports.appendTrailingSlash = appendTrailingSlash;
|
|
15
25
|
exports.getRepositoryUrl = getRepositoryUrl;
|
|
16
|
-
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=urls.cjs.map
|
package/dist/utils/urls.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urls.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"urls.cjs","names":[],"sources":["../../src/utils/urls.ts"],"sourcesContent":["/**\n * Build a repository base url from the prismic base url\n *\n * @param baseUrl - Prismic base url like prismic.io\n * @param repository - The repository name\n * @returns The repository url like https://my-repo.prismic.io\n */\nexport function getRepositoryUrl(baseUrl: string, repository: string): string {\n\tconst url = new URL(baseUrl)\n\turl.hostname = `${repository}.${url.hostname}`\n\n\treturn url.toString()\n}\n\n/**\n * Prevent issues when building urls using `URL` that contain sub path without trailing slashes.\n *\n * @returns The original url with a trailing slash, if needed.\n */\nexport function appendTrailingSlash(url: string): string {\n\tif (!url.endsWith(\"/\")) {\n\t\treturn url + \"/\"\n\t}\n\n\treturn url\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,iBAAiB,SAAiB,YAA4B;CAC7E,MAAM,MAAM,IAAI,IAAI,OAAO;CAC3B,IAAI,WAAW,GAAG,WAAW,GAAG,IAAI;CAEpC,OAAO,IAAI,SAAS;AACrB;;;;;;AAOA,SAAgB,oBAAoB,KAAqB;CACxD,IAAI,CAAC,IAAI,SAAS,GAAG,GACpB,OAAO,MAAM;CAGd,OAAO;AACR"}
|
package/dist/utils/urls.js
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
|
+
//#region src/utils/urls.ts
|
|
2
|
+
/**
|
|
3
|
+
* Build a repository base url from the prismic base url
|
|
4
|
+
*
|
|
5
|
+
* @param baseUrl - Prismic base url like prismic.io
|
|
6
|
+
* @param repository - The repository name
|
|
7
|
+
* @returns The repository url like https://my-repo.prismic.io
|
|
8
|
+
*/
|
|
1
9
|
function getRepositoryUrl(baseUrl, repository) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
10
|
+
const url = new URL(baseUrl);
|
|
11
|
+
url.hostname = `${repository}.${url.hostname}`;
|
|
12
|
+
return url.toString();
|
|
5
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Prevent issues when building urls using `URL` that contain sub path without trailing slashes.
|
|
16
|
+
*
|
|
17
|
+
* @returns The original url with a trailing slash, if needed.
|
|
18
|
+
*/
|
|
6
19
|
function appendTrailingSlash(url) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
return url;
|
|
20
|
+
if (!url.endsWith("/")) return url + "/";
|
|
21
|
+
return url;
|
|
11
22
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=urls.js.map
|
|
23
|
+
//#endregion
|
|
24
|
+
export { appendTrailingSlash, getRepositoryUrl };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=urls.js.map
|
package/dist/utils/urls.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urls.js","sources":["
|
|
1
|
+
{"version":3,"file":"urls.js","names":[],"sources":["../../src/utils/urls.ts"],"sourcesContent":["/**\n * Build a repository base url from the prismic base url\n *\n * @param baseUrl - Prismic base url like prismic.io\n * @param repository - The repository name\n * @returns The repository url like https://my-repo.prismic.io\n */\nexport function getRepositoryUrl(baseUrl: string, repository: string): string {\n\tconst url = new URL(baseUrl)\n\turl.hostname = `${repository}.${url.hostname}`\n\n\treturn url.toString()\n}\n\n/**\n * Prevent issues when building urls using `URL` that contain sub path without trailing slashes.\n *\n * @returns The original url with a trailing slash, if needed.\n */\nexport function appendTrailingSlash(url: string): string {\n\tif (!url.endsWith(\"/\")) {\n\t\treturn url + \"/\"\n\t}\n\n\treturn url\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,iBAAiB,SAAiB,YAA4B;CAC7E,MAAM,MAAM,IAAI,IAAI,OAAO;CAC3B,IAAI,WAAW,GAAG,WAAW,GAAG,IAAI;CAEpC,OAAO,IAAI,SAAS;AACrB;;;;;;AAOA,SAAgB,oBAAoB,KAAqB;CACxD,IAAI,CAAC,IAAI,SAAS,GAAG,GACpB,OAAO,MAAM;CAGd,OAAO;AACR"}
|
package/package.json
CHANGED
|
@@ -1,100 +1,75 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/e2e-tests-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0-canary.d349d21",
|
|
4
4
|
"description": "A collection of utilities for to manage Prismic test data",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
6
|
+
"prismic",
|
|
7
|
+
"typescript"
|
|
8
8
|
],
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"author": "Prismic <contact@prismic.io> (https://prismic.io)",
|
|
9
11
|
"repository": {
|
|
10
12
|
"type": "git",
|
|
11
|
-
"url": "
|
|
13
|
+
"url": "ssh://git@github.com/prismicio/prismic-e2e-tests-utils.git"
|
|
12
14
|
},
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
+
"files": [
|
|
16
|
+
"./dist",
|
|
17
|
+
"./src"
|
|
18
|
+
],
|
|
15
19
|
"type": "module",
|
|
20
|
+
"main": "./dist/index.cjs",
|
|
21
|
+
"module": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.cts",
|
|
16
23
|
"exports": {
|
|
17
24
|
".": {
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"default": "./dist/index.cjs"
|
|
21
|
-
},
|
|
22
|
-
"import": {
|
|
23
|
-
"types": "./dist/index.d.ts",
|
|
24
|
-
"default": "./dist/index.js"
|
|
25
|
-
}
|
|
25
|
+
"import": "./dist/index.js",
|
|
26
|
+
"require": "./dist/index.cjs"
|
|
26
27
|
},
|
|
27
28
|
"./package.json": "./package.json"
|
|
28
29
|
},
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"files": [
|
|
33
|
-
"./dist",
|
|
34
|
-
"./src"
|
|
35
|
-
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
36
33
|
"scripts": {
|
|
37
|
-
"build": "
|
|
38
|
-
"dev": "
|
|
39
|
-
"format": "
|
|
34
|
+
"build": "tsdown",
|
|
35
|
+
"dev": "tsdown --watch",
|
|
36
|
+
"format": "oxfmt",
|
|
40
37
|
"prepare": "npm run build",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"release:patch": "npm run test && standard-version --release-as patch && git push --follow-tags && npm run build && npm publish",
|
|
44
|
-
"release:patch:dry": "standard-version --dry-run --release-as patch",
|
|
45
|
-
"release:alpha": "npm run test && standard-version --prerelease alpha && git push --follow-tags && npm run build && npm publish --tag alpha",
|
|
46
|
-
"release:alpha:dry": "standard-version --prerelease alpha --dry-run",
|
|
47
|
-
"lint": "eslint --ext .js,.ts .",
|
|
48
|
-
"lint:fix": "eslint --fix --ext .js,.ts .",
|
|
49
|
-
"types": "vitest --typecheck --run && tsc --noEmit",
|
|
50
|
-
"types:watch": "vitest --typecheck",
|
|
38
|
+
"lint": "oxlint --deny-warnings",
|
|
39
|
+
"types": "tsc --noEmit",
|
|
51
40
|
"unit": "vitest run --coverage",
|
|
52
41
|
"unit:watch": "vitest watch",
|
|
53
|
-
"
|
|
54
|
-
"test": "npm run lint && npm run types && npm run unit && npm run build && npm run size"
|
|
42
|
+
"test": "npm run lint && npm run types && npm run unit && npm run build"
|
|
55
43
|
},
|
|
56
44
|
"dependencies": {
|
|
57
|
-
"axios": "^1.
|
|
58
|
-
"jsonwebtoken": "^9.0.
|
|
45
|
+
"axios": "^1.18.1",
|
|
46
|
+
"jsonwebtoken": "^9.0.3",
|
|
59
47
|
"lodash.isequal": "^4.5.0",
|
|
60
|
-
"winston": "^3.
|
|
48
|
+
"winston": "^3.19.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@prismicio/types-internal": "^4.5.1",
|
|
52
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
53
|
+
"@types/lodash.isequal": "^4.5.8",
|
|
54
|
+
"@types/node": "^26.0.1",
|
|
55
|
+
"@vitest/coverage-v8": "^4.1.9",
|
|
56
|
+
"msw": "^2.14.6",
|
|
57
|
+
"oxfmt": "^0.57.0",
|
|
58
|
+
"oxlint": "^1.72.0",
|
|
59
|
+
"tsdown": "^0.22.3",
|
|
60
|
+
"typescript": "^6.0.3",
|
|
61
|
+
"vitest": "^4.1.9"
|
|
61
62
|
},
|
|
62
63
|
"peerDependencies": {
|
|
63
|
-
"@playwright/test": ">=
|
|
64
|
-
"@prismicio/types-internal": ">=
|
|
64
|
+
"@playwright/test": ">=1.16",
|
|
65
|
+
"@prismicio/types-internal": ">=2.3.1"
|
|
65
66
|
},
|
|
66
67
|
"peerDependenciesMeta": {
|
|
67
68
|
"@prismicio/types-internal": {
|
|
68
69
|
"optional": true
|
|
69
70
|
}
|
|
70
71
|
},
|
|
71
|
-
"devDependencies": {
|
|
72
|
-
"@size-limit/preset-small-lib": "^11.0.1",
|
|
73
|
-
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
|
|
74
|
-
"@types/jsonwebtoken": "^9.0.6",
|
|
75
|
-
"@types/lodash.isequal": "^4.5.8",
|
|
76
|
-
"@types/node": "^20.9.2",
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
|
78
|
-
"@typescript-eslint/parser": "^6.8.0",
|
|
79
|
-
"@vitest/coverage-v8": "^1.0.4",
|
|
80
|
-
"eslint": "^8.51.0",
|
|
81
|
-
"eslint-config-prettier": "^9.0.0",
|
|
82
|
-
"eslint-plugin-prettier": "^5.0.1",
|
|
83
|
-
"eslint-plugin-tsdoc": "^0.2.17",
|
|
84
|
-
"msw": "^2.2.13",
|
|
85
|
-
"prettier": "^3.0.3",
|
|
86
|
-
"prettier-plugin-jsdoc": "^1.1.1",
|
|
87
|
-
"size-limit": "^11.0.1",
|
|
88
|
-
"standard-version": "^9.5.0",
|
|
89
|
-
"typescript": "^5.2.2",
|
|
90
|
-
"vite": "^5.0.9",
|
|
91
|
-
"vite-plugin-sdk": "^0.1.1",
|
|
92
|
-
"vitest": "^1.0.4"
|
|
93
|
-
},
|
|
94
72
|
"engines": {
|
|
95
73
|
"node": ">=18.0.0"
|
|
96
|
-
},
|
|
97
|
-
"publishConfig": {
|
|
98
|
-
"access": "public"
|
|
99
74
|
}
|
|
100
75
|
}
|
package/src/clients/apiClient.ts
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import { APIRequestContext
|
|
1
|
+
import type { APIRequestContext } from "@playwright/test"
|
|
2
|
+
import { request } from "@playwright/test"
|
|
2
3
|
|
|
3
|
-
import { appendTrailingSlash } from "../utils/urls"
|
|
4
|
+
import { appendTrailingSlash } from "../utils/urls"
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* The authentication token. Can be a string or a function that returns a
|
|
7
|
-
*
|
|
7
|
+
* The authentication token. Can be a string or a function that returns a promise resolving to the
|
|
8
|
+
* token.
|
|
8
9
|
*/
|
|
9
|
-
export type AuthServerToken = string | (() => Promise<string>)
|
|
10
|
+
export type AuthServerToken = string | (() => Promise<string>)
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
|
-
* Abstract class for Prismic api clients that use the Prismic authentication
|
|
13
|
-
*
|
|
14
|
-
* necessary authorization headers.
|
|
13
|
+
* Abstract class for Prismic api clients that use the Prismic authentication server. This class
|
|
14
|
+
* takes care or creating the Playwright context with the necessary authorization headers.
|
|
15
15
|
*
|
|
16
|
-
* This class performs requests with Playwright instead of a library like Axios
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* Playwright.
|
|
16
|
+
* This class performs requests with Playwright instead of a library like Axios which has the
|
|
17
|
+
* advantage of tracing all the network details in the Playwright reports making test failures
|
|
18
|
+
* investigation easier for projects that use Playwright.
|
|
20
19
|
*/
|
|
21
20
|
export abstract class AuthenticatedApiClient {
|
|
22
|
-
private _context?: APIRequestContext
|
|
21
|
+
private _context?: APIRequestContext
|
|
23
22
|
|
|
24
23
|
constructor(
|
|
25
24
|
private readonly baseURL: string,
|
|
@@ -27,14 +26,10 @@ export abstract class AuthenticatedApiClient {
|
|
|
27
26
|
private readonly headers?: { [key: string]: string } | undefined,
|
|
28
27
|
) {}
|
|
29
28
|
|
|
30
|
-
/**
|
|
31
|
-
* Returns a Playwright ApiRequestContext instance with the necessary
|
|
32
|
-
* authorization headers.
|
|
33
|
-
*/
|
|
29
|
+
/** Returns a Playwright ApiRequestContext instance with the necessary authorization headers. */
|
|
34
30
|
protected async getContext(): Promise<APIRequestContext> {
|
|
35
31
|
if (!this._context) {
|
|
36
|
-
const token =
|
|
37
|
-
typeof this.token === "string" ? this.token : await this.token();
|
|
32
|
+
const token = typeof this.token === "string" ? this.token : await this.token()
|
|
38
33
|
|
|
39
34
|
this._context = await request.newContext({
|
|
40
35
|
baseURL: appendTrailingSlash(this.baseURL),
|
|
@@ -42,9 +37,9 @@ export abstract class AuthenticatedApiClient {
|
|
|
42
37
|
Authorization: `Bearer ${token}`,
|
|
43
38
|
...this.headers,
|
|
44
39
|
},
|
|
45
|
-
})
|
|
40
|
+
})
|
|
46
41
|
}
|
|
47
42
|
|
|
48
|
-
return this._context
|
|
43
|
+
return this._context
|
|
49
44
|
}
|
|
50
45
|
}
|