@prismicio/e2e-tests-utils 1.18.0 → 1.19.0-pr.37.6283e4a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/README.md +24 -27
  2. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  3. package/dist/clients/apiClient.cjs +38 -38
  4. package/dist/clients/apiClient.cjs.map +1 -1
  5. package/dist/clients/apiClient.d.cts +30 -0
  6. package/dist/clients/apiClient.d.cts.map +1 -0
  7. package/dist/clients/apiClient.d.ts +23 -23
  8. package/dist/clients/apiClient.d.ts.map +1 -0
  9. package/dist/clients/apiClient.js +38 -38
  10. package/dist/clients/apiClient.js.map +1 -1
  11. package/dist/clients/assetApi.cjs +81 -93
  12. package/dist/clients/assetApi.cjs.map +1 -1
  13. package/dist/clients/assetApi.d.cts +105 -0
  14. package/dist/clients/assetApi.d.cts.map +1 -0
  15. package/dist/clients/assetApi.d.ts +96 -97
  16. package/dist/clients/assetApi.d.ts.map +1 -0
  17. package/dist/clients/assetApi.js +79 -91
  18. package/dist/clients/assetApi.js.map +1 -1
  19. package/dist/clients/authenticationApi.cjs +66 -73
  20. package/dist/clients/authenticationApi.cjs.map +1 -1
  21. package/dist/clients/authenticationApi.d.cts +20 -0
  22. package/dist/clients/authenticationApi.d.cts.map +1 -0
  23. package/dist/clients/authenticationApi.d.ts +18 -13
  24. package/dist/clients/authenticationApi.d.ts.map +1 -0
  25. package/dist/clients/authenticationApi.js +65 -72
  26. package/dist/clients/authenticationApi.js.map +1 -1
  27. package/dist/clients/contentApi.cjs +94 -103
  28. package/dist/clients/contentApi.cjs.map +1 -1
  29. package/dist/clients/contentApi.d.cts +116 -0
  30. package/dist/clients/contentApi.d.cts.map +1 -0
  31. package/dist/clients/contentApi.d.ts +102 -98
  32. package/dist/clients/contentApi.d.ts.map +1 -0
  33. package/dist/clients/contentApi.js +94 -103
  34. package/dist/clients/contentApi.js.map +1 -1
  35. package/dist/clients/coreApi.cjs +154 -145
  36. package/dist/clients/coreApi.cjs.map +1 -1
  37. package/dist/clients/coreApi.d.cts +142 -0
  38. package/dist/clients/coreApi.d.cts.map +1 -0
  39. package/dist/clients/coreApi.d.ts +131 -109
  40. package/dist/clients/coreApi.d.ts.map +1 -0
  41. package/dist/clients/coreApi.js +153 -144
  42. package/dist/clients/coreApi.js.map +1 -1
  43. package/dist/clients/customTypesApi.cjs +90 -99
  44. package/dist/clients/customTypesApi.cjs.map +1 -1
  45. package/dist/clients/customTypesApi.d.cts +46 -0
  46. package/dist/clients/customTypesApi.d.cts.map +1 -0
  47. package/dist/clients/customTypesApi.d.ts +45 -45
  48. package/dist/clients/customTypesApi.d.ts.map +1 -0
  49. package/dist/clients/customTypesApi.js +87 -98
  50. package/dist/clients/customTypesApi.js.map +1 -1
  51. package/dist/clients/integrationFields.cjs +96 -87
  52. package/dist/clients/integrationFields.cjs.map +1 -1
  53. package/dist/clients/integrationFields.d.cts +30 -0
  54. package/dist/clients/integrationFields.d.cts.map +1 -0
  55. package/dist/clients/integrationFields.d.ts +27 -22
  56. package/dist/clients/integrationFields.d.ts.map +1 -0
  57. package/dist/clients/integrationFields.js +93 -86
  58. package/dist/clients/integrationFields.js.map +1 -1
  59. package/dist/clients/manageV2.cjs +154 -171
  60. package/dist/clients/manageV2.cjs.map +1 -1
  61. package/dist/clients/manageV2.d.cts +105 -0
  62. package/dist/clients/manageV2.d.cts.map +1 -0
  63. package/dist/clients/manageV2.d.ts +103 -111
  64. package/dist/clients/manageV2.d.ts.map +1 -0
  65. package/dist/clients/manageV2.js +149 -169
  66. package/dist/clients/manageV2.js.map +1 -1
  67. package/dist/clients/migrationApi.cjs +37 -36
  68. package/dist/clients/migrationApi.cjs.map +1 -1
  69. package/dist/clients/migrationApi.d.cts +48 -0
  70. package/dist/clients/migrationApi.d.cts.map +1 -0
  71. package/dist/clients/migrationApi.d.ts +45 -39
  72. package/dist/clients/migrationApi.d.ts.map +1 -0
  73. package/dist/clients/migrationApi.js +35 -34
  74. package/dist/clients/migrationApi.js.map +1 -1
  75. package/dist/clients/wroom.cjs +101 -122
  76. package/dist/clients/wroom.cjs.map +1 -1
  77. package/dist/clients/wroom.d.cts +48 -0
  78. package/dist/clients/wroom.d.cts.map +1 -0
  79. package/dist/clients/wroom.d.ts +46 -47
  80. package/dist/clients/wroom.d.ts.map +1 -0
  81. package/dist/clients/wroom.js +99 -122
  82. package/dist/clients/wroom.js.map +1 -1
  83. package/dist/index.cjs +13 -15
  84. package/dist/index.d.cts +8 -0
  85. package/dist/index.d.ts +8 -7
  86. package/dist/index.js +5 -14
  87. package/dist/managers/repositories.cjs +159 -169
  88. package/dist/managers/repositories.cjs.map +1 -1
  89. package/dist/managers/repositories.d.cts +67 -0
  90. package/dist/managers/repositories.d.cts.map +1 -0
  91. package/dist/managers/repositories.d.ts +56 -63
  92. package/dist/managers/repositories.d.ts.map +1 -0
  93. package/dist/managers/repositories.js +148 -159
  94. package/dist/managers/repositories.js.map +1 -1
  95. package/dist/managers/repository.cjs +591 -616
  96. package/dist/managers/repository.cjs.map +1 -1
  97. package/dist/managers/repository.d.cts +338 -0
  98. package/dist/managers/repository.d.cts.map +1 -0
  99. package/dist/managers/repository.d.ts +333 -307
  100. package/dist/managers/repository.d.ts.map +1 -0
  101. package/dist/managers/repository.js +591 -616
  102. package/dist/managers/repository.js.map +1 -1
  103. package/dist/types.d.cts +41 -0
  104. package/dist/types.d.cts.map +1 -0
  105. package/dist/types.d.ts +35 -37
  106. package/dist/types.d.ts.map +1 -0
  107. package/dist/utils/cookies.cjs +19 -17
  108. package/dist/utils/cookies.cjs.map +1 -1
  109. package/dist/utils/cookies.js +20 -18
  110. package/dist/utils/cookies.js.map +1 -1
  111. package/dist/utils/envVariableManager.cjs +33 -34
  112. package/dist/utils/envVariableManager.cjs.map +1 -1
  113. package/dist/utils/envVariableManager.js +34 -35
  114. package/dist/utils/envVariableManager.js.map +1 -1
  115. package/dist/utils/log.cjs +18 -19
  116. package/dist/utils/log.cjs.map +1 -1
  117. package/dist/utils/log.js +18 -21
  118. package/dist/utils/log.js.map +1 -1
  119. package/dist/utils/random.cjs +13 -6
  120. package/dist/utils/random.cjs.map +1 -1
  121. package/dist/utils/random.js +13 -6
  122. package/dist/utils/random.js.map +1 -1
  123. package/dist/utils/strings.cjs +13 -7
  124. package/dist/utils/strings.cjs.map +1 -1
  125. package/dist/utils/strings.js +14 -8
  126. package/dist/utils/strings.js.map +1 -1
  127. package/dist/utils/urls.cjs +21 -10
  128. package/dist/utils/urls.cjs.map +1 -1
  129. package/dist/utils/urls.js +22 -12
  130. package/dist/utils/urls.js.map +1 -1
  131. package/package.json +42 -67
  132. package/src/clients/apiClient.ts +16 -21
  133. package/src/clients/assetApi.ts +75 -82
  134. package/src/clients/authenticationApi.ts +54 -27
  135. package/src/clients/contentApi.ts +111 -129
  136. package/src/clients/coreApi.ts +165 -117
  137. package/src/clients/customTypesApi.ts +54 -74
  138. package/src/clients/integrationFields.ts +59 -74
  139. package/src/clients/manageV2.ts +72 -96
  140. package/src/clients/migrationApi.ts +35 -39
  141. package/src/clients/wroom.ts +42 -56
  142. package/src/index.ts +7 -7
  143. package/src/managers/repositories.ts +85 -108
  144. package/src/managers/repository.ts +393 -368
  145. package/src/types.ts +31 -31
  146. package/src/utils/cookies.ts +8 -8
  147. package/src/utils/envVariableManager.ts +15 -15
  148. package/src/utils/log.ts +17 -21
  149. package/src/utils/random.ts +5 -6
  150. package/src/utils/strings.ts +7 -9
  151. package/src/utils/urls.ts +10 -12
  152. package/dist/index.cjs.map +0 -1
  153. package/dist/index.js.map +0 -1
  154. package/dist/utils/cookies.d.ts +0 -8
  155. package/dist/utils/envVariableManager.d.ts +0 -16
  156. package/dist/utils/log.d.ts +0 -5
  157. package/dist/utils/random.d.ts +0 -8
  158. package/dist/utils/strings.d.ts +0 -11
  159. package/dist/utils/urls.d.ts +0 -16
package/src/types.ts CHANGED
@@ -1,51 +1,51 @@
1
1
  export type UrlConfig = {
2
2
  /** Prismic base url */
3
- baseURL: string;
3
+ baseURL: string
4
4
  /** Custom types api base url */
5
- customTypesApi: string;
5
+ customTypesApi: string
6
6
  /** Auth service api base url */
7
- authenticationApi: string;
7
+ authenticationApi: string
8
8
  /** Prismic migration api base url */
9
- migrationApi?: string;
9
+ migrationApi?: string
10
10
  /** Asset api base url */
11
- assetApi: string;
11
+ assetApi: string
12
12
  /** Integration fields api base url */
13
- integrationFieldApi?: string;
14
- };
13
+ integrationFieldApi?: string
14
+ }
15
15
 
16
16
  export type AuthConfig = {
17
- email: string;
18
- password: string;
19
- };
17
+ email: string
18
+ password: string
19
+ }
20
20
 
21
21
  export type ManageV2Config = {
22
- secret: string;
23
- audience: string;
24
- };
22
+ secret: string
23
+ audience: string
24
+ }
25
25
 
26
26
  // Global configuration Object
27
27
  export type SetupConfiguration = {
28
28
  // If provided as a string: It is treated as the base URL for Prismic. Other
29
29
  // URLs (Custom Types API, Auth API) will be derived from it.
30
- urlConfig: UrlConfig | string;
31
- authConfig: AuthConfig;
32
- manageV2Config?: ManageV2Config;
33
- cluster?: string;
34
- environment?: string;
35
- integrationFieldsConfig?: IntegrationFieldConfig[];
36
- };
30
+ urlConfig: UrlConfig | string
31
+ authConfig: AuthConfig
32
+ manageV2Config?: ManageV2Config
33
+ cluster?: string
34
+ environment?: string
35
+ integrationFieldsConfig?: IntegrationFieldConfig[]
36
+ }
37
37
 
38
38
  export type IntegrationFieldData = {
39
- id: string;
40
- title: string;
41
- description: string;
42
- blob: Record<string, unknown>;
43
- };
39
+ id: string
40
+ title: string
41
+ description: string
42
+ blob: Record<string, unknown>
43
+ }
44
44
 
45
45
  export type IntegrationFieldConfig = {
46
- name: string;
47
- description: string;
48
- customTypeId: string;
49
- fieldId: string;
50
- data: IntegrationFieldData[];
51
- };
46
+ name: string
47
+ description: string
48
+ customTypeId: string
49
+ fieldId: string
50
+ data: IntegrationFieldData[]
51
+ }
@@ -1,4 +1,4 @@
1
- import { AxiosHeaderValue } from "axios";
1
+ import type { AxiosHeaderValue } from "axios"
2
2
 
3
3
  /**
4
4
  * Extract the value of a specific cookie from Axios cookies.
@@ -10,21 +10,21 @@ export const extractCookie = (
10
10
  cookies: AxiosHeaderValue | undefined,
11
11
  cookieName: string,
12
12
  ): string | undefined => {
13
- const regex = new RegExp(`${cookieName}=([^;]+)`, "i"); // 'i' flag for case-insensitivity
13
+ const regex = new RegExp(`${cookieName}=([^;]+)`, "i") // 'i' flag for case-insensitivity
14
14
 
15
15
  if (typeof cookies === "string") {
16
- const match = cookies.match(regex);
16
+ const match = cookies.match(regex)
17
17
 
18
- return match ? match[1] : undefined;
18
+ return match ? match[1] : undefined
19
19
  }
20
20
  if (Array.isArray(cookies)) {
21
21
  for (const cookie of cookies) {
22
- const match = cookie.match(regex);
22
+ const match = cookie.match(regex)
23
23
  if (match) {
24
- return match[1];
24
+ return match[1]
25
25
  }
26
26
  }
27
27
  }
28
28
 
29
- return undefined;
30
- };
29
+ return undefined
30
+ }
@@ -1,35 +1,35 @@
1
1
  /**
2
- * Manage a list of strings within an environment variable. This is useful to
3
- * share data across different test phases (setup, teardown, test execution) as
4
- * most test frameworks run these in independent states
2
+ * Manage a list of strings within an environment variable. This is useful to share data across
3
+ * different test phases (setup, teardown, test execution) as most test frameworks run these in
4
+ * independent states
5
5
  */
6
6
  export class EnvVariableManager {
7
7
  constructor(private variableName: string) {}
8
8
 
9
- /** add a string and persist it in the environment variable */
9
+ /** Add a string and persist it in the environment variable */
10
10
  add(value: string): void {
11
- const existingValues = this.getAll();
12
- existingValues.push(value);
11
+ const existingValues = this.getAll()
12
+ existingValues.push(value)
13
13
 
14
- this.setAll(existingValues);
14
+ this.setAll(existingValues)
15
15
  }
16
16
 
17
- /** remove a string from the environment variable */
17
+ /** Remove a string from the environment variable */
18
18
  remove(value: string): void {
19
- const existingValues = this.getAll();
20
- const updatedValues = existingValues.filter((item) => item !== value);
19
+ const existingValues = this.getAll()
20
+ const updatedValues = existingValues.filter((item) => item !== value)
21
21
 
22
- this.setAll(updatedValues);
22
+ this.setAll(updatedValues)
23
23
  }
24
24
 
25
- /** return all items stored in the environment variable */
25
+ /** Return all items stored in the environment variable */
26
26
  getAll(): string[] {
27
- const value = process.env[this.variableName] || "[]";
27
+ const value = process.env[this.variableName] || "[]"
28
28
 
29
- return JSON.parse(value);
29
+ return JSON.parse(value)
30
30
  }
31
31
 
32
32
  private setAll(values: string[]): void {
33
- process.env[this.variableName] = JSON.stringify(values);
33
+ process.env[this.variableName] = JSON.stringify(values)
34
34
  }
35
35
  }
package/src/utils/log.ts CHANGED
@@ -1,43 +1,39 @@
1
- import { APIResponse } from "@playwright/test";
2
- import { AxiosResponse } from "axios";
3
- import { createLogger, format, transports } from "winston";
1
+ import type { APIResponse } from "@playwright/test"
2
+ import type { AxiosResponse } from "axios"
3
+ import { createLogger, format, transports } from "winston"
4
4
 
5
5
  export const logHttpResponse = (response: AxiosResponse): void => {
6
- const { status, data } = response;
7
- const { baseURL = "", url = "" } = response.config;
6
+ const { status, data } = response
7
+ const { baseURL = "", url = "" } = response.config
8
8
  // make sure the url always shows baseURL + path.
9
9
  // Depending on how the AxiosInstance was called, the url already contains the baseURL
10
- const fullUrl = url.startsWith("http") ? url : `${baseURL}/${url}`;
10
+ const fullUrl = url.startsWith("http") ? url : `${baseURL}/${url}`
11
11
 
12
- logger.info(
13
- `Call to ${fullUrl} failed, received [${status}] ${JSON.stringify(data)}`,
14
- );
15
- };
12
+ logger.info(`Call to ${fullUrl} failed, received [${status}] ${JSON.stringify(data)}`)
13
+ }
16
14
 
17
- export const logPlaywrightApiResponse = async (
18
- response: APIResponse,
19
- ): Promise<void> => {
15
+ export const logPlaywrightApiResponse = async (response: APIResponse): Promise<void> => {
20
16
  logger.info(
21
17
  `Call to ${response.url()} failed, received [${response.status()}] ${JSON.stringify(
22
18
  await response.text(),
23
19
  )}`,
24
- );
25
- };
20
+ )
21
+ }
26
22
 
27
- const { combine, printf } = format;
23
+ const { combine, printf } = format
28
24
 
29
25
  const customFormat = printf(({ message, durationMs }) => {
30
- const baseMsg = `[test data] ${message}`;
26
+ const baseMsg = `[test data] ${message}`
31
27
  if (durationMs) {
32
- return `${baseMsg} in ${durationMs}ms`;
28
+ return `${baseMsg} in ${durationMs}ms`
33
29
  }
34
30
 
35
- return baseMsg;
36
- });
31
+ return baseMsg
32
+ })
37
33
 
38
34
  export const logger = createLogger({
39
35
  silent: process.env["prismic_e2e_tests_utils_silent"] === "true",
40
36
  level: process.env["prismic_e2e_tests_utils_log_level"] || "info",
41
37
  format: combine(customFormat),
42
38
  transports: [new transports.Console()],
43
- });
39
+ })
@@ -1,14 +1,13 @@
1
- import { createHash } from "crypto";
1
+ import { createHash } from "crypto"
2
2
 
3
3
  /**
4
4
  * Generate a random string
5
5
  *
6
- * @param length - max 32
7
- *
6
+ * @param length - Max 32
8
7
  * @returns
9
8
  */
10
9
  export const randomString = (length = 16): string => {
11
- const uniqueInput = Math.random().toString();
10
+ const uniqueInput = Math.random().toString()
12
11
 
13
- return createHash("md5").update(uniqueInput).digest("hex").slice(0, length);
14
- };
12
+ return createHash("md5").update(uniqueInput).digest("hex").slice(0, length)
13
+ }
@@ -2,16 +2,14 @@
2
2
  * Convert string to a slug suitable for Integration Fields.
3
3
  *
4
4
  * @param str - The input string to slugify.
5
- *
6
- * @returns The slugified string (empty string if no valid characters remain).
7
- *
8
- * Inspired by the Wroom slugify function:
5
+ * @returns The slugified string (empty string if no valid characters remain). Inspired by the Wroom
6
+ * slugify function:
9
7
  * https://github.com/prismicio/wroom/blob/09452b75fa5fabdaf3cd81383741cd02d30c9c9f/subprojects/common/app/utils/String.scala#L55
10
8
  */
11
9
  export const slugify = (str: string): string => {
12
- const noWhitespace = str.trim().replace(/ /g, "_");
13
- const normalized = noWhitespace.normalize("NFD").replace(/\p{M}+/gu, "");
14
- const slug = normalized.replace(/[^A-Za-z0-9_-]/g, "").toLowerCase();
10
+ const noWhitespace = str.trim().replace(/ /g, "_")
11
+ const normalized = noWhitespace.normalize("NFD").replace(/\p{M}+/gu, "")
12
+ const slug = normalized.replace(/[^A-Za-z0-9_-]/g, "").toLowerCase()
15
13
 
16
- return slug || "";
17
- };
14
+ return slug || ""
15
+ }
package/src/utils/urls.ts CHANGED
@@ -1,28 +1,26 @@
1
1
  /**
2
2
  * Build a repository base url from the prismic base url
3
3
  *
4
- * @param baseUrl - prismic base url like prismic.io
5
- * @param repository - the repository name
6
- *
7
- * @returns the repository url like https://my-repo.prismic.io
4
+ * @param baseUrl - Prismic base url like prismic.io
5
+ * @param repository - The repository name
6
+ * @returns The repository url like https://my-repo.prismic.io
8
7
  */
9
8
  export function getRepositoryUrl(baseUrl: string, repository: string): string {
10
- const url = new URL(baseUrl);
11
- url.hostname = `${repository}.${url.hostname}`;
9
+ const url = new URL(baseUrl)
10
+ url.hostname = `${repository}.${url.hostname}`
12
11
 
13
- return url.toString();
12
+ return url.toString()
14
13
  }
15
14
 
16
15
  /**
17
- * Prevent issues when building urls using `URL` that contain sub path without
18
- * trailing slashes.
16
+ * Prevent issues when building urls using `URL` that contain sub path without trailing slashes.
19
17
  *
20
- * @returns the original url with a trailing slash, if needed.
18
+ * @returns The original url with a trailing slash, if needed.
21
19
  */
22
20
  export function appendTrailingSlash(url: string): string {
23
21
  if (!url.endsWith("/")) {
24
- return url + "/";
22
+ return url + "/"
25
23
  }
26
24
 
27
- return url;
25
+ return url
28
26
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -1,8 +0,0 @@
1
- import { AxiosHeaderValue } from "axios";
2
- /**
3
- * Extract the value of a specific cookie from Axios cookies.
4
- *
5
- * @param cookies - Axios cookies, can be a string or an array
6
- * @param cookieName - The name of the cookie to extract.
7
- */
8
- export declare const extractCookie: (cookies: AxiosHeaderValue | undefined, cookieName: string) => string | undefined;
@@ -1,16 +0,0 @@
1
- /**
2
- * Manage a list of strings within an environment variable. This is useful to
3
- * share data across different test phases (setup, teardown, test execution) as
4
- * most test frameworks run these in independent states
5
- */
6
- export declare class EnvVariableManager {
7
- private variableName;
8
- constructor(variableName: string);
9
- /** add a string and persist it in the environment variable */
10
- add(value: string): void;
11
- /** remove a string from the environment variable */
12
- remove(value: string): void;
13
- /** return all items stored in the environment variable */
14
- getAll(): string[];
15
- private setAll;
16
- }
@@ -1,5 +0,0 @@
1
- import { APIResponse } from "@playwright/test";
2
- import { AxiosResponse } from "axios";
3
- export declare const logHttpResponse: (response: AxiosResponse) => void;
4
- export declare const logPlaywrightApiResponse: (response: APIResponse) => Promise<void>;
5
- export declare const logger: import("winston").Logger;
@@ -1,8 +0,0 @@
1
- /**
2
- * Generate a random string
3
- *
4
- * @param length - max 32
5
- *
6
- * @returns
7
- */
8
- export declare const randomString: (length?: number) => string;
@@ -1,11 +0,0 @@
1
- /**
2
- * Convert string to a slug suitable for Integration Fields.
3
- *
4
- * @param str - The input string to slugify.
5
- *
6
- * @returns The slugified string (empty string if no valid characters remain).
7
- *
8
- * Inspired by the Wroom slugify function:
9
- * https://github.com/prismicio/wroom/blob/09452b75fa5fabdaf3cd81383741cd02d30c9c9f/subprojects/common/app/utils/String.scala#L55
10
- */
11
- export declare const slugify: (str: string) => string;
@@ -1,16 +0,0 @@
1
- /**
2
- * Build a repository base url from the prismic base url
3
- *
4
- * @param baseUrl - prismic base url like prismic.io
5
- * @param repository - the repository name
6
- *
7
- * @returns the repository url like https://my-repo.prismic.io
8
- */
9
- export declare function getRepositoryUrl(baseUrl: string, repository: string): string;
10
- /**
11
- * Prevent issues when building urls using `URL` that contain sub path without
12
- * trailing slashes.
13
- *
14
- * @returns the original url with a trailing slash, if needed.
15
- */
16
- export declare function appendTrailingSlash(url: string): string;