@prismicio/e2e-tests-utils 1.18.0 → 1.19.0-pr.37.21fc0dd

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 +592 -616
  96. package/dist/managers/repository.cjs.map +1 -1
  97. package/dist/managers/repository.d.cts +339 -0
  98. package/dist/managers/repository.d.cts.map +1 -0
  99. package/dist/managers/repository.d.ts +334 -307
  100. package/dist/managers/repository.d.ts.map +1 -0
  101. package/dist/managers/repository.js +592 -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 +394 -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
@@ -1,37 +1,38 @@
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 MigrationApiClient extends apiClient.AuthenticatedApiClient {
6
- /**
7
- * @example To instantiate the class:
8
- *
9
- * ```js
10
- * new MigrationApiClient("https://migration.prismic.io", {
11
- * authToken: "my-secret-token",
12
- * repository: "my-repo-name",
13
- * });
14
- * ```
15
- *
16
- * @param baseURL - the api base URL like https://migration.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
- async createDocument(data) {
27
- const context = await this.getContext();
28
- const result = await context.post("documents", { data });
29
- if (201 !== result.status()) {
30
- await log.logPlaywrightApiResponse(result);
31
- throw new Error("Could not create a document with the migration api.");
32
- }
33
- return result.json();
34
- }
35
- }
1
+ const require_log = require("../utils/log.cjs");
2
+ const require_apiClient = require("./apiClient.cjs");
3
+ //#region src/clients/migrationApi.ts
4
+ var MigrationApiClient = class extends require_apiClient.AuthenticatedApiClient {
5
+ /**
6
+ * @example
7
+ * To instantiate the class:
8
+ *
9
+ * ```js
10
+ * new MigrationApiClient("https://migration.prismic.io", {
11
+ * authToken: "my-secret-token",
12
+ * repository: "my-repo-name",
13
+ * });
14
+ * ```
15
+ *
16
+ * @param baseURL - The api base URL like https://migration.prismic.io
17
+ * @param config - Optional configuration
18
+ *
19
+ * - {@link config.authToken}: Api token generated from the auth service or a function to fetch it
20
+ * 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
+ async createDocument(data) {
27
+ const result = await (await this.getContext()).post("documents", { data });
28
+ if (201 !== result.status()) {
29
+ await require_log.logPlaywrightApiResponse(result);
30
+ throw new Error("Could not create a document with the migration api.");
31
+ }
32
+ return result.json();
33
+ }
34
+ };
35
+ //#endregion
36
36
  exports.MigrationApiClient = MigrationApiClient;
37
- //# sourceMappingURL=migrationApi.cjs.map
37
+
38
+ //# sourceMappingURL=migrationApi.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrationApi.cjs","sources":["../../../src/clients/migrationApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\nexport type MigrationApiDocumentPayload = {\n\tuid?: string | null;\n\ttype: string;\n\tlang: string;\n\ttitle: string;\n\ttags?: string[];\n\talternate_language_id?: string;\n\tdata: Record<string, unknown>;\n\t// if true, the document will be part of the documents list instead of in the migration release\n\tinDocuments?: boolean;\n};\nexport type MigrationApiDocumentResponse = {\n\tid: string;\n\ttype: string;\n\tlang: string;\n\ttitle: string;\n\tuid?: string;\n};\n\nexport class MigrationApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new MigrationApiClient(\"https://migration.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 like https://migration.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\tasync createDocument(\n\t\tdata: MigrationApiDocumentPayload,\n\t): Promise<MigrationApiDocumentResponse> {\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.post(\"documents\", { data });\n\n\t\tif (201 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not create a document with the migration api.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n}\n"],"names":["AuthenticatedApiClient","logPlaywrightApiResponse"],"mappings":";;;;AAuBM,MAAO,2BAA2BA,UAAAA,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkB7D,YACC,SACA,QAA0D;AAE1D,UAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,YAAY;AAAA,EACnE;AAAA,EAEA,MAAM,eACL,MAAiC;AAE3B,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,KAAK,aAAa,EAAE,MAAM;AAEnD,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAMC,IAAAA,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,qDAAqD;AAAA,IACtE;AAEA,WAAO,OAAO;EACf;AACA;;"}
1
+ {"version":3,"file":"migrationApi.cjs","names":["AuthenticatedApiClient","logPlaywrightApiResponse"],"sources":["../../src/clients/migrationApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\"\nimport type { AuthServerToken } from \"./apiClient\"\nimport { AuthenticatedApiClient } from \"./apiClient\"\n\nexport type MigrationApiDocumentPayload = {\n\tuid?: string | null\n\ttype: string\n\tlang: string\n\ttitle: string\n\ttags?: string[]\n\talternate_language_id?: string\n\tdata: Record<string, unknown>\n\t// if true, the document will be part of the documents list instead of in the migration release\n\tinDocuments?: boolean\n}\nexport type MigrationApiDocumentResponse = {\n\tid: string\n\ttype: string\n\tlang: string\n\ttitle: string\n\tuid?: string\n}\n\nexport class MigrationApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example\n\t * \tTo instantiate the class:\n\t *\n\t * \t```js\n\t * \tnew MigrationApiClient(\"https://migration.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \trepository: \"my-repo-name\",\n\t * \t});\n\t * \t```\n\t *\n\t * @param baseURL - The api base URL like https://migration.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.authToken}: Api token generated from the auth service or a function to fetch it\n\t * when it's needed.\n\t * - {@link config.repository}: Repository name.\n\t */\n\tconstructor(baseURL: string, config: { authToken: AuthServerToken; repository: string }) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository })\n\t}\n\n\tasync createDocument(data: MigrationApiDocumentPayload): Promise<MigrationApiDocumentResponse> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(\"documents\", { data })\n\n\t\tif (201 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not create a document with the migration api.\")\n\t\t}\n\n\t\treturn result.json()\n\t}\n}\n"],"mappings":";;;AAuBA,IAAa,qBAAb,cAAwCA,kBAAAA,uBAAuB;;;;;;;;;;;;;;;;;;;CAmB9D,YAAY,SAAiB,QAA4D;EACxF,MAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,WAAW,CAAC;CACnE;CAEA,MAAM,eAAe,MAA0E;EAE9F,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,KAAK,aAAa,EAAE,KAAK,CAAC;EAEvD,IAAI,QAAQ,OAAO,OAAO,GAAG;GAC5B,MAAMC,YAAAA,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,qDAAqD;EACtE;EAEA,OAAO,OAAO,KAAK;CACpB;AACD"}
@@ -0,0 +1,48 @@
1
+ import { AuthServerToken, AuthenticatedApiClient } from "./apiClient.cjs";
2
+
3
+ //#region src/clients/migrationApi.d.ts
4
+ type MigrationApiDocumentPayload = {
5
+ uid?: string | null;
6
+ type: string;
7
+ lang: string;
8
+ title: string;
9
+ tags?: string[];
10
+ alternate_language_id?: string;
11
+ data: Record<string, unknown>;
12
+ inDocuments?: boolean;
13
+ };
14
+ type MigrationApiDocumentResponse = {
15
+ id: string;
16
+ type: string;
17
+ lang: string;
18
+ title: string;
19
+ uid?: string;
20
+ };
21
+ declare class MigrationApiClient extends AuthenticatedApiClient {
22
+ /**
23
+ * @example
24
+ * To instantiate the class:
25
+ *
26
+ * ```js
27
+ * new MigrationApiClient("https://migration.prismic.io", {
28
+ * authToken: "my-secret-token",
29
+ * repository: "my-repo-name",
30
+ * });
31
+ * ```
32
+ *
33
+ * @param baseURL - The api base URL like https://migration.prismic.io
34
+ * @param config - Optional configuration
35
+ *
36
+ * - {@link config.authToken}: Api token generated from the auth service or a function to fetch it
37
+ * when it's needed.
38
+ * - {@link config.repository}: Repository name.
39
+ */
40
+ constructor(baseURL: string, config: {
41
+ authToken: AuthServerToken;
42
+ repository: string;
43
+ });
44
+ createDocument(data: MigrationApiDocumentPayload): Promise<MigrationApiDocumentResponse>;
45
+ }
46
+ //#endregion
47
+ export { MigrationApiClient, MigrationApiDocumentPayload, MigrationApiDocumentResponse };
48
+ //# sourceMappingURL=migrationApi.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrationApi.d.cts","names":[],"sources":["../../src/clients/migrationApi.ts"],"mappings":";;;KAIY,2BAAA;EACX,GAAA;EACA,IAAA;EACA,IAAA;EACA,KAAA;EACA,IAAA;EACA,qBAAA;EACA,IAAA,EAAM,MAAM;EAEZ,WAAA;AAAA;AAAA,KAEW,4BAAA;EACX,EAAA;EACA,IAAA;EACA,IAAA;EACA,KAAA;EACA,GAAA;AAAA;AAAA,cAGY,kBAAA,SAA2B,sBAAA;;;;;;;;;AAHpC;AAGJ;;;;;;;;;cAmBa,OAAA,UAAiB,MAAA;IAAU,SAAA,EAAW,eAAA;IAAiB,UAAA;EAAA;EAI7D,cAAA,CAAe,IAAA,EAAM,2BAAA,GAA8B,OAAA,CAAQ,4BAAA;AAAA"}
@@ -1,42 +1,48 @@
1
- import { AuthServerToken, AuthenticatedApiClient } from "./apiClient";
2
- export type MigrationApiDocumentPayload = {
3
- uid?: string | null;
4
- type: string;
5
- lang: string;
6
- title: string;
7
- tags?: string[];
8
- alternate_language_id?: string;
9
- data: Record<string, unknown>;
10
- inDocuments?: boolean;
1
+ import { AuthServerToken, AuthenticatedApiClient } from "./apiClient.js";
2
+
3
+ //#region src/clients/migrationApi.d.ts
4
+ type MigrationApiDocumentPayload = {
5
+ uid?: string | null;
6
+ type: string;
7
+ lang: string;
8
+ title: string;
9
+ tags?: string[];
10
+ alternate_language_id?: string;
11
+ data: Record<string, unknown>;
12
+ inDocuments?: boolean;
11
13
  };
12
- export type MigrationApiDocumentResponse = {
13
- id: string;
14
- type: string;
15
- lang: string;
16
- title: string;
17
- uid?: string;
14
+ type MigrationApiDocumentResponse = {
15
+ id: string;
16
+ type: string;
17
+ lang: string;
18
+ title: string;
19
+ uid?: string;
18
20
  };
19
- export declare class MigrationApiClient extends AuthenticatedApiClient {
20
- /**
21
- * @example To instantiate the class:
22
- *
23
- * ```js
24
- * new MigrationApiClient("https://migration.prismic.io", {
25
- * authToken: "my-secret-token",
26
- * repository: "my-repo-name",
27
- * });
28
- * ```
29
- *
30
- * @param baseURL - the api base URL like https://migration.prismic.io
31
- * @param config - Optional configuration
32
- *
33
- * - {@link config.authToken}: Api token generated from the auth service or a
34
- * function to fetch it when it's needed.
35
- * - {@link config.repository}: Repository name.
36
- */
37
- constructor(baseURL: string, config: {
38
- authToken: AuthServerToken;
39
- repository: string;
40
- });
41
- createDocument(data: MigrationApiDocumentPayload): Promise<MigrationApiDocumentResponse>;
21
+ declare class MigrationApiClient extends AuthenticatedApiClient {
22
+ /**
23
+ * @example
24
+ * To instantiate the class:
25
+ *
26
+ * ```js
27
+ * new MigrationApiClient("https://migration.prismic.io", {
28
+ * authToken: "my-secret-token",
29
+ * repository: "my-repo-name",
30
+ * });
31
+ * ```
32
+ *
33
+ * @param baseURL - The api base URL like https://migration.prismic.io
34
+ * @param config - Optional configuration
35
+ *
36
+ * - {@link config.authToken}: Api token generated from the auth service or a function to fetch it
37
+ * when it's needed.
38
+ * - {@link config.repository}: Repository name.
39
+ */
40
+ constructor(baseURL: string, config: {
41
+ authToken: AuthServerToken;
42
+ repository: string;
43
+ });
44
+ createDocument(data: MigrationApiDocumentPayload): Promise<MigrationApiDocumentResponse>;
42
45
  }
46
+ //#endregion
47
+ export { MigrationApiClient, MigrationApiDocumentPayload, MigrationApiDocumentResponse };
48
+ //# sourceMappingURL=migrationApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrationApi.d.ts","names":[],"sources":["../../src/clients/migrationApi.ts"],"mappings":";;;KAIY,2BAAA;EACX,GAAA;EACA,IAAA;EACA,IAAA;EACA,KAAA;EACA,IAAA;EACA,qBAAA;EACA,IAAA,EAAM,MAAM;EAEZ,WAAA;AAAA;AAAA,KAEW,4BAAA;EACX,EAAA;EACA,IAAA;EACA,IAAA;EACA,KAAA;EACA,GAAA;AAAA;AAAA,cAGY,kBAAA,SAA2B,sBAAA;;;;;;;;;AAHpC;AAGJ;;;;;;;;;cAmBa,OAAA,UAAiB,MAAA;IAAU,SAAA,EAAW,eAAA;IAAiB,UAAA;EAAA;EAI7D,cAAA,CAAe,IAAA,EAAM,2BAAA,GAA8B,OAAA,CAAQ,4BAAA;AAAA"}
@@ -1,37 +1,38 @@
1
1
  import { logPlaywrightApiResponse } from "../utils/log.js";
2
2
  import { AuthenticatedApiClient } from "./apiClient.js";
3
- class MigrationApiClient extends AuthenticatedApiClient {
4
- /**
5
- * @example To instantiate the class:
6
- *
7
- * ```js
8
- * new MigrationApiClient("https://migration.prismic.io", {
9
- * authToken: "my-secret-token",
10
- * repository: "my-repo-name",
11
- * });
12
- * ```
13
- *
14
- * @param baseURL - the api base URL like https://migration.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
- async createDocument(data) {
25
- const context = await this.getContext();
26
- const result = await context.post("documents", { data });
27
- if (201 !== result.status()) {
28
- await logPlaywrightApiResponse(result);
29
- throw new Error("Could not create a document with the migration api.");
30
- }
31
- return result.json();
32
- }
33
- }
34
- export {
35
- MigrationApiClient
3
+ //#region src/clients/migrationApi.ts
4
+ var MigrationApiClient = class extends AuthenticatedApiClient {
5
+ /**
6
+ * @example
7
+ * To instantiate the class:
8
+ *
9
+ * ```js
10
+ * new MigrationApiClient("https://migration.prismic.io", {
11
+ * authToken: "my-secret-token",
12
+ * repository: "my-repo-name",
13
+ * });
14
+ * ```
15
+ *
16
+ * @param baseURL - The api base URL like https://migration.prismic.io
17
+ * @param config - Optional configuration
18
+ *
19
+ * - {@link config.authToken}: Api token generated from the auth service or a function to fetch it
20
+ * 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
+ async createDocument(data) {
27
+ const result = await (await this.getContext()).post("documents", { data });
28
+ if (201 !== result.status()) {
29
+ await logPlaywrightApiResponse(result);
30
+ throw new Error("Could not create a document with the migration api.");
31
+ }
32
+ return result.json();
33
+ }
36
34
  };
37
- //# sourceMappingURL=migrationApi.js.map
35
+ //#endregion
36
+ export { MigrationApiClient };
37
+
38
+ //# sourceMappingURL=migrationApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrationApi.js","sources":["../../../src/clients/migrationApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\nexport type MigrationApiDocumentPayload = {\n\tuid?: string | null;\n\ttype: string;\n\tlang: string;\n\ttitle: string;\n\ttags?: string[];\n\talternate_language_id?: string;\n\tdata: Record<string, unknown>;\n\t// if true, the document will be part of the documents list instead of in the migration release\n\tinDocuments?: boolean;\n};\nexport type MigrationApiDocumentResponse = {\n\tid: string;\n\ttype: string;\n\tlang: string;\n\ttitle: string;\n\tuid?: string;\n};\n\nexport class MigrationApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new MigrationApiClient(\"https://migration.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 like https://migration.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\tasync createDocument(\n\t\tdata: MigrationApiDocumentPayload,\n\t): Promise<MigrationApiDocumentResponse> {\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.post(\"documents\", { data });\n\n\t\tif (201 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not create a document with the migration api.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n}\n"],"names":[],"mappings":";;AAuBM,MAAO,2BAA2B,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkB7D,YACC,SACA,QAA0D;AAE1D,UAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,YAAY;AAAA,EACnE;AAAA,EAEA,MAAM,eACL,MAAiC;AAE3B,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,KAAK,aAAa,EAAE,MAAM;AAEnD,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAM,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,qDAAqD;AAAA,IACtE;AAEA,WAAO,OAAO;EACf;AACA;"}
1
+ {"version":3,"file":"migrationApi.js","names":[],"sources":["../../src/clients/migrationApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\"\nimport type { AuthServerToken } from \"./apiClient\"\nimport { AuthenticatedApiClient } from \"./apiClient\"\n\nexport type MigrationApiDocumentPayload = {\n\tuid?: string | null\n\ttype: string\n\tlang: string\n\ttitle: string\n\ttags?: string[]\n\talternate_language_id?: string\n\tdata: Record<string, unknown>\n\t// if true, the document will be part of the documents list instead of in the migration release\n\tinDocuments?: boolean\n}\nexport type MigrationApiDocumentResponse = {\n\tid: string\n\ttype: string\n\tlang: string\n\ttitle: string\n\tuid?: string\n}\n\nexport class MigrationApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example\n\t * \tTo instantiate the class:\n\t *\n\t * \t```js\n\t * \tnew MigrationApiClient(\"https://migration.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \trepository: \"my-repo-name\",\n\t * \t});\n\t * \t```\n\t *\n\t * @param baseURL - The api base URL like https://migration.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.authToken}: Api token generated from the auth service or a function to fetch it\n\t * when it's needed.\n\t * - {@link config.repository}: Repository name.\n\t */\n\tconstructor(baseURL: string, config: { authToken: AuthServerToken; repository: string }) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository })\n\t}\n\n\tasync createDocument(data: MigrationApiDocumentPayload): Promise<MigrationApiDocumentResponse> {\n\t\tconst context = await this.getContext()\n\t\tconst result = await context.post(\"documents\", { data })\n\n\t\tif (201 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result)\n\t\t\tthrow new Error(\"Could not create a document with the migration api.\")\n\t\t}\n\n\t\treturn result.json()\n\t}\n}\n"],"mappings":";;;AAuBA,IAAa,qBAAb,cAAwC,uBAAuB;;;;;;;;;;;;;;;;;;;CAmB9D,YAAY,SAAiB,QAA4D;EACxF,MAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,WAAW,CAAC;CACnE;CAEA,MAAM,eAAe,MAA0E;EAE9F,MAAM,SAAS,OAAM,MADC,KAAK,WAAW,EAAA,CACT,KAAK,aAAa,EAAE,KAAK,CAAC;EAEvD,IAAI,QAAQ,OAAO,OAAO,GAAG;GAC5B,MAAM,yBAAyB,MAAM;GACrC,MAAM,IAAI,MAAM,qDAAqD;EACtE;EAEA,OAAO,OAAO,KAAK;CACpB;AACD"}
@@ -1,124 +1,103 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
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) => {
5
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
- return value;
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_log = require("../utils/log.cjs");
3
+ const require_urls = require("../utils/urls.cjs");
4
+ const require_cookies = require("../utils/cookies.cjs");
5
+ let axios = require("axios");
6
+ axios = require_runtime.__toESM(axios, 1);
7
+ //#region src/clients/wroom.ts
8
+ /** Client for interacting with the Wroom service to perform operations on repositories. */
9
+ var WroomClient = class {
10
+ auth;
11
+ client;
12
+ loggedIn = false;
13
+ /**
14
+ * @param baseURL - The base URL of the Wroom app. ex: https://prismic.io
15
+ * @param auth - Authentication credentials.
16
+ * @param cluster - Cluster where to create the repository (only work in staging)
17
+ */
18
+ constructor(baseURL, auth, cluster) {
19
+ this.auth = auth;
20
+ const clusterHeader = cluster ? { "X-Prismic-Cluster": cluster } : {};
21
+ this.client = axios.default.create({
22
+ baseURL,
23
+ withCredentials: true,
24
+ validateStatus: () => true,
25
+ xsrfCookieName: "X_XSRF",
26
+ headers: {
27
+ "User-Agent": "prismic-cli/prismic-e2e-tests-utils",
28
+ ...clusterHeader
29
+ }
30
+ });
31
+ this.client.interceptors.response.use((response) => {
32
+ const cookies = response.headers["set-cookie"];
33
+ if (cookies && require_cookies.extractCookie(cookies, "SESSION")) this.client.defaults.headers["Cookie"] = cookies;
34
+ return response;
35
+ });
36
+ }
37
+ getBaseURL() {
38
+ return this.client.getUri();
39
+ }
40
+ /** Authenticated GET request on the wroom backend */
41
+ async get(repository, path) {
42
+ if (!this.loggedIn) await this.login();
43
+ let url = new URL(path, this.client.getUri()).toString();
44
+ if (repository) url = require_urls.getRepositoryUrl(url, repository);
45
+ return this.client.get(url);
46
+ }
47
+ /** Authenticated POST request on the wroom backend */
48
+ async post(repository, path, data) {
49
+ if (!this.loggedIn) await this.login();
50
+ let url = new URL(path, this.client.getUri()).toString();
51
+ if (repository) url = require_urls.getRepositoryUrl(url, repository);
52
+ return await this.client.post(url.toString(), data, { params: { _: require_cookies.extractCookie(this.client.defaults.headers["Cookie"], "X_XSRF") } });
53
+ }
54
+ /**
55
+ * Update the role of a user in the repository
56
+ *
57
+ * @param {string} repository - The repository name
58
+ * @param {string} email - The email of the user
59
+ * @param {string} role - The new role to be given
60
+ * @returns The Axios Reponse
61
+ */
62
+ async updateRole(repository, email, role) {
63
+ const path = `/app/settings/users/profiles?${new URLSearchParams({
64
+ email,
65
+ profile: role
66
+ }).toString()}`;
67
+ return this.post(repository, path);
68
+ }
69
+ /**
70
+ * Update the role of a user in the repository
71
+ *
72
+ * @param {string} repository - The repository name
73
+ * @param {string} email - The email of the user
74
+ * @param {string} rolePerLocal - The role per local object
75
+ * @returns The Axios Reponse
76
+ */
77
+ async updateRolePerLocal(repository, email, rolePerLocal) {
78
+ const path = `/app/settings/users/rolesperlocale?${new URLSearchParams({ email }).toString()}`;
79
+ return this.post(repository, path, rolePerLocal);
80
+ }
81
+ /**
82
+ * Authenticate Wroom to call Wroom unofficial endpoints.
83
+ *
84
+ * @throws Error if the login to Wroom fails.
85
+ */
86
+ async login() {
87
+ const profiler = require_log.logger.startTimer();
88
+ const response = await this.client.post("/authentication/signin", {
89
+ email: this.auth.email,
90
+ password: this.auth.password
91
+ });
92
+ if (response.status !== 200) {
93
+ require_log.logHttpResponse(response);
94
+ throw new Error("Could not login to Prismic, check your credentials");
95
+ }
96
+ this.loggedIn = true;
97
+ profiler.done({ message: "logged in to Prismic" });
98
+ }
7
99
  };
8
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
9
- const axios = require("axios");
10
- const cookies = require("../utils/cookies.cjs");
11
- const log = require("../utils/log.cjs");
12
- const urls = require("../utils/urls.cjs");
13
- class WroomClient {
14
- /**
15
- * @param baseURL - The base URL of the Wroom app. ex: https://prismic.io
16
- * @param auth - Authentication credentials.
17
- * @param cluster - Cluster where to create the repository (only work in
18
- * staging)
19
- */
20
- constructor(baseURL, auth, cluster) {
21
- __publicField(this, "auth");
22
- __publicField(this, "client");
23
- __publicField(this, "loggedIn", false);
24
- this.auth = auth;
25
- const clusterHeader = cluster ? {
26
- "X-Prismic-Cluster": cluster
27
- } : {};
28
- this.client = axios.create({
29
- baseURL,
30
- withCredentials: true,
31
- validateStatus: () => true,
32
- xsrfCookieName: "X_XSRF",
33
- headers: {
34
- "User-Agent": "prismic-cli/prismic-e2e-tests-utils",
35
- ...clusterHeader
36
- }
37
- });
38
- this.client.interceptors.response.use((response) => {
39
- const cookies$1 = response.headers["set-cookie"];
40
- if (cookies$1 && cookies.extractCookie(cookies$1, "SESSION")) {
41
- this.client.defaults.headers["Cookie"] = cookies$1;
42
- }
43
- return response;
44
- });
45
- }
46
- getBaseURL() {
47
- return this.client.getUri();
48
- }
49
- /** authenticated GET request on the wroom backend */
50
- async get(repository, path) {
51
- if (!this.loggedIn) {
52
- await this.login();
53
- }
54
- let url = new URL(path, this.client.getUri()).toString();
55
- if (repository) {
56
- url = urls.getRepositoryUrl(url, repository);
57
- }
58
- return this.client.get(url);
59
- }
60
- /** authenticated POST request on the wroom backend */
61
- async post(repository, path, data) {
62
- if (!this.loggedIn) {
63
- await this.login();
64
- }
65
- let url = new URL(path, this.client.getUri()).toString();
66
- if (repository) {
67
- url = urls.getRepositoryUrl(url, repository);
68
- }
69
- const response = await this.client.post(url.toString(), data, {
70
- params: {
71
- _: cookies.extractCookie(this.client.defaults.headers["Cookie"], "X_XSRF")
72
- }
73
- });
74
- return response;
75
- }
76
- /**
77
- * Update the role of a user in the repository
78
- *
79
- * @param {string} repository - The repository name
80
- * @param {string} email - The email of the user
81
- * @param {string} role - The new role to be given
82
- *
83
- * @returns The Axios Reponse
84
- */
85
- async updateRole(repository, email, role) {
86
- const params = new URLSearchParams({ email, profile: role });
87
- const path = `/app/settings/users/profiles?${params.toString()}`;
88
- return this.post(repository, path);
89
- }
90
- /**
91
- * Update the role of a user in the repository
92
- *
93
- * @param {string} repository - The repository name
94
- * @param {string} email - The email of the user
95
- * @param {string} rolePerLocal - The role per local object
96
- *
97
- * @returns The Axios Reponse
98
- */
99
- async updateRolePerLocal(repository, email, rolePerLocal) {
100
- const params = new URLSearchParams({ email });
101
- const path = `/app/settings/users/rolesperlocale?${params.toString()}`;
102
- return this.post(repository, path, rolePerLocal);
103
- }
104
- /**
105
- * Authenticate Wroom to call Wroom unofficial endpoints.
106
- *
107
- * @throws Error if the login to Wroom fails.
108
- */
109
- async login() {
110
- const profiler = log.logger.startTimer();
111
- const response = await this.client.post("/authentication/signin", {
112
- email: this.auth.email,
113
- password: this.auth.password
114
- });
115
- if (response.status !== 200) {
116
- log.logHttpResponse(response);
117
- throw new Error("Could not login to Prismic, check your credentials");
118
- }
119
- this.loggedIn = true;
120
- profiler.done({ message: "logged in to Prismic" });
121
- }
122
- }
100
+ //#endregion
123
101
  exports.WroomClient = WroomClient;
124
- //# sourceMappingURL=wroom.cjs.map
102
+
103
+ //# sourceMappingURL=wroom.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"wroom.cjs","sources":["../../../src/clients/wroom.ts"],"sourcesContent":["import axios, { AxiosInstance, AxiosResponse } from \"axios\";\n\nimport { AuthConfig } from \"../types\";\n\nimport { extractCookie } from \"../utils/cookies\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\n/**\n * Client for interacting with the Wroom service to perform operations on\n * repositories.\n */\nexport class WroomClient {\n\tprivate readonly client: AxiosInstance;\n\tprivate loggedIn = false;\n\n\t/**\n\t * @param baseURL - The base URL of the Wroom app. ex: https://prismic.io\n\t * @param auth - Authentication credentials.\n\t * @param cluster - Cluster where to create the repository (only work in\n\t * staging)\n\t */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tprivate readonly auth: AuthConfig,\n\t\tcluster?: string,\n\t) {\n\t\tconst clusterHeader = cluster\n\t\t\t? {\n\t\t\t\t\t\"X-Prismic-Cluster\": cluster,\n\t\t\t\t}\n\t\t\t: {};\n\n\t\tthis.client = axios.create({\n\t\t\tbaseURL,\n\t\t\twithCredentials: true,\n\t\t\tvalidateStatus: () => true,\n\t\t\txsrfCookieName: \"X_XSRF\",\n\t\t\theaders: {\n\t\t\t\t\"User-Agent\": \"prismic-cli/prismic-e2e-tests-utils\",\n\t\t\t\t...clusterHeader,\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, \"SESSION\")) {\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\tgetBaseURL(): string {\n\t\treturn this.client.getUri();\n\t}\n\n\t/** authenticated GET request on the wroom backend */\n\tasync get(repository: string | null, path: string): Promise<AxiosResponse> {\n\t\tif (!this.loggedIn) {\n\t\t\tawait this.login();\n\t\t}\n\n\t\tlet url = new URL(path, this.client.getUri()).toString();\n\t\tif (repository) {\n\t\t\turl = getRepositoryUrl(url, repository);\n\t\t}\n\n\t\treturn this.client.get(url);\n\t}\n\n\t/** authenticated POST request on the wroom backend */\n\tasync post(\n\t\trepository: string | null,\n\t\tpath: string,\n\t\tdata?: unknown,\n\t): Promise<AxiosResponse> {\n\t\tif (!this.loggedIn) {\n\t\t\tawait this.login();\n\t\t}\n\n\t\tlet url = new URL(path, this.client.getUri()).toString();\n\t\tif (repository) {\n\t\t\turl = getRepositoryUrl(url, repository);\n\t\t}\n\t\tconst response = await this.client.post(url.toString(), data, {\n\t\t\tparams: {\n\t\t\t\t_: extractCookie(this.client.defaults.headers[\"Cookie\"], \"X_XSRF\"),\n\t\t\t},\n\t\t});\n\n\t\treturn response;\n\t}\n\n\t/**\n\t * Update the role of a user in the repository\n\t *\n\t * @param {string} repository - The repository name\n\t * @param {string} email - The email of the user\n\t * @param {string} role - The new role to be given\n\t *\n\t * @returns The Axios Reponse\n\t */\n\tasync updateRole(\n\t\trepository: string,\n\t\temail: string,\n\t\trole: string,\n\t): Promise<AxiosResponse> {\n\t\tconst params = new URLSearchParams({ email, profile: role });\n\t\tconst path = `/app/settings/users/profiles?${params.toString()}`;\n\n\t\treturn this.post(repository, path);\n\t}\n\n\t/**\n\t * Update the role of a user in the repository\n\t *\n\t * @param {string} repository - The repository name\n\t * @param {string} email - The email of the user\n\t * @param {string} rolePerLocal - The role per local object\n\t *\n\t * @returns The Axios Reponse\n\t */\n\tasync updateRolePerLocal(\n\t\trepository: string,\n\t\temail: string,\n\t\trolePerLocal: Record<string, string>,\n\t): Promise<AxiosResponse> {\n\t\tconst params = new URLSearchParams({ email });\n\t\tconst path = `/app/settings/users/rolesperlocale?${params.toString()}`;\n\n\t\treturn this.post(repository, path, rolePerLocal);\n\t}\n\n\t/**\n\t * Authenticate Wroom to call Wroom unofficial endpoints.\n\t *\n\t * @throws Error if the login to Wroom fails.\n\t */\n\tprivate async login(): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\t\tconst response = await this.client.post<string>(\"/authentication/signin\", {\n\t\t\temail: this.auth.email,\n\t\t\tpassword: this.auth.password,\n\t\t});\n\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(\"Could not login to Prismic, check your credentials\");\n\t\t}\n\t\tthis.loggedIn = true;\n\t\tprofiler.done({ message: \"logged in to Prismic\" });\n\t}\n}\n"],"names":["cookies","extractCookie","getRepositoryUrl","logger","logHttpResponse"],"mappings":";;;;;;;;;;;;MAYa,YAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUvB,YACC,SACiB,MACjB,SAAgB;AADC;AAXD;AACT,oCAAW;AAUD,SAAI,OAAJ;AAGjB,UAAM,gBAAgB,UACnB;AAAA,MACA,qBAAqB;AAAA,QAErB;AAEE,SAAA,SAAS,MAAM,OAAO;AAAA,MAC1B;AAAA,MACA,iBAAiB;AAAA,MACjB,gBAAgB,MAAM;AAAA,MACtB,gBAAgB;AAAA,MAChB,SAAS;AAAA,QACR,cAAc;AAAA,QACd,GAAG;AAAA,MACH;AAAA,IAAA,CACD;AAGD,SAAK,OAAO,aAAa,SAAS,IAAI,CAAC,aAAY;AAC5C,YAAAA,YAAU,SAAS,QAAQ,YAAY;AAC7C,UAAIA,aAAWC,QAAAA,cAAcD,WAAS,SAAS,GAAG;AACjD,aAAK,OAAO,SAAS,QAAQ,QAAQ,IAAIA;AAAAA,MAC1C;AAEO,aAAA;AAAA,IAAA,CACP;AAAA,EACF;AAAA,EAEA,aAAU;AACF,WAAA,KAAK,OAAO;EACpB;AAAA;AAAA,EAGA,MAAM,IAAI,YAA2B,MAAY;AAC5C,QAAA,CAAC,KAAK,UAAU;AACnB,YAAM,KAAK;IACZ;AAEI,QAAA,MAAM,IAAI,IAAI,MAAM,KAAK,OAAO,OAAA,CAAQ,EAAE;AAC9C,QAAI,YAAY;AACT,YAAAE,KAAA,iBAAiB,KAAK,UAAU;AAAA,IACvC;AAEO,WAAA,KAAK,OAAO,IAAI,GAAG;AAAA,EAC3B;AAAA;AAAA,EAGA,MAAM,KACL,YACA,MACA,MAAc;AAEV,QAAA,CAAC,KAAK,UAAU;AACnB,YAAM,KAAK;IACZ;AAEI,QAAA,MAAM,IAAI,IAAI,MAAM,KAAK,OAAO,OAAA,CAAQ,EAAE;AAC9C,QAAI,YAAY;AACT,YAAAA,KAAA,iBAAiB,KAAK,UAAU;AAAA,IACvC;AACM,UAAA,WAAW,MAAM,KAAK,OAAO,KAAK,IAAI,YAAY,MAAM;AAAA,MAC7D,QAAQ;AAAA,QACP,GAAGD,QAAAA,cAAc,KAAK,OAAO,SAAS,QAAQ,QAAQ,GAAG,QAAQ;AAAA,MACjE;AAAA,IAAA,CACD;AAEM,WAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,WACL,YACA,OACA,MAAY;AAEZ,UAAM,SAAS,IAAI,gBAAgB,EAAE,OAAO,SAAS,MAAM;AAC3D,UAAM,OAAO,gCAAgC,OAAO,SAAA,CAAU;AAEvD,WAAA,KAAK,KAAK,YAAY,IAAI;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,mBACL,YACA,OACA,cAAoC;AAEpC,UAAM,SAAS,IAAI,gBAAgB,EAAE,MAAO,CAAA;AAC5C,UAAM,OAAO,sCAAsC,OAAO,SAAA,CAAU;AAEpE,WAAO,KAAK,KAAK,YAAY,MAAM,YAAY;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOQ,MAAM,QAAK;AACZ,UAAA,WAAWE,WAAO;AACxB,UAAM,WAAW,MAAM,KAAK,OAAO,KAAa,0BAA0B;AAAA,MACzE,OAAO,KAAK,KAAK;AAAA,MACjB,UAAU,KAAK,KAAK;AAAA,IAAA,CACpB;AAEG,QAAA,SAAS,WAAW,KAAK;AAC5BC,UAAA,gBAAgB,QAAQ;AAClB,YAAA,IAAI,MAAM,oDAAoD;AAAA,IACrE;AACA,SAAK,WAAW;AAChB,aAAS,KAAK,EAAE,SAAS,uBAAwB,CAAA;AAAA,EAClD;AACA;;"}
1
+ {"version":3,"file":"wroom.cjs","names":["extractCookie","getRepositoryUrl","logger"],"sources":["../../src/clients/wroom.ts"],"sourcesContent":["import type { AxiosInstance, AxiosResponse } from \"axios\"\nimport axios from \"axios\"\n\nimport type { AuthConfig } from \"../types\"\nimport { extractCookie } from \"../utils/cookies\"\nimport { logHttpResponse, logger } from \"../utils/log\"\nimport { getRepositoryUrl } from \"../utils/urls\"\n\n/** Client for interacting with the Wroom service to perform operations on repositories. */\nexport class WroomClient {\n\tprivate readonly client: AxiosInstance\n\tprivate loggedIn = false\n\n\t/**\n\t * @param baseURL - The base URL of the Wroom app. ex: https://prismic.io\n\t * @param auth - Authentication credentials.\n\t * @param cluster - Cluster where to create the repository (only work in staging)\n\t */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tprivate readonly auth: AuthConfig,\n\t\tcluster?: string,\n\t) {\n\t\tconst clusterHeader = cluster\n\t\t\t? {\n\t\t\t\t\t\"X-Prismic-Cluster\": cluster,\n\t\t\t\t}\n\t\t\t: {}\n\n\t\tthis.client = axios.create({\n\t\t\tbaseURL,\n\t\t\twithCredentials: true,\n\t\t\tvalidateStatus: () => true,\n\t\t\txsrfCookieName: \"X_XSRF\",\n\t\t\theaders: {\n\t\t\t\t\"User-Agent\": \"prismic-cli/prismic-e2e-tests-utils\",\n\t\t\t\t...clusterHeader,\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, \"SESSION\")) {\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\tgetBaseURL(): string {\n\t\treturn this.client.getUri()\n\t}\n\n\t/** Authenticated GET request on the wroom backend */\n\tasync get(repository: string | null, path: string): Promise<AxiosResponse> {\n\t\tif (!this.loggedIn) {\n\t\t\tawait this.login()\n\t\t}\n\n\t\tlet url = new URL(path, this.client.getUri()).toString()\n\t\tif (repository) {\n\t\t\turl = getRepositoryUrl(url, repository)\n\t\t}\n\n\t\treturn this.client.get(url)\n\t}\n\n\t/** Authenticated POST request on the wroom backend */\n\tasync post(repository: string | null, path: string, data?: unknown): Promise<AxiosResponse> {\n\t\tif (!this.loggedIn) {\n\t\t\tawait this.login()\n\t\t}\n\n\t\tlet url = new URL(path, this.client.getUri()).toString()\n\t\tif (repository) {\n\t\t\turl = getRepositoryUrl(url, repository)\n\t\t}\n\t\tconst response = await this.client.post(url.toString(), data, {\n\t\t\tparams: {\n\t\t\t\t_: extractCookie(this.client.defaults.headers[\"Cookie\"], \"X_XSRF\"),\n\t\t\t},\n\t\t})\n\n\t\treturn response\n\t}\n\n\t/**\n\t * Update the role of a user in the repository\n\t *\n\t * @param {string} repository - The repository name\n\t * @param {string} email - The email of the user\n\t * @param {string} role - The new role to be given\n\t * @returns The Axios Reponse\n\t */\n\tasync updateRole(repository: string, email: string, role: string): Promise<AxiosResponse> {\n\t\tconst params = new URLSearchParams({ email, profile: role })\n\t\tconst path = `/app/settings/users/profiles?${params.toString()}`\n\n\t\treturn this.post(repository, path)\n\t}\n\n\t/**\n\t * Update the role of a user in the repository\n\t *\n\t * @param {string} repository - The repository name\n\t * @param {string} email - The email of the user\n\t * @param {string} rolePerLocal - The role per local object\n\t * @returns The Axios Reponse\n\t */\n\tasync updateRolePerLocal(\n\t\trepository: string,\n\t\temail: string,\n\t\trolePerLocal: Record<string, string>,\n\t): Promise<AxiosResponse> {\n\t\tconst params = new URLSearchParams({ email })\n\t\tconst path = `/app/settings/users/rolesperlocale?${params.toString()}`\n\n\t\treturn this.post(repository, path, rolePerLocal)\n\t}\n\n\t/**\n\t * Authenticate Wroom to call Wroom unofficial endpoints.\n\t *\n\t * @throws Error if the login to Wroom fails.\n\t */\n\tprivate async login(): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\t\tconst response = await this.client.post<string>(\"/authentication/signin\", {\n\t\t\temail: this.auth.email,\n\t\t\tpassword: this.auth.password,\n\t\t})\n\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response)\n\t\t\tthrow new Error(\"Could not login to Prismic, check your credentials\")\n\t\t}\n\t\tthis.loggedIn = true\n\t\tprofiler.done({ message: \"logged in to Prismic\" })\n\t}\n}\n"],"mappings":";;;;;;;;AASA,IAAa,cAAb,MAAyB;CAWN;CAVlB;CACA,WAAmB;;;;;;CAOnB,YACC,SACA,MACA,SACC;EAFgB,KAAA,OAAA;EAGjB,MAAM,gBAAgB,UACnB,EACA,qBAAqB,QACtB,IACC,CAAC;EAEJ,KAAK,SAAS,MAAA,QAAM,OAAO;GAC1B;GACA,iBAAiB;GACjB,sBAAsB;GACtB,gBAAgB;GAChB,SAAS;IACR,cAAc;IACd,GAAG;GACJ;EACD,CAAC;EAGD,KAAK,OAAO,aAAa,SAAS,KAAK,aAAa;GACnD,MAAM,UAAU,SAAS,QAAQ;GACjC,IAAI,WAAWA,gBAAAA,cAAc,SAAS,SAAS,GAC9C,KAAK,OAAO,SAAS,QAAQ,YAAY;GAG1C,OAAO;EACR,CAAC;CACF;CAEA,aAAqB;EACpB,OAAO,KAAK,OAAO,OAAO;CAC3B;;CAGA,MAAM,IAAI,YAA2B,MAAsC;EAC1E,IAAI,CAAC,KAAK,UACT,MAAM,KAAK,MAAM;EAGlB,IAAI,MAAM,IAAI,IAAI,MAAM,KAAK,OAAO,OAAO,CAAC,CAAC,CAAC,SAAS;EACvD,IAAI,YACH,MAAMC,aAAAA,iBAAiB,KAAK,UAAU;EAGvC,OAAO,KAAK,OAAO,IAAI,GAAG;CAC3B;;CAGA,MAAM,KAAK,YAA2B,MAAc,MAAwC;EAC3F,IAAI,CAAC,KAAK,UACT,MAAM,KAAK,MAAM;EAGlB,IAAI,MAAM,IAAI,IAAI,MAAM,KAAK,OAAO,OAAO,CAAC,CAAC,CAAC,SAAS;EACvD,IAAI,YACH,MAAMA,aAAAA,iBAAiB,KAAK,UAAU;EAQvC,OAAO,MANgB,KAAK,OAAO,KAAK,IAAI,SAAS,GAAG,MAAM,EAC7D,QAAQ,EACP,GAAGD,gBAAAA,cAAc,KAAK,OAAO,SAAS,QAAQ,WAAW,QAAQ,EAClE,EACD,CAAC;CAGF;;;;;;;;;CAUA,MAAM,WAAW,YAAoB,OAAe,MAAsC;EAEzF,MAAM,OAAO,gCAAgC,IAD1B,gBAAgB;GAAE;GAAO,SAAS;EAAK,CACR,CAAC,CAAC,SAAS;EAE7D,OAAO,KAAK,KAAK,YAAY,IAAI;CAClC;;;;;;;;;CAUA,MAAM,mBACL,YACA,OACA,cACyB;EAEzB,MAAM,OAAO,sCAAsC,IADhC,gBAAgB,EAAE,MAAM,CACa,CAAC,CAAC,SAAS;EAEnE,OAAO,KAAK,KAAK,YAAY,MAAM,YAAY;CAChD;;;;;;CAOA,MAAc,QAAuB;EACpC,MAAM,WAAWE,YAAAA,OAAO,WAAW;EACnC,MAAM,WAAW,MAAM,KAAK,OAAO,KAAa,0BAA0B;GACzE,OAAO,KAAK,KAAK;GACjB,UAAU,KAAK,KAAK;EACrB,CAAC;EAED,IAAI,SAAS,WAAW,KAAK;GAC5B,YAAA,gBAAgB,QAAQ;GACxB,MAAM,IAAI,MAAM,oDAAoD;EACrE;EACA,KAAK,WAAW;EAChB,SAAS,KAAK,EAAE,SAAS,uBAAuB,CAAC;CAClD;AACD"}
@@ -0,0 +1,48 @@
1
+ import { AuthConfig } from "../types.cjs";
2
+ import { AxiosResponse } from "axios";
3
+
4
+ //#region src/clients/wroom.d.ts
5
+ /** Client for interacting with the Wroom service to perform operations on repositories. */
6
+ declare class WroomClient {
7
+ private readonly auth;
8
+ private readonly client;
9
+ private loggedIn;
10
+ /**
11
+ * @param baseURL - The base URL of the Wroom app. ex: https://prismic.io
12
+ * @param auth - Authentication credentials.
13
+ * @param cluster - Cluster where to create the repository (only work in staging)
14
+ */
15
+ constructor(baseURL: string, auth: AuthConfig, cluster?: string);
16
+ getBaseURL(): string;
17
+ /** Authenticated GET request on the wroom backend */
18
+ get(repository: string | null, path: string): Promise<AxiosResponse>;
19
+ /** Authenticated POST request on the wroom backend */
20
+ post(repository: string | null, path: string, data?: unknown): Promise<AxiosResponse>;
21
+ /**
22
+ * Update the role of a user in the repository
23
+ *
24
+ * @param {string} repository - The repository name
25
+ * @param {string} email - The email of the user
26
+ * @param {string} role - The new role to be given
27
+ * @returns The Axios Reponse
28
+ */
29
+ updateRole(repository: string, email: string, role: string): Promise<AxiosResponse>;
30
+ /**
31
+ * Update the role of a user in the repository
32
+ *
33
+ * @param {string} repository - The repository name
34
+ * @param {string} email - The email of the user
35
+ * @param {string} rolePerLocal - The role per local object
36
+ * @returns The Axios Reponse
37
+ */
38
+ updateRolePerLocal(repository: string, email: string, rolePerLocal: Record<string, string>): Promise<AxiosResponse>;
39
+ /**
40
+ * Authenticate Wroom to call Wroom unofficial endpoints.
41
+ *
42
+ * @throws Error if the login to Wroom fails.
43
+ */
44
+ private login;
45
+ }
46
+ //#endregion
47
+ export { WroomClient };
48
+ //# sourceMappingURL=wroom.d.cts.map