@prismicio/e2e-tests-utils 1.11.0 → 2.0.0-alpha.0

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.
@@ -6,7 +6,6 @@ import {
6
6
  SharedSlice,
7
7
  } from "@prismicio/types-internal/lib/customtypes";
8
8
 
9
- import { AssetApiClient } from "../clients/assetApi";
10
9
  import { AuthenticationApiClient } from "../clients/authenticationApi";
11
10
  import { ContentApiClient } from "../clients/contentApi";
12
11
  import {
@@ -30,7 +29,6 @@ export class RepositoryManager {
30
29
  private readonly wroomClient: WroomClient,
31
30
  private readonly customTypesApiClient: CustomTypesApiClient,
32
31
  private readonly migrationApiClient: MigrationApiClient | undefined,
33
- private readonly assetApiClient: AssetApiClient,
34
32
  private readonly manageV2Client: ManageV2Client,
35
33
  ) {}
36
34
 
@@ -87,10 +85,6 @@ export class RepositoryManager {
87
85
  if (config.rolePerLocal) {
88
86
  await this.toggleRolePerLocal(true);
89
87
  }
90
-
91
- if (config.customRoles) {
92
- await this.toggleCustomRoles(true);
93
- }
94
88
  }
95
89
 
96
90
  /** @returns the repository base url, like https://my-repo.prismic.io */
@@ -127,14 +121,6 @@ export class RepositoryManager {
127
121
  return this.migrationApiClient;
128
122
  }
129
123
 
130
- /**
131
- * @returns an instance of the Asset api client, see
132
- * https://prismic.io/docs/asset-api-technical-reference
133
- */
134
- getAssetApiClient(): AssetApiClient {
135
- return this.assetApiClient;
136
- }
137
-
138
124
  /** @returns the Wroom commit hash deployed on the current repository */
139
125
  async getDeployedVersion(): Promise<string | undefined> {
140
126
  const response = await this.wroomClient.get(
@@ -344,62 +330,6 @@ export class RepositoryManager {
344
330
  profiler.done({ message: `preview '${id}' deleted` });
345
331
  }
346
332
 
347
- /**
348
- * Create a webhook.
349
- *
350
- * @returns A Promise that resolves with the webhook id.
351
- */
352
- async createWebhook(
353
- name: string,
354
- url: string,
355
- secret: string,
356
- triggers: {
357
- documentsPublished?: boolean;
358
- documentsUnpublished?: boolean;
359
- releasesCreated?: boolean;
360
- releasesUpdated?: boolean;
361
- tagsCreated?: boolean;
362
- tagsDeleted?: boolean;
363
- },
364
- active: boolean,
365
- ): Promise<string> {
366
- const profiler = logger.startTimer();
367
-
368
- const response = await this.wroomClient.post(
369
- this.name,
370
- "app/settings/webhooks/create",
371
- {
372
- name,
373
- url,
374
- secret,
375
- active: active ? "on" : "off",
376
- ...triggers,
377
- },
378
- );
379
- this.failIfNot200(response, `Could not create webhook ${name}`);
380
- profiler.done({ message: `webhook '${name}' created` });
381
-
382
- return response.data.created;
383
- }
384
-
385
- /**
386
- * Deletes a webhook.
387
- *
388
- * @param id - The webhook ID.
389
- */
390
- async deleteWebhook(id: string): Promise<void> {
391
- const profiler = logger.startTimer();
392
-
393
- const response = await this.wroomClient.post(
394
- this.name,
395
- `app/settings/webhooks/${id}/delete`,
396
- {},
397
- );
398
-
399
- this.failIfNot200(response, `Could not delete webhook with id ${id}`);
400
- profiler.done({ message: `webhook '${id}' deleted` });
401
- }
402
-
403
333
  /**
404
334
  * Create Custom Types using the Custom types api.
405
335
  *
@@ -501,7 +431,7 @@ export class RepositoryManager {
501
431
  }
502
432
 
503
433
  /**
504
- * Toggle the Role per Locale workflow
434
+ * Toggle the Role per local feature
505
435
  *
506
436
  * @param enabled - The feature new status
507
437
  */
@@ -524,30 +454,6 @@ export class RepositoryManager {
524
454
  });
525
455
  }
526
456
 
527
- /**
528
- * Toggle the Custom Roles workflow
529
- *
530
- * @param enabled - The feature new status
531
- */
532
- async toggleCustomRoles(enabled: boolean): Promise<void> {
533
- const profiler = logger.startTimer();
534
-
535
- const response = await this.manageV2Client.toggleCustomRoles({
536
- repository: this.name,
537
- enabled: enabled,
538
- });
539
-
540
- this.failIfNot200(
541
- response,
542
- `Could not ${enabled ? "enable" : "disable"} Custom Roles for ${
543
- this.name
544
- }`,
545
- );
546
- profiler.done({
547
- message: `Custom Roles ${enabled ? "enabled" : "disabled"}`,
548
- });
549
- }
550
-
551
457
  /**
552
458
  * Change the Repository Plan
553
459
  *
@@ -727,7 +633,6 @@ export type RepositoryConfig = {
727
633
  customTypes?: CustomType[];
728
634
  preview?: Preview;
729
635
  rolePerLocal?: boolean;
730
- customRoles?: boolean;
731
636
  };
732
637
 
733
638
  export type Preview = {
package/src/types.ts CHANGED
@@ -7,8 +7,6 @@ export type UrlConfig = {
7
7
  authenticationApi: string;
8
8
  /** Prismic migration api base url */
9
9
  migrationApi?: string;
10
- /** Asset api base url */
11
- assetApi: string;
12
10
  };
13
11
 
14
12
  export type AuthConfig = {
@@ -29,5 +27,4 @@ export type SetupConfiguration = {
29
27
  authConfig: AuthConfig;
30
28
  manageV2Config?: ManageV2Config;
31
29
  cluster?: string;
32
- environment?: string;
33
30
  };
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const log = require("../utils/log.cjs");
4
- const apiClient = require("./apiClient.cjs");
5
- class AssetApiClient extends apiClient.AuthenticatedApiClient {
6
- /**
7
- * @example To instantiate the class:
8
- *
9
- * ```js
10
- * new AssetApiClient("https://asset-api.prismic.io", {
11
- * authToken: "my-secret-token",
12
- * repository: "my-repo-name",
13
- * });
14
- * ```
15
- *
16
- * @param baseURL - The API base URL, such as https://asset-api.prismic.io
17
- * @param config - Optional configuration
18
- *
19
- * - {@link config.authToken}: API token generated from the auth service or a
20
- * function to fetch it when it's needed.
21
- * - {@link config.repository}: Repository name.
22
- */
23
- constructor(baseURL, config) {
24
- super(baseURL, config.authToken, { repository: config.repository });
25
- }
26
- /**
27
- * Uploads an asset file to the server.
28
- *
29
- * @param data - The payload containing the file and filename.
30
- *
31
- * @returns The API response containing asset information.
32
- *
33
- * @throws An error if the upload fails.
34
- */
35
- async createAsset(data) {
36
- const context = await this.getContext();
37
- const result = await context.post("assets", {
38
- multipart: { file: data }
39
- });
40
- if (200 !== result.status()) {
41
- await log.logPlaywrightApiResponse(result);
42
- throw new Error("Could not upload the asset with the asset API.");
43
- }
44
- return result.json();
45
- }
46
- }
47
- exports.AssetApiClient = AssetApiClient;
48
- //# sourceMappingURL=assetApi.cjs.map
@@ -1 +0,0 @@
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,54 +0,0 @@
1
- /// <reference types="node" />
2
- import { AuthServerToken, AuthenticatedApiClient } from "./apiClient";
3
- export interface AssetApiCreatePayload {
4
- name: string;
5
- mimeType: string;
6
- buffer: Buffer;
7
- }
8
- export interface AssetApiCreateResponse {
9
- id: string;
10
- url: string;
11
- filename: string;
12
- size: number;
13
- width: number;
14
- height: number;
15
- last_modified: number;
16
- kind: string;
17
- extension: string;
18
- created_at: number;
19
- uploader_id: string;
20
- tags: string[];
21
- }
22
- export declare class AssetApiClient extends AuthenticatedApiClient {
23
- /**
24
- * @example To instantiate the class:
25
- *
26
- * ```js
27
- * new AssetApiClient("https://asset-api.prismic.io", {
28
- * authToken: "my-secret-token",
29
- * repository: "my-repo-name",
30
- * });
31
- * ```
32
- *
33
- * @param baseURL - The API base URL, such as https://asset-api.prismic.io
34
- * @param config - Optional configuration
35
- *
36
- * - {@link config.authToken}: API token generated from the auth service or a
37
- * function to fetch it when it's needed.
38
- * - {@link config.repository}: Repository name.
39
- */
40
- constructor(baseURL: string, config: {
41
- authToken: AuthServerToken;
42
- repository: string;
43
- });
44
- /**
45
- * Uploads an asset file to the server.
46
- *
47
- * @param data - The payload containing the file and filename.
48
- *
49
- * @returns The API response containing asset information.
50
- *
51
- * @throws An error if the upload fails.
52
- */
53
- createAsset(data: AssetApiCreatePayload): Promise<AssetApiCreateResponse>;
54
- }
@@ -1,48 +0,0 @@
1
- import { logPlaywrightApiResponse } from "../utils/log.js";
2
- import { AuthenticatedApiClient } from "./apiClient.js";
3
- class AssetApiClient extends AuthenticatedApiClient {
4
- /**
5
- * @example To instantiate the class:
6
- *
7
- * ```js
8
- * new AssetApiClient("https://asset-api.prismic.io", {
9
- * authToken: "my-secret-token",
10
- * repository: "my-repo-name",
11
- * });
12
- * ```
13
- *
14
- * @param baseURL - The API base URL, such as https://asset-api.prismic.io
15
- * @param config - Optional configuration
16
- *
17
- * - {@link config.authToken}: API token generated from the auth service or a
18
- * function to fetch it when it's needed.
19
- * - {@link config.repository}: Repository name.
20
- */
21
- constructor(baseURL, config) {
22
- super(baseURL, config.authToken, { repository: config.repository });
23
- }
24
- /**
25
- * Uploads an asset file to the server.
26
- *
27
- * @param data - The payload containing the file and filename.
28
- *
29
- * @returns The API response containing asset information.
30
- *
31
- * @throws An error if the upload fails.
32
- */
33
- async createAsset(data) {
34
- const context = await this.getContext();
35
- const result = await context.post("assets", {
36
- multipart: { file: data }
37
- });
38
- if (200 !== result.status()) {
39
- await logPlaywrightApiResponse(result);
40
- throw new Error("Could not upload the asset with the asset API.");
41
- }
42
- return result.json();
43
- }
44
- }
45
- export {
46
- AssetApiClient
47
- };
48
- //# sourceMappingURL=assetApi.js.map
@@ -1 +0,0 @@
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,76 +0,0 @@
1
- import { logPlaywrightApiResponse } from "../utils/log";
2
-
3
- import { AuthServerToken, AuthenticatedApiClient } from "./apiClient";
4
-
5
- export interface AssetApiCreatePayload {
6
- name: string;
7
- mimeType: string;
8
- buffer: Buffer;
9
- }
10
-
11
- export interface AssetApiCreateResponse {
12
- id: string;
13
- url: string;
14
- filename: string;
15
- size: number;
16
- width: number;
17
- height: number;
18
- last_modified: number;
19
- kind: string;
20
- extension: string;
21
- created_at: number;
22
- uploader_id: string;
23
- tags: string[];
24
- }
25
-
26
- export class AssetApiClient extends AuthenticatedApiClient {
27
- /**
28
- * @example To instantiate the class:
29
- *
30
- * ```js
31
- * new AssetApiClient("https://asset-api.prismic.io", {
32
- * authToken: "my-secret-token",
33
- * repository: "my-repo-name",
34
- * });
35
- * ```
36
- *
37
- * @param baseURL - The API base URL, such as https://asset-api.prismic.io
38
- * @param config - Optional configuration
39
- *
40
- * - {@link config.authToken}: API token generated from the auth service or a
41
- * function to fetch it when it's needed.
42
- * - {@link config.repository}: Repository name.
43
- */
44
- constructor(
45
- baseURL: string,
46
- config: { authToken: AuthServerToken; repository: string },
47
- ) {
48
- super(baseURL, config.authToken, { repository: config.repository });
49
- }
50
-
51
- /**
52
- * Uploads an asset file to the server.
53
- *
54
- * @param data - The payload containing the file and filename.
55
- *
56
- * @returns The API response containing asset information.
57
- *
58
- * @throws An error if the upload fails.
59
- */
60
- async createAsset(
61
- data: AssetApiCreatePayload,
62
- ): Promise<AssetApiCreateResponse> {
63
- const context = await this.getContext();
64
-
65
- const result = await context.post("assets", {
66
- multipart: { file: data },
67
- });
68
-
69
- if (200 !== result.status()) {
70
- await logPlaywrightApiResponse(result);
71
- throw new Error("Could not upload the asset with the asset API.");
72
- }
73
-
74
- return result.json();
75
- }
76
- }