@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
@@ -1,173 +1,163 @@
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;
7
- };
8
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
9
- const assetApi = require("../clients/assetApi.cjs");
10
- const authenticationApi = require("../clients/authenticationApi.cjs");
11
- const coreApi = require("../clients/coreApi.cjs");
12
- const customTypesApi = require("../clients/customTypesApi.cjs");
13
- const integrationFields = require("../clients/integrationFields.cjs");
14
- const manageV2 = require("../clients/manageV2.cjs");
15
- const migrationApi = require("../clients/migrationApi.cjs");
16
- const wroom = require("../clients/wroom.cjs");
17
- const envVariableManager = require("../utils/envVariableManager.cjs");
18
- const log = require("../utils/log.cjs");
19
- const random = require("../utils/random.cjs");
20
- const urls = require("../utils/urls.cjs");
21
- const repository = require("./repository.cjs");
1
+ const require_log = require("../utils/log.cjs");
2
+ const require_urls = require("../utils/urls.cjs");
3
+ const require_assetApi = require("../clients/assetApi.cjs");
4
+ const require_authenticationApi = require("../clients/authenticationApi.cjs");
5
+ const require_coreApi = require("../clients/coreApi.cjs");
6
+ const require_customTypesApi = require("../clients/customTypesApi.cjs");
7
+ const require_integrationFields = require("../clients/integrationFields.cjs");
8
+ const require_manageV2 = require("../clients/manageV2.cjs");
9
+ const require_migrationApi = require("../clients/migrationApi.cjs");
10
+ const require_wroom = require("../clients/wroom.cjs");
11
+ const require_envVariableManager = require("../utils/envVariableManager.cjs");
12
+ const require_random = require("../utils/random.cjs");
13
+ const require_repository = require("./repository.cjs");
14
+ //#region src/managers/repositories.ts
15
+ /**
16
+ * Factory method to create a RepositoriesManager to manage repositories test data.
17
+ *
18
+ * @param configuration - Global object containing the different configurations required to setup
19
+ * the RepositoriesManager.
20
+ *
21
+ * - {@link configuration.urlConfig}: Configuration around the API's URLs management.
22
+ * - {@link configuration.authConfig}: Configuration around the authentication of a user.
23
+ * - {@link configuration.manageV2Config}: Optional Configuration used to make calls to ManageV2.
24
+ *
25
+ * @returns An instance of {@link RepositoriesManager} to manage test data.
26
+ */
22
27
  const createRepositoriesManager = (configuration) => {
23
- return new RepositoriesManager(configuration);
28
+ return new RepositoriesManager(configuration);
29
+ };
30
+ /** Utility object to manage Prismic test data */
31
+ var RepositoriesManager = class {
32
+ config;
33
+ wroomClient;
34
+ authClient;
35
+ manageV2Client;
36
+ /** Helper to keep track of repositories across independent test phases (setup, teardown) */
37
+ repositories = new require_envVariableManager.EnvVariableManager("_PRISMIC_E2E_TESTS_REPOS");
38
+ /**
39
+ * @param configuration - Global object containing the different configuration required to setup
40
+ * the different clients.
41
+ * @param credentials - Authentication credentials (email and password)
42
+ */
43
+ constructor(configuration) {
44
+ this.config = {
45
+ ...configuration,
46
+ cluster: configuration.cluster,
47
+ urlConfig: typeof configuration.urlConfig === "string" ? this.inferUrls(configuration.urlConfig) : configuration.urlConfig
48
+ };
49
+ this.wroomClient = new require_wroom.WroomClient(this.config.urlConfig.baseURL, this.config.authConfig, this.config.cluster);
50
+ this.authClient = new require_authenticationApi.AuthenticationApiClient(this.config.urlConfig.authenticationApi, this.config.authConfig);
51
+ this.manageV2Client = new require_manageV2.ManageV2Client(this.config.urlConfig.baseURL, this.config.manageV2Config);
52
+ this.config.urlConfig.customTypesApi = configuration.environment === "stage" && configuration.cluster === "unify-exp" ? `https://customtypes.wroom.io/${configuration.cluster}/` : this.config.urlConfig.customTypesApi;
53
+ }
54
+ /** If the baseURL is prismic.io, assume the other services have the format <name>.prismic.io */
55
+ inferUrls(baseURL) {
56
+ const url = new URL(baseURL);
57
+ const protocol = url.protocol.slice(0, -1);
58
+ return {
59
+ baseURL,
60
+ authenticationApi: `${protocol}://auth.${url.hostname}`,
61
+ customTypesApi: `${protocol}://customtypes.${url.hostname}`,
62
+ migrationApi: `${protocol}://migration.${url.hostname}`,
63
+ assetApi: `${protocol}://asset-api.${url.hostname}`,
64
+ integrationFieldApi: url.hostname === "prismic.io" ? `${protocol}://if-api.${url.hostname}` : `${protocol}://api.${url.hostname}`
65
+ };
66
+ }
67
+ /**
68
+ * Generate a user token from the authentication service.
69
+ *
70
+ * @returns A JWT token
71
+ */
72
+ async getUserApiToken() {
73
+ return this.authClient.getToken();
74
+ }
75
+ /**
76
+ * Create a new repository in Wroom.
77
+ *
78
+ * @param repositoryName - The name of the repository.
79
+ * @throws Error if the repository creation fails.
80
+ */
81
+ async createRepository(config = {}) {
82
+ const profiler = require_log.logger.startTimer();
83
+ const { prefix = "e2e-tests" } = config;
84
+ const repositoryName = `${prefix}-${require_random.randomString()}`;
85
+ const response = await this.wroomClient.post(null, "authentication/newrepository", {
86
+ domain: repositoryName,
87
+ framework: "next",
88
+ plan: "personal",
89
+ isAnnual: "false",
90
+ role: "developer"
91
+ });
92
+ if (response.status !== 200) {
93
+ require_log.logHttpResponse(response);
94
+ throw new Error(`Could not create repository ${repositoryName}`);
95
+ }
96
+ this.repositories.add(repositoryName);
97
+ const repository = this.getRepositoryManager(repositoryName);
98
+ const version = await repository.getDeployedVersion();
99
+ profiler.done({ message: `created repository '${repositoryName}', Wroom version is "${version}"` });
100
+ await repository.configure(config);
101
+ return repository;
102
+ }
103
+ /**
104
+ * Delete a repository from Wroom.
105
+ *
106
+ * @param repository - The name of the repository.
107
+ * @throws Error if the repository deletion fails.
108
+ */
109
+ async deleteRepository(repository) {
110
+ const profiler = require_log.logger.startTimer();
111
+ const post = async () => this.wroomClient.post(repository, "app/settings/delete", {
112
+ confirm: repository,
113
+ password: this.config.authConfig.password
114
+ });
115
+ const response = await post();
116
+ if (response.status !== 200) {
117
+ if ((await post()).status !== 404) {
118
+ require_log.logHttpResponse(response);
119
+ throw new Error(`Could not delete repository ${repository}`);
120
+ }
121
+ }
122
+ this.repositories.remove(repository);
123
+ profiler.done({ message: `deleted repository '${repository}'` });
124
+ }
125
+ /** Cleanup test data. For example, it deletes repositories created using createRepository() */
126
+ async tearDown() {
127
+ const repositories = this.repositories.getAll();
128
+ for (const repository of repositories) await this.deleteRepository(repository);
129
+ }
130
+ /**
131
+ * Return a repository utilities object for a repository.
132
+ *
133
+ * @param repository - The name of the repository.
134
+ */
135
+ getRepositoryManager(repository) {
136
+ const { urlConfig } = this.config;
137
+ const authToken = () => this.authClient.getToken();
138
+ const customTypeClient = new require_customTypesApi.CustomTypesApiClient(urlConfig.customTypesApi, {
139
+ authToken,
140
+ repository
141
+ });
142
+ const coreApiClient = new require_coreApi.CoreApiClient(require_urls.getRepositoryUrl(urlConfig.baseURL, repository), authToken);
143
+ const migrationApiClient = urlConfig.migrationApi ? new require_migrationApi.MigrationApiClient(urlConfig.migrationApi, {
144
+ authToken,
145
+ repository
146
+ }) : void 0;
147
+ const assetApiClient = new require_assetApi.AssetApiClient(urlConfig.assetApi, {
148
+ authToken,
149
+ repository
150
+ });
151
+ const integrationFieldsClient = urlConfig.integrationFieldApi ? new require_integrationFields.IntegrationFieldsClient(urlConfig.integrationFieldApi, {
152
+ customTypesApiClient: customTypeClient,
153
+ wroomClient: this.wroomClient,
154
+ repository
155
+ }) : void 0;
156
+ return new require_repository.RepositoryManager(repository, coreApiClient, this.authClient, this.wroomClient, customTypeClient, migrationApiClient, assetApiClient, this.manageV2Client, integrationFieldsClient);
157
+ }
24
158
  };
25
- class RepositoriesManager {
26
- /**
27
- * @param configuration - Global object containing the different configuration
28
- * required to setup the different clients.
29
- * @param credentials - Authentication credentials (email and password)
30
- */
31
- constructor(configuration) {
32
- __publicField(this, "config");
33
- __publicField(this, "wroomClient");
34
- __publicField(this, "authClient");
35
- __publicField(this, "manageV2Client");
36
- /**
37
- * helper to keep track of repositories across independent test phases (setup,
38
- * teardown)
39
- */
40
- __publicField(this, "repositories", new envVariableManager.EnvVariableManager("_PRISMIC_E2E_TESTS_REPOS"));
41
- this.config = {
42
- ...configuration,
43
- cluster: configuration.cluster,
44
- // When a string is provided, treat it as the 'base' property
45
- urlConfig: typeof configuration.urlConfig === "string" ? this.inferUrls(configuration.urlConfig) : configuration.urlConfig
46
- };
47
- this.wroomClient = new wroom.WroomClient(this.config.urlConfig.baseURL, this.config.authConfig, this.config.cluster);
48
- this.authClient = new authenticationApi.AuthenticationApiClient(this.config.urlConfig.authenticationApi, this.config.authConfig);
49
- this.manageV2Client = new manageV2.ManageV2Client(this.config.urlConfig.baseURL, this.config.manageV2Config);
50
- this.config.urlConfig.customTypesApi = configuration.environment === "stage" && configuration.cluster === "unify-exp" ? `https://customtypes.wroom.io/${configuration.cluster}/` : this.config.urlConfig.customTypesApi;
51
- }
52
- /**
53
- * If the baseURL is prismic.io, assume the other services have the format
54
- * <name>.prismic.io
55
- */
56
- inferUrls(baseURL) {
57
- const url = new URL(baseURL);
58
- const protocol = url.protocol.slice(0, -1);
59
- return {
60
- baseURL,
61
- authenticationApi: `${protocol}://auth.${url.hostname}`,
62
- customTypesApi: `${protocol}://customtypes.${url.hostname}`,
63
- migrationApi: `${protocol}://migration.${url.hostname}`,
64
- assetApi: `${protocol}://asset-api.${url.hostname}`,
65
- integrationFieldApi: url.hostname === "prismic.io" ? `${protocol}://if-api.${url.hostname}` : `${protocol}://api.${url.hostname}`
66
- };
67
- }
68
- /**
69
- * Generate a user token from the authentication service.
70
- *
71
- * @returns a JWT token
72
- */
73
- async getUserApiToken() {
74
- return this.authClient.getToken();
75
- }
76
- /**
77
- * Create a new repository in Wroom.
78
- *
79
- * @param repositoryName - The name of the repository.
80
- *
81
- * @throws Error if the repository creation fails.
82
- */
83
- async createRepository(config = {}) {
84
- const profiler = log.logger.startTimer();
85
- const { prefix = "e2e-tests" } = config;
86
- const repositoryName = `${prefix}-${random.randomString()}`;
87
- const response = await this.wroomClient.post(null, "authentication/newrepository", {
88
- domain: repositoryName,
89
- framework: "next",
90
- plan: "personal",
91
- isAnnual: "false",
92
- role: "developer"
93
- });
94
- if (response.status !== 200) {
95
- log.logHttpResponse(response);
96
- throw new Error(`Could not create repository ${repositoryName}`);
97
- }
98
- this.repositories.add(repositoryName);
99
- const repository2 = this.getRepositoryManager(repositoryName);
100
- const version = await repository2.getDeployedVersion();
101
- profiler.done({
102
- message: `created repository '${repositoryName}', Wroom version is "${version}"`
103
- });
104
- await repository2.configure(config);
105
- return repository2;
106
- }
107
- /**
108
- * Delete a repository from Wroom.
109
- *
110
- * @param repository - The name of the repository.
111
- *
112
- * @throws Error if the repository deletion fails.
113
- */
114
- async deleteRepository(repository2) {
115
- const profiler = log.logger.startTimer();
116
- const post = async () => this.wroomClient.post(repository2, "app/settings/delete", {
117
- confirm: repository2,
118
- password: this.config.authConfig.password
119
- });
120
- const response = await post();
121
- if (response.status !== 200) {
122
- const retry = await post();
123
- if (retry.status !== 404) {
124
- log.logHttpResponse(response);
125
- throw new Error(`Could not delete repository ${repository2}`);
126
- }
127
- }
128
- this.repositories.remove(repository2);
129
- profiler.done({ message: `deleted repository '${repository2}'` });
130
- }
131
- /**
132
- * Cleanup test data. For example, it deletes repositories created using
133
- * createRepository()
134
- */
135
- async tearDown() {
136
- const repositories = this.repositories.getAll();
137
- for (const repository2 of repositories) {
138
- await this.deleteRepository(repository2);
139
- }
140
- }
141
- /**
142
- * Return a repository utilities object for a repository.
143
- *
144
- * @param repository - The name of the repository.
145
- */
146
- getRepositoryManager(repository$1) {
147
- const { urlConfig } = this.config;
148
- const authToken = () => this.authClient.getToken();
149
- const customTypeClient = new customTypesApi.CustomTypesApiClient(urlConfig.customTypesApi, {
150
- authToken,
151
- repository: repository$1
152
- });
153
- const coreApiUrl = urls.getRepositoryUrl(urlConfig.baseURL, repository$1);
154
- const coreApiClient = new coreApi.CoreApiClient(coreApiUrl, authToken);
155
- const migrationApiClient = urlConfig.migrationApi ? new migrationApi.MigrationApiClient(urlConfig.migrationApi, {
156
- authToken,
157
- repository: repository$1
158
- }) : void 0;
159
- const assetApiClient = new assetApi.AssetApiClient(urlConfig.assetApi, {
160
- authToken,
161
- repository: repository$1
162
- });
163
- const integrationFieldsClient = urlConfig.integrationFieldApi ? new integrationFields.IntegrationFieldsClient(urlConfig.integrationFieldApi, {
164
- customTypesApiClient: customTypeClient,
165
- wroomClient: this.wroomClient,
166
- repository: repository$1
167
- }) : void 0;
168
- return new repository.RepositoryManager(repository$1, coreApiClient, this.authClient, this.wroomClient, customTypeClient, migrationApiClient, assetApiClient, this.manageV2Client, integrationFieldsClient);
169
- }
170
- }
159
+ //#endregion
171
160
  exports.RepositoriesManager = RepositoriesManager;
172
161
  exports.createRepositoriesManager = createRepositoriesManager;
173
- //# sourceMappingURL=repositories.cjs.map
162
+
163
+ //# sourceMappingURL=repositories.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"repositories.cjs","sources":["../../../src/managers/repositories.ts"],"sourcesContent":["import { SetupConfiguration, UrlConfig } from \"../types\";\n\nimport { AssetApiClient } from \"../clients/assetApi\";\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\";\nimport { CoreApiClient } from \"../clients/coreApi\";\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\";\nimport { IntegrationFieldsClient } from \"../clients/integrationFields\";\nimport { ManageV2Client } from \"../clients/manageV2\";\nimport { MigrationApiClient } from \"../clients/migrationApi\";\nimport { WroomClient } from \"../clients/wroom\";\nimport { EnvVariableManager } from \"../utils/envVariableManager\";\nimport { logHttpResponse, logger } from \"../utils/log\";\nimport { randomString } from \"../utils/random\";\nimport { getRepositoryUrl } from \"../utils/urls\";\n\nimport { RepositoryConfig, RepositoryManager } from \"./repository\";\n\n/**\n * Factory method to create a RepositoriesManager to manage repositories test\n * data.\n *\n * @param configuration - Global object containing the different configurations\n * required to setup the RepositoriesManager.\n *\n * - {@link configuration.urlConfig}: Configuration around the API's URLs management.\n * - {@link configuration.authConfig}: Configuration around the authentication of a user.\n * - {@link configuration.manageV2Config}: Optional Configuration used to make calls to ManageV2.\n *\n * @returns An instance of {@link RepositoriesManager} to manage test data.\n */\nexport const createRepositoriesManager = (\n\tconfiguration: SetupConfiguration,\n): RepositoriesManager => {\n\treturn new RepositoriesManager(configuration);\n};\n\n/** Utility object to manage Prismic test data */\nexport class RepositoriesManager {\n\tprivate readonly config: Omit<SetupConfiguration, \"urlConfig\"> & {\n\t\turlConfig: UrlConfig;\n\t};\n\tprivate readonly wroomClient: WroomClient;\n\tprivate readonly authClient: AuthenticationApiClient;\n\tprivate readonly manageV2Client: ManageV2Client;\n\t/**\n\t * helper to keep track of repositories across independent test phases (setup,\n\t * teardown)\n\t */\n\tprivate readonly repositories = new EnvVariableManager(\n\t\t\"_PRISMIC_E2E_TESTS_REPOS\",\n\t);\n\n\t/**\n\t * @param configuration - Global object containing the different configuration\n\t * required to setup the different clients.\n\t * @param credentials - Authentication credentials (email and password)\n\t */\n\tconstructor(configuration: SetupConfiguration) {\n\t\tthis.config = {\n\t\t\t...configuration,\n\t\t\tcluster: configuration.cluster,\n\t\t\t// When a string is provided, treat it as the 'base' property\n\t\t\turlConfig:\n\t\t\t\ttypeof configuration.urlConfig === \"string\"\n\t\t\t\t\t? this.inferUrls(configuration.urlConfig)\n\t\t\t\t\t: configuration.urlConfig,\n\t\t};\n\n\t\tthis.wroomClient = new WroomClient(\n\t\t\tthis.config.urlConfig.baseURL,\n\t\t\tthis.config.authConfig,\n\t\t\tthis.config.cluster,\n\t\t);\n\t\tthis.authClient = new AuthenticationApiClient(\n\t\t\tthis.config.urlConfig.authenticationApi,\n\t\t\tthis.config.authConfig,\n\t\t);\n\t\tthis.manageV2Client = new ManageV2Client(\n\t\t\tthis.config.urlConfig.baseURL,\n\t\t\tthis.config.manageV2Config,\n\t\t);\n\n\t\t// This logic specific to staging environment allow us to target a specific version of the custom types API.\n\t\t// This is only works for unify-exp at the moment.\n\t\t// Having this logic here avoids duplicating it across different CI workflows.\n\t\tthis.config.urlConfig.customTypesApi =\n\t\t\tconfiguration.environment === \"stage\" &&\n\t\t\tconfiguration.cluster === \"unify-exp\"\n\t\t\t\t? `https://customtypes.wroom.io/${configuration.cluster}/`\n\t\t\t\t: this.config.urlConfig.customTypesApi;\n\t}\n\n\t/**\n\t * If the baseURL is prismic.io, assume the other services have the format\n\t * <name>.prismic.io\n\t */\n\tprivate inferUrls(baseURL: string): UrlConfig {\n\t\tconst url = new URL(baseURL);\n\t\tconst protocol = url.protocol.slice(0, -1); // Remove the trailing colon from the protocol\n\n\t\treturn {\n\t\t\tbaseURL: baseURL,\n\t\t\tauthenticationApi: `${protocol}://auth.${url.hostname}`,\n\t\t\tcustomTypesApi: `${protocol}://customtypes.${url.hostname}`,\n\t\t\tmigrationApi: `${protocol}://migration.${url.hostname}`,\n\t\t\tassetApi: `${protocol}://asset-api.${url.hostname}`,\n\t\t\tintegrationFieldApi:\n\t\t\t\turl.hostname === \"prismic.io\"\n\t\t\t\t\t? `${protocol}://if-api.${url.hostname}`\n\t\t\t\t\t: `${protocol}://api.${url.hostname}`,\n\t\t};\n\t}\n\n\t/**\n\t * Generate a user token from the authentication service.\n\t *\n\t * @returns a JWT token\n\t */\n\tasync getUserApiToken(): Promise<string> {\n\t\treturn this.authClient.getToken();\n\t}\n\n\t/**\n\t * Create a new repository in Wroom.\n\t *\n\t * @param repositoryName - The name of the repository.\n\t *\n\t * @throws Error if the repository creation fails.\n\t */\n\tasync createRepository(\n\t\tconfig: {\n\t\t\tprefix?: string;\n\t\t} & RepositoryConfig = {},\n\t): Promise<RepositoryManager> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst { prefix = \"e2e-tests\" } = config;\n\t\tconst repositoryName = `${prefix}-${randomString()}`;\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tnull,\n\t\t\t\"authentication/newrepository\",\n\t\t\t{\n\t\t\t\tdomain: repositoryName,\n\t\t\t\tframework: \"next\",\n\t\t\t\tplan: \"personal\",\n\t\t\t\tisAnnual: \"false\",\n\t\t\t\trole: \"developer\",\n\t\t\t},\n\t\t);\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not create repository ${repositoryName}`);\n\t\t}\n\t\tthis.repositories.add(repositoryName);\n\n\t\tconst repository = this.getRepositoryManager(repositoryName);\n\t\tconst version = await repository.getDeployedVersion();\n\n\t\tprofiler.done({\n\t\t\tmessage: `created repository '${repositoryName}', Wroom version is \"${version}\"`,\n\t\t});\n\t\tawait repository.configure(config);\n\n\t\treturn repository;\n\t}\n\n\t/**\n\t * Delete a repository from Wroom.\n\t *\n\t * @param repository - The name of the repository.\n\t *\n\t * @throws Error if the repository deletion fails.\n\t */\n\tasync deleteRepository(repository: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst post = async () =>\n\t\t\tthis.wroomClient.post(repository, \"app/settings/delete\", {\n\t\t\t\tconfirm: repository,\n\t\t\t\tpassword: this.config.authConfig.password,\n\t\t\t});\n\t\tconst response = await post();\n\t\tif (response.status !== 200) {\n\t\t\t// sometimes the deletion returns 500 but actually succeeds\n\t\t\t// we run the query again and check the repo is actually deleted (404)\n\t\t\tconst retry = await post();\n\t\t\tif (retry.status !== 404) {\n\t\t\t\tlogHttpResponse(response);\n\t\t\t\tthrow new Error(`Could not delete repository ${repository}`);\n\t\t\t}\n\t\t}\n\t\tthis.repositories.remove(repository);\n\t\tprofiler.done({ message: `deleted repository '${repository}'` });\n\t}\n\n\t/**\n\t * Cleanup test data. For example, it deletes repositories created using\n\t * createRepository()\n\t */\n\tasync tearDown(): Promise<void> {\n\t\tconst repositories = this.repositories.getAll();\n\t\tfor (const repository of repositories) {\n\t\t\tawait this.deleteRepository(repository);\n\t\t}\n\t}\n\n\t/**\n\t * Return a repository utilities object for a repository.\n\t *\n\t * @param repository - The name of the repository.\n\t */\n\tgetRepositoryManager(repository: string): RepositoryManager {\n\t\tconst { urlConfig } = this.config;\n\t\tconst authToken = () => this.authClient.getToken();\n\t\tconst customTypeClient = new CustomTypesApiClient(\n\t\t\turlConfig.customTypesApi,\n\t\t\t{\n\t\t\t\tauthToken,\n\t\t\t\trepository,\n\t\t\t},\n\t\t);\n\t\tconst coreApiUrl = getRepositoryUrl(urlConfig.baseURL, repository);\n\t\tconst coreApiClient = new CoreApiClient(coreApiUrl, authToken);\n\t\tconst migrationApiClient = urlConfig.migrationApi\n\t\t\t? new MigrationApiClient(urlConfig.migrationApi, {\n\t\t\t\t\tauthToken,\n\t\t\t\t\trepository,\n\t\t\t\t})\n\t\t\t: undefined;\n\t\tconst assetApiClient = new AssetApiClient(urlConfig.assetApi, {\n\t\t\tauthToken,\n\t\t\trepository,\n\t\t});\n\t\tconst integrationFieldsClient = urlConfig.integrationFieldApi\n\t\t\t? new IntegrationFieldsClient(urlConfig.integrationFieldApi, {\n\t\t\t\t\tcustomTypesApiClient: customTypeClient,\n\t\t\t\t\twroomClient: this.wroomClient,\n\t\t\t\t\trepository,\n\t\t\t\t})\n\t\t\t: undefined;\n\n\t\treturn new RepositoryManager(\n\t\t\trepository,\n\t\t\tcoreApiClient,\n\t\t\tthis.authClient,\n\t\t\tthis.wroomClient,\n\t\t\tcustomTypeClient,\n\t\t\tmigrationApiClient,\n\t\t\tassetApiClient,\n\t\t\tthis.manageV2Client,\n\t\t\tintegrationFieldsClient,\n\t\t);\n\t}\n}\n"],"names":["EnvVariableManager","WroomClient","AuthenticationApiClient","ManageV2Client","logger","randomString","logHttpResponse","repository","CustomTypesApiClient","getRepositoryUrl","CoreApiClient","MigrationApiClient","AssetApiClient","IntegrationFieldsClient","RepositoryManager"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8Ba,MAAA,4BAA4B,CACxC,kBACwB;AACjB,SAAA,IAAI,oBAAoB,aAAa;AAC7C;MAGa,oBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoB/B,YAAY,eAAiC;AAnB5B;AAGA;AACA;AACA;AAKA;AAAA;AAAA;AAAA;AAAA,wCAAe,IAAIA,sCACnC,0BAA0B;AAS1B,SAAK,SAAS;AAAA,MACb,GAAG;AAAA,MACH,SAAS,cAAc;AAAA;AAAA,MAEvB,WACC,OAAO,cAAc,cAAc,WAChC,KAAK,UAAU,cAAc,SAAS,IACtC,cAAc;AAAA,IAAA;AAGnB,SAAK,cAAc,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C3B,UAAM,YAAY,MAAM,KAAK,WAAW,SAAQ;AAChD,UAAM,mBAAmB,IAAIC,oCAC5B,UAAU,gBACV;AAAA,MACC;AAAA,MAAA,YACAD;AAAAA,IAAA,CACA;AAEF,UAAM,aAAaE,KAAA,iBAAiB,UAAU,SAASF,YAAU;AACjE,UAAM,gBAAgB,IAAIG,QAAAA,cAAc,YAAY,SAAS;AAC7D,UAAM,qBAAqB,UAAU,eAClC,IAAIC,aAAA,mBAAmB,UAAU,cAAc;AAAA,MAC/C;AAAA,MAAA,YACAJ;AAAAA,IAAA,CACA,IACA;AACH,UAAM,iBAAiB,IAAIK,wBAAe,UAAU,UAAU;AAAA,MAC7D;AAAA,MAAA,YACAL;AAAAA,IAAA,CACA;AACD,UAAM,0BAA0B,UAAU,sBACvC,IAAIM,kBAAA,wBAAwB,UAAU,qBAAqB;AAAA,MAC3D,sBAAsB;AAAA,MACtB,aAAa,KAAK;AAAA,MAAA,YAClBN;AAAAA,IAAA,CACA,IACA;AAEH,WAAO,IAAIO,WAAA,kBACVP,cACA,eACA,KAAK,YACL,KAAK,aACL,kBACA,oBACA,gBACA,KAAK,gBACL,uBAAuB;AAAA,EAEzB;AACA;;;"}
1
+ {"version":3,"file":"repositories.cjs","names":["EnvVariableManager","WroomClient","AuthenticationApiClient","ManageV2Client","logger","randomString","CustomTypesApiClient","CoreApiClient","getRepositoryUrl","MigrationApiClient","AssetApiClient","IntegrationFieldsClient","RepositoryManager"],"sources":["../../src/managers/repositories.ts"],"sourcesContent":["import { AssetApiClient } from \"../clients/assetApi\"\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\"\nimport { CoreApiClient } from \"../clients/coreApi\"\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\"\nimport { IntegrationFieldsClient } from \"../clients/integrationFields\"\nimport { ManageV2Client } from \"../clients/manageV2\"\nimport { MigrationApiClient } from \"../clients/migrationApi\"\nimport { WroomClient } from \"../clients/wroom\"\nimport type { SetupConfiguration, UrlConfig } from \"../types\"\nimport { EnvVariableManager } from \"../utils/envVariableManager\"\nimport { logHttpResponse, logger } from \"../utils/log\"\nimport { randomString } from \"../utils/random\"\nimport { getRepositoryUrl } from \"../utils/urls\"\nimport type { RepositoryConfig } from \"./repository\"\nimport { RepositoryManager } from \"./repository\"\n\n/**\n * Factory method to create a RepositoriesManager to manage repositories test data.\n *\n * @param configuration - Global object containing the different configurations required to setup\n * the RepositoriesManager.\n *\n * - {@link configuration.urlConfig}: Configuration around the API's URLs management.\n * - {@link configuration.authConfig}: Configuration around the authentication of a user.\n * - {@link configuration.manageV2Config}: Optional Configuration used to make calls to ManageV2.\n *\n * @returns An instance of {@link RepositoriesManager} to manage test data.\n */\nexport const createRepositoriesManager = (\n\tconfiguration: SetupConfiguration,\n): RepositoriesManager => {\n\treturn new RepositoriesManager(configuration)\n}\n\n/** Utility object to manage Prismic test data */\nexport class RepositoriesManager {\n\tprivate readonly config: Omit<SetupConfiguration, \"urlConfig\"> & {\n\t\turlConfig: UrlConfig\n\t}\n\tprivate readonly wroomClient: WroomClient\n\tprivate readonly authClient: AuthenticationApiClient\n\tprivate readonly manageV2Client: ManageV2Client\n\t/** Helper to keep track of repositories across independent test phases (setup, teardown) */\n\tprivate readonly repositories = new EnvVariableManager(\"_PRISMIC_E2E_TESTS_REPOS\")\n\n\t/**\n\t * @param configuration - Global object containing the different configuration required to setup\n\t * the different clients.\n\t * @param credentials - Authentication credentials (email and password)\n\t */\n\tconstructor(configuration: SetupConfiguration) {\n\t\tthis.config = {\n\t\t\t...configuration,\n\t\t\tcluster: configuration.cluster,\n\t\t\t// When a string is provided, treat it as the 'base' property\n\t\t\turlConfig:\n\t\t\t\ttypeof configuration.urlConfig === \"string\"\n\t\t\t\t\t? this.inferUrls(configuration.urlConfig)\n\t\t\t\t\t: configuration.urlConfig,\n\t\t}\n\n\t\tthis.wroomClient = new WroomClient(\n\t\t\tthis.config.urlConfig.baseURL,\n\t\t\tthis.config.authConfig,\n\t\t\tthis.config.cluster,\n\t\t)\n\t\tthis.authClient = new AuthenticationApiClient(\n\t\t\tthis.config.urlConfig.authenticationApi,\n\t\t\tthis.config.authConfig,\n\t\t)\n\t\tthis.manageV2Client = new ManageV2Client(\n\t\t\tthis.config.urlConfig.baseURL,\n\t\t\tthis.config.manageV2Config,\n\t\t)\n\n\t\t// This logic specific to staging environment allow us to target a specific version of the custom types API.\n\t\t// This is only works for unify-exp at the moment.\n\t\t// Having this logic here avoids duplicating it across different CI workflows.\n\t\tthis.config.urlConfig.customTypesApi =\n\t\t\tconfiguration.environment === \"stage\" && configuration.cluster === \"unify-exp\"\n\t\t\t\t? `https://customtypes.wroom.io/${configuration.cluster}/`\n\t\t\t\t: this.config.urlConfig.customTypesApi\n\t}\n\n\t/** If the baseURL is prismic.io, assume the other services have the format <name>.prismic.io */\n\tprivate inferUrls(baseURL: string): UrlConfig {\n\t\tconst url = new URL(baseURL)\n\t\tconst protocol = url.protocol.slice(0, -1) // Remove the trailing colon from the protocol\n\n\t\treturn {\n\t\t\tbaseURL: baseURL,\n\t\t\tauthenticationApi: `${protocol}://auth.${url.hostname}`,\n\t\t\tcustomTypesApi: `${protocol}://customtypes.${url.hostname}`,\n\t\t\tmigrationApi: `${protocol}://migration.${url.hostname}`,\n\t\t\tassetApi: `${protocol}://asset-api.${url.hostname}`,\n\t\t\tintegrationFieldApi:\n\t\t\t\turl.hostname === \"prismic.io\"\n\t\t\t\t\t? `${protocol}://if-api.${url.hostname}`\n\t\t\t\t\t: `${protocol}://api.${url.hostname}`,\n\t\t}\n\t}\n\n\t/**\n\t * Generate a user token from the authentication service.\n\t *\n\t * @returns A JWT token\n\t */\n\tasync getUserApiToken(): Promise<string> {\n\t\treturn this.authClient.getToken()\n\t}\n\n\t/**\n\t * Create a new repository in Wroom.\n\t *\n\t * @param repositoryName - The name of the repository.\n\t * @throws Error if the repository creation fails.\n\t */\n\tasync createRepository(\n\t\tconfig: {\n\t\t\tprefix?: string\n\t\t} & RepositoryConfig = {},\n\t): Promise<RepositoryManager> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst { prefix = \"e2e-tests\" } = config\n\t\tconst repositoryName = `${prefix}-${randomString()}`\n\n\t\tconst response = await this.wroomClient.post(null, \"authentication/newrepository\", {\n\t\t\tdomain: repositoryName,\n\t\t\tframework: \"next\",\n\t\t\tplan: \"personal\",\n\t\t\tisAnnual: \"false\",\n\t\t\trole: \"developer\",\n\t\t})\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response)\n\t\t\tthrow new Error(`Could not create repository ${repositoryName}`)\n\t\t}\n\t\tthis.repositories.add(repositoryName)\n\n\t\tconst repository = this.getRepositoryManager(repositoryName)\n\t\tconst version = await repository.getDeployedVersion()\n\n\t\tprofiler.done({\n\t\t\tmessage: `created repository '${repositoryName}', Wroom version is \"${version}\"`,\n\t\t})\n\t\tawait repository.configure(config)\n\n\t\treturn repository\n\t}\n\n\t/**\n\t * Delete a repository from Wroom.\n\t *\n\t * @param repository - The name of the repository.\n\t * @throws Error if the repository deletion fails.\n\t */\n\tasync deleteRepository(repository: string): Promise<void> {\n\t\tconst profiler = logger.startTimer()\n\n\t\tconst post = async () =>\n\t\t\tthis.wroomClient.post(repository, \"app/settings/delete\", {\n\t\t\t\tconfirm: repository,\n\t\t\t\tpassword: this.config.authConfig.password,\n\t\t\t})\n\t\tconst response = await post()\n\t\tif (response.status !== 200) {\n\t\t\t// sometimes the deletion returns 500 but actually succeeds\n\t\t\t// we run the query again and check the repo is actually deleted (404)\n\t\t\tconst retry = await post()\n\t\t\tif (retry.status !== 404) {\n\t\t\t\tlogHttpResponse(response)\n\t\t\t\tthrow new Error(`Could not delete repository ${repository}`)\n\t\t\t}\n\t\t}\n\t\tthis.repositories.remove(repository)\n\t\tprofiler.done({ message: `deleted repository '${repository}'` })\n\t}\n\n\t/** Cleanup test data. For example, it deletes repositories created using createRepository() */\n\tasync tearDown(): Promise<void> {\n\t\tconst repositories = this.repositories.getAll()\n\t\tfor (const repository of repositories) {\n\t\t\tawait this.deleteRepository(repository)\n\t\t}\n\t}\n\n\t/**\n\t * Return a repository utilities object for a repository.\n\t *\n\t * @param repository - The name of the repository.\n\t */\n\tgetRepositoryManager(repository: string): RepositoryManager {\n\t\tconst { urlConfig } = this.config\n\t\tconst authToken = () => this.authClient.getToken()\n\t\tconst customTypeClient = new CustomTypesApiClient(urlConfig.customTypesApi, {\n\t\t\tauthToken,\n\t\t\trepository,\n\t\t})\n\t\tconst coreApiUrl = getRepositoryUrl(urlConfig.baseURL, repository)\n\t\tconst coreApiClient = new CoreApiClient(coreApiUrl, authToken)\n\t\tconst migrationApiClient = urlConfig.migrationApi\n\t\t\t? new MigrationApiClient(urlConfig.migrationApi, {\n\t\t\t\t\tauthToken,\n\t\t\t\t\trepository,\n\t\t\t\t})\n\t\t\t: undefined\n\t\tconst assetApiClient = new AssetApiClient(urlConfig.assetApi, {\n\t\t\tauthToken,\n\t\t\trepository,\n\t\t})\n\t\tconst integrationFieldsClient = urlConfig.integrationFieldApi\n\t\t\t? new IntegrationFieldsClient(urlConfig.integrationFieldApi, {\n\t\t\t\t\tcustomTypesApiClient: customTypeClient,\n\t\t\t\t\twroomClient: this.wroomClient,\n\t\t\t\t\trepository,\n\t\t\t\t})\n\t\t\t: undefined\n\n\t\treturn new RepositoryManager(\n\t\t\trepository,\n\t\t\tcoreApiClient,\n\t\t\tthis.authClient,\n\t\t\tthis.wroomClient,\n\t\t\tcustomTypeClient,\n\t\t\tmigrationApiClient,\n\t\t\tassetApiClient,\n\t\t\tthis.manageV2Client,\n\t\t\tintegrationFieldsClient,\n\t\t)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,6BACZ,kBACyB;CACzB,OAAO,IAAI,oBAAoB,aAAa;AAC7C;;AAGA,IAAa,sBAAb,MAAiC;CAChC;CAGA;CACA;CACA;;CAEA,eAAgC,IAAIA,2BAAAA,mBAAmB,0BAA0B;;;;;;CAOjF,YAAY,eAAmC;EAC9C,KAAK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;GAC/C;GACA;EACD,CAAC,IACA,KAAA;EACH,MAAM,iBAAiB,IAAIC,iBAAAA,eAAe,UAAU,UAAU;GAC7D;GACA;EACD,CAAC;EACD,MAAM,0BAA0B,UAAU,sBACvC,IAAIC,0BAAAA,wBAAwB,UAAU,qBAAqB;GAC3D,sBAAsB;GACtB,aAAa,KAAK;GAClB;EACD,CAAC,IACA,KAAA;EAEH,OAAO,IAAIC,mBAAAA,kBACV,YACA,eACA,KAAK,YACL,KAAK,aACL,kBACA,oBACA,gBACA,KAAK,gBACL,uBACD;CACD;AACD"}
@@ -0,0 +1,67 @@
1
+ import { SetupConfiguration } from "../types.cjs";
2
+ import { RepositoryConfig, RepositoryManager } from "./repository.cjs";
3
+
4
+ //#region src/managers/repositories.d.ts
5
+ /**
6
+ * Factory method to create a RepositoriesManager to manage repositories test data.
7
+ *
8
+ * @param configuration - Global object containing the different configurations required to setup
9
+ * the RepositoriesManager.
10
+ *
11
+ * - {@link configuration.urlConfig}: Configuration around the API's URLs management.
12
+ * - {@link configuration.authConfig}: Configuration around the authentication of a user.
13
+ * - {@link configuration.manageV2Config}: Optional Configuration used to make calls to ManageV2.
14
+ *
15
+ * @returns An instance of {@link RepositoriesManager} to manage test data.
16
+ */
17
+ declare const createRepositoriesManager: (configuration: SetupConfiguration) => RepositoriesManager;
18
+ /** Utility object to manage Prismic test data */
19
+ declare class RepositoriesManager {
20
+ private readonly config;
21
+ private readonly wroomClient;
22
+ private readonly authClient;
23
+ private readonly manageV2Client;
24
+ /** Helper to keep track of repositories across independent test phases (setup, teardown) */
25
+ private readonly repositories;
26
+ /**
27
+ * @param configuration - Global object containing the different configuration required to setup
28
+ * the different clients.
29
+ * @param credentials - Authentication credentials (email and password)
30
+ */
31
+ constructor(configuration: SetupConfiguration);
32
+ /** If the baseURL is prismic.io, assume the other services have the format <name>.prismic.io */
33
+ private inferUrls;
34
+ /**
35
+ * Generate a user token from the authentication service.
36
+ *
37
+ * @returns A JWT token
38
+ */
39
+ getUserApiToken(): Promise<string>;
40
+ /**
41
+ * Create a new repository in Wroom.
42
+ *
43
+ * @param repositoryName - The name of the repository.
44
+ * @throws Error if the repository creation fails.
45
+ */
46
+ createRepository(config?: {
47
+ prefix?: string;
48
+ } & RepositoryConfig): Promise<RepositoryManager>;
49
+ /**
50
+ * Delete a repository from Wroom.
51
+ *
52
+ * @param repository - The name of the repository.
53
+ * @throws Error if the repository deletion fails.
54
+ */
55
+ deleteRepository(repository: string): Promise<void>;
56
+ /** Cleanup test data. For example, it deletes repositories created using createRepository() */
57
+ tearDown(): Promise<void>;
58
+ /**
59
+ * Return a repository utilities object for a repository.
60
+ *
61
+ * @param repository - The name of the repository.
62
+ */
63
+ getRepositoryManager(repository: string): RepositoryManager;
64
+ }
65
+ //#endregion
66
+ export { RepositoriesManager, createRepositoriesManager };
67
+ //# sourceMappingURL=repositories.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repositories.d.cts","names":[],"sources":["../../src/managers/repositories.ts"],"mappings":";;;;;AA4BA;;;;;;;;AAIC;AAGD;;cAPa,yBAAA,GACZ,aAAA,EAAe,kBAAA,KACb,mBAEF;;cAGY,mBAAA;EAAA,iBACK,MAAA;EAAA,iBAGA,WAAA;EAAA,iBACA,UAAA;EAAA,iBACA,cAAA;EA2IC;EAAA,iBAzID,YAAA;EAqJ0C;;;;;cA9I/C,aAAA,EAAe,kBAAA;EAPV;EAAA,QA0CT,SAAA;EAnCmB;;;;;EAyDrB,eAAA,IAAmB,OAAA;EAYvB;;;;;;EAFI,gBAAA,CACL,MAAA;IACC,MAAA;EAAA,IACG,gBAAA,GACF,OAAA,CAAQ,iBAAA;EA2DO;;;;;AAYyC;EAnCrD,gBAAA,CAAiB,UAAA,WAAqB,OAAA;;EAuBtC,QAAA,IAAY,OAAA;;;;;;EAYlB,oBAAA,CAAqB,UAAA,WAAqB,iBAAA;AAAA"}
@@ -1,11 +1,12 @@
1
- import { SetupConfiguration } from "../types";
2
- import { RepositoryConfig, RepositoryManager } from "./repository";
1
+ import { SetupConfiguration } from "../types.js";
2
+ import { RepositoryConfig, RepositoryManager } from "./repository.js";
3
+
4
+ //#region src/managers/repositories.d.ts
3
5
  /**
4
- * Factory method to create a RepositoriesManager to manage repositories test
5
- * data.
6
+ * Factory method to create a RepositoriesManager to manage repositories test data.
6
7
  *
7
- * @param configuration - Global object containing the different configurations
8
- * required to setup the RepositoriesManager.
8
+ * @param configuration - Global object containing the different configurations required to setup
9
+ * the RepositoriesManager.
9
10
  *
10
11
  * - {@link configuration.urlConfig}: Configuration around the API's URLs management.
11
12
  * - {@link configuration.authConfig}: Configuration around the authentication of a user.
@@ -13,62 +14,54 @@ import { RepositoryConfig, RepositoryManager } from "./repository";
13
14
  *
14
15
  * @returns An instance of {@link RepositoriesManager} to manage test data.
15
16
  */
16
- export declare const createRepositoriesManager: (configuration: SetupConfiguration) => RepositoriesManager;
17
+ declare const createRepositoriesManager: (configuration: SetupConfiguration) => RepositoriesManager;
17
18
  /** Utility object to manage Prismic test data */
18
- export declare class RepositoriesManager {
19
- private readonly config;
20
- private readonly wroomClient;
21
- private readonly authClient;
22
- private readonly manageV2Client;
23
- /**
24
- * helper to keep track of repositories across independent test phases (setup,
25
- * teardown)
26
- */
27
- private readonly repositories;
28
- /**
29
- * @param configuration - Global object containing the different configuration
30
- * required to setup the different clients.
31
- * @param credentials - Authentication credentials (email and password)
32
- */
33
- constructor(configuration: SetupConfiguration);
34
- /**
35
- * If the baseURL is prismic.io, assume the other services have the format
36
- * <name>.prismic.io
37
- */
38
- private inferUrls;
39
- /**
40
- * Generate a user token from the authentication service.
41
- *
42
- * @returns a JWT token
43
- */
44
- getUserApiToken(): Promise<string>;
45
- /**
46
- * Create a new repository in Wroom.
47
- *
48
- * @param repositoryName - The name of the repository.
49
- *
50
- * @throws Error if the repository creation fails.
51
- */
52
- createRepository(config?: {
53
- prefix?: string;
54
- } & RepositoryConfig): Promise<RepositoryManager>;
55
- /**
56
- * Delete a repository from Wroom.
57
- *
58
- * @param repository - The name of the repository.
59
- *
60
- * @throws Error if the repository deletion fails.
61
- */
62
- deleteRepository(repository: string): Promise<void>;
63
- /**
64
- * Cleanup test data. For example, it deletes repositories created using
65
- * createRepository()
66
- */
67
- tearDown(): Promise<void>;
68
- /**
69
- * Return a repository utilities object for a repository.
70
- *
71
- * @param repository - The name of the repository.
72
- */
73
- getRepositoryManager(repository: string): RepositoryManager;
19
+ declare class RepositoriesManager {
20
+ private readonly config;
21
+ private readonly wroomClient;
22
+ private readonly authClient;
23
+ private readonly manageV2Client;
24
+ /** Helper to keep track of repositories across independent test phases (setup, teardown) */
25
+ private readonly repositories;
26
+ /**
27
+ * @param configuration - Global object containing the different configuration required to setup
28
+ * the different clients.
29
+ * @param credentials - Authentication credentials (email and password)
30
+ */
31
+ constructor(configuration: SetupConfiguration);
32
+ /** If the baseURL is prismic.io, assume the other services have the format <name>.prismic.io */
33
+ private inferUrls;
34
+ /**
35
+ * Generate a user token from the authentication service.
36
+ *
37
+ * @returns A JWT token
38
+ */
39
+ getUserApiToken(): Promise<string>;
40
+ /**
41
+ * Create a new repository in Wroom.
42
+ *
43
+ * @param repositoryName - The name of the repository.
44
+ * @throws Error if the repository creation fails.
45
+ */
46
+ createRepository(config?: {
47
+ prefix?: string;
48
+ } & RepositoryConfig): Promise<RepositoryManager>;
49
+ /**
50
+ * Delete a repository from Wroom.
51
+ *
52
+ * @param repository - The name of the repository.
53
+ * @throws Error if the repository deletion fails.
54
+ */
55
+ deleteRepository(repository: string): Promise<void>;
56
+ /** Cleanup test data. For example, it deletes repositories created using createRepository() */
57
+ tearDown(): Promise<void>;
58
+ /**
59
+ * Return a repository utilities object for a repository.
60
+ *
61
+ * @param repository - The name of the repository.
62
+ */
63
+ getRepositoryManager(repository: string): RepositoryManager;
74
64
  }
65
+ //#endregion
66
+ export { RepositoriesManager, createRepositoriesManager };
67
+ //# sourceMappingURL=repositories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repositories.d.ts","names":[],"sources":["../../src/managers/repositories.ts"],"mappings":";;;;;AA4BA;;;;;;;;AAIC;AAGD;;cAPa,yBAAA,GACZ,aAAA,EAAe,kBAAA,KACb,mBAEF;;cAGY,mBAAA;EAAA,iBACK,MAAA;EAAA,iBAGA,WAAA;EAAA,iBACA,UAAA;EAAA,iBACA,cAAA;EA2IC;EAAA,iBAzID,YAAA;EAqJ0C;;;;;cA9I/C,aAAA,EAAe,kBAAA;EAPV;EAAA,QA0CT,SAAA;EAnCmB;;;;;EAyDrB,eAAA,IAAmB,OAAA;EAYvB;;;;;;EAFI,gBAAA,CACL,MAAA;IACC,MAAA;EAAA,IACG,gBAAA,GACF,OAAA,CAAQ,iBAAA;EA2DO;;;;;AAYyC;EAnCrD,gBAAA,CAAiB,UAAA,WAAqB,OAAA;;EAuBtC,QAAA,IAAY,OAAA;;;;;;EAYlB,oBAAA,CAAqB,UAAA,WAAqB,iBAAA;AAAA"}