@prismicio/e2e-tests-utils 1.18.0 → 1.19.0-canary.d349d21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -27
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/clients/apiClient.cjs +38 -38
- package/dist/clients/apiClient.cjs.map +1 -1
- package/dist/clients/apiClient.d.cts +30 -0
- package/dist/clients/apiClient.d.cts.map +1 -0
- package/dist/clients/apiClient.d.ts +23 -23
- package/dist/clients/apiClient.d.ts.map +1 -0
- package/dist/clients/apiClient.js +38 -38
- package/dist/clients/apiClient.js.map +1 -1
- package/dist/clients/assetApi.cjs +81 -93
- package/dist/clients/assetApi.cjs.map +1 -1
- package/dist/clients/assetApi.d.cts +105 -0
- package/dist/clients/assetApi.d.cts.map +1 -0
- package/dist/clients/assetApi.d.ts +96 -97
- package/dist/clients/assetApi.d.ts.map +1 -0
- package/dist/clients/assetApi.js +79 -91
- package/dist/clients/assetApi.js.map +1 -1
- package/dist/clients/authenticationApi.cjs +66 -73
- package/dist/clients/authenticationApi.cjs.map +1 -1
- package/dist/clients/authenticationApi.d.cts +20 -0
- package/dist/clients/authenticationApi.d.cts.map +1 -0
- package/dist/clients/authenticationApi.d.ts +18 -13
- package/dist/clients/authenticationApi.d.ts.map +1 -0
- package/dist/clients/authenticationApi.js +65 -72
- package/dist/clients/authenticationApi.js.map +1 -1
- package/dist/clients/contentApi.cjs +94 -103
- package/dist/clients/contentApi.cjs.map +1 -1
- package/dist/clients/contentApi.d.cts +116 -0
- package/dist/clients/contentApi.d.cts.map +1 -0
- package/dist/clients/contentApi.d.ts +102 -98
- package/dist/clients/contentApi.d.ts.map +1 -0
- package/dist/clients/contentApi.js +94 -103
- package/dist/clients/contentApi.js.map +1 -1
- package/dist/clients/coreApi.cjs +154 -145
- package/dist/clients/coreApi.cjs.map +1 -1
- package/dist/clients/coreApi.d.cts +143 -0
- package/dist/clients/coreApi.d.cts.map +1 -0
- package/dist/clients/coreApi.d.ts +132 -109
- package/dist/clients/coreApi.d.ts.map +1 -0
- package/dist/clients/coreApi.js +153 -144
- package/dist/clients/coreApi.js.map +1 -1
- package/dist/clients/customTypesApi.cjs +90 -99
- package/dist/clients/customTypesApi.cjs.map +1 -1
- package/dist/clients/customTypesApi.d.cts +46 -0
- package/dist/clients/customTypesApi.d.cts.map +1 -0
- package/dist/clients/customTypesApi.d.ts +45 -45
- package/dist/clients/customTypesApi.d.ts.map +1 -0
- package/dist/clients/customTypesApi.js +87 -98
- package/dist/clients/customTypesApi.js.map +1 -1
- package/dist/clients/integrationFields.cjs +96 -87
- package/dist/clients/integrationFields.cjs.map +1 -1
- package/dist/clients/integrationFields.d.cts +30 -0
- package/dist/clients/integrationFields.d.cts.map +1 -0
- package/dist/clients/integrationFields.d.ts +27 -22
- package/dist/clients/integrationFields.d.ts.map +1 -0
- package/dist/clients/integrationFields.js +93 -86
- package/dist/clients/integrationFields.js.map +1 -1
- package/dist/clients/manageV2.cjs +154 -171
- package/dist/clients/manageV2.cjs.map +1 -1
- package/dist/clients/manageV2.d.cts +105 -0
- package/dist/clients/manageV2.d.cts.map +1 -0
- package/dist/clients/manageV2.d.ts +103 -111
- package/dist/clients/manageV2.d.ts.map +1 -0
- package/dist/clients/manageV2.js +149 -169
- package/dist/clients/manageV2.js.map +1 -1
- package/dist/clients/migrationApi.cjs +37 -36
- package/dist/clients/migrationApi.cjs.map +1 -1
- package/dist/clients/migrationApi.d.cts +48 -0
- package/dist/clients/migrationApi.d.cts.map +1 -0
- package/dist/clients/migrationApi.d.ts +45 -39
- package/dist/clients/migrationApi.d.ts.map +1 -0
- package/dist/clients/migrationApi.js +35 -34
- package/dist/clients/migrationApi.js.map +1 -1
- package/dist/clients/wroom.cjs +101 -122
- package/dist/clients/wroom.cjs.map +1 -1
- package/dist/clients/wroom.d.cts +48 -0
- package/dist/clients/wroom.d.cts.map +1 -0
- package/dist/clients/wroom.d.ts +46 -47
- package/dist/clients/wroom.d.ts.map +1 -0
- package/dist/clients/wroom.js +99 -122
- package/dist/clients/wroom.js.map +1 -1
- package/dist/index.cjs +13 -15
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -7
- package/dist/index.js +5 -14
- package/dist/managers/repositories.cjs +159 -169
- package/dist/managers/repositories.cjs.map +1 -1
- package/dist/managers/repositories.d.cts +67 -0
- package/dist/managers/repositories.d.cts.map +1 -0
- package/dist/managers/repositories.d.ts +56 -63
- package/dist/managers/repositories.d.ts.map +1 -0
- package/dist/managers/repositories.js +148 -159
- package/dist/managers/repositories.js.map +1 -1
- package/dist/managers/repository.cjs +595 -616
- package/dist/managers/repository.cjs.map +1 -1
- package/dist/managers/repository.d.cts +341 -0
- package/dist/managers/repository.d.cts.map +1 -0
- package/dist/managers/repository.d.ts +336 -307
- package/dist/managers/repository.d.ts.map +1 -0
- package/dist/managers/repository.js +595 -616
- package/dist/managers/repository.js.map +1 -1
- package/dist/types.d.cts +41 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +35 -37
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/cookies.cjs +19 -17
- package/dist/utils/cookies.cjs.map +1 -1
- package/dist/utils/cookies.js +20 -18
- package/dist/utils/cookies.js.map +1 -1
- package/dist/utils/envVariableManager.cjs +33 -34
- package/dist/utils/envVariableManager.cjs.map +1 -1
- package/dist/utils/envVariableManager.js +34 -35
- package/dist/utils/envVariableManager.js.map +1 -1
- package/dist/utils/log.cjs +18 -19
- package/dist/utils/log.cjs.map +1 -1
- package/dist/utils/log.js +18 -21
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/random.cjs +13 -6
- package/dist/utils/random.cjs.map +1 -1
- package/dist/utils/random.js +13 -6
- package/dist/utils/random.js.map +1 -1
- package/dist/utils/strings.cjs +13 -7
- package/dist/utils/strings.cjs.map +1 -1
- package/dist/utils/strings.js +14 -8
- package/dist/utils/strings.js.map +1 -1
- package/dist/utils/urls.cjs +21 -10
- package/dist/utils/urls.cjs.map +1 -1
- package/dist/utils/urls.js +22 -12
- package/dist/utils/urls.js.map +1 -1
- package/package.json +42 -67
- package/src/clients/apiClient.ts +16 -21
- package/src/clients/assetApi.ts +75 -82
- package/src/clients/authenticationApi.ts +54 -27
- package/src/clients/contentApi.ts +111 -129
- package/src/clients/coreApi.ts +166 -117
- package/src/clients/customTypesApi.ts +54 -74
- package/src/clients/integrationFields.ts +59 -74
- package/src/clients/manageV2.ts +72 -96
- package/src/clients/migrationApi.ts +35 -39
- package/src/clients/wroom.ts +42 -56
- package/src/index.ts +7 -7
- package/src/managers/repositories.ts +85 -108
- package/src/managers/repository.ts +410 -378
- package/src/types.ts +31 -31
- package/src/utils/cookies.ts +8 -8
- package/src/utils/envVariableManager.ts +15 -15
- package/src/utils/log.ts +17 -21
- package/src/utils/random.ts +5 -6
- package/src/utils/strings.ts +7 -9
- package/src/utils/urls.ts +10 -12
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/utils/cookies.d.ts +0 -8
- package/dist/utils/envVariableManager.d.ts +0 -16
- package/dist/utils/log.d.ts +0 -5
- package/dist/utils/random.d.ts +0 -8
- package/dist/utils/strings.d.ts +0 -11
- package/dist/utils/urls.d.ts +0 -16
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
1
|
+
import { logHttpResponse, logger } from "../utils/log.js";
|
|
2
|
+
import { getRepositoryUrl } from "../utils/urls.js";
|
|
7
3
|
import { AssetApiClient } from "../clients/assetApi.js";
|
|
8
4
|
import { AuthenticationApiClient } from "../clients/authenticationApi.js";
|
|
9
5
|
import { CoreApiClient } from "../clients/coreApi.js";
|
|
@@ -13,161 +9,154 @@ import { ManageV2Client } from "../clients/manageV2.js";
|
|
|
13
9
|
import { MigrationApiClient } from "../clients/migrationApi.js";
|
|
14
10
|
import { WroomClient } from "../clients/wroom.js";
|
|
15
11
|
import { EnvVariableManager } from "../utils/envVariableManager.js";
|
|
16
|
-
import { logger, logHttpResponse } from "../utils/log.js";
|
|
17
12
|
import { randomString } from "../utils/random.js";
|
|
18
|
-
import { getRepositoryUrl } from "../utils/urls.js";
|
|
19
13
|
import { RepositoryManager } from "./repository.js";
|
|
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
|
+
*/
|
|
20
27
|
const createRepositoriesManager = (configuration) => {
|
|
21
|
-
|
|
28
|
+
return new RepositoriesManager(configuration);
|
|
22
29
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const coreApiUrl = getRepositoryUrl(urlConfig.baseURL, repository);
|
|
152
|
-
const coreApiClient = new CoreApiClient(coreApiUrl, authToken);
|
|
153
|
-
const migrationApiClient = urlConfig.migrationApi ? new MigrationApiClient(urlConfig.migrationApi, {
|
|
154
|
-
authToken,
|
|
155
|
-
repository
|
|
156
|
-
}) : void 0;
|
|
157
|
-
const assetApiClient = new AssetApiClient(urlConfig.assetApi, {
|
|
158
|
-
authToken,
|
|
159
|
-
repository
|
|
160
|
-
});
|
|
161
|
-
const integrationFieldsClient = urlConfig.integrationFieldApi ? new IntegrationFieldsClient(urlConfig.integrationFieldApi, {
|
|
162
|
-
customTypesApiClient: customTypeClient,
|
|
163
|
-
wroomClient: this.wroomClient,
|
|
164
|
-
repository
|
|
165
|
-
}) : void 0;
|
|
166
|
-
return new RepositoryManager(repository, coreApiClient, this.authClient, this.wroomClient, customTypeClient, migrationApiClient, assetApiClient, this.manageV2Client, integrationFieldsClient);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
export {
|
|
170
|
-
RepositoriesManager,
|
|
171
|
-
createRepositoriesManager
|
|
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 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 WroomClient(this.config.urlConfig.baseURL, this.config.authConfig, this.config.cluster);
|
|
50
|
+
this.authClient = new AuthenticationApiClient(this.config.urlConfig.authenticationApi, this.config.authConfig);
|
|
51
|
+
this.manageV2Client = new 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 = logger.startTimer();
|
|
83
|
+
const { prefix = "e2e-tests" } = config;
|
|
84
|
+
const repositoryName = `${prefix}-${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
|
+
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 = 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
|
+
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 CustomTypesApiClient(urlConfig.customTypesApi, {
|
|
139
|
+
authToken,
|
|
140
|
+
repository
|
|
141
|
+
});
|
|
142
|
+
const coreApiClient = new CoreApiClient(getRepositoryUrl(urlConfig.baseURL, repository), authToken);
|
|
143
|
+
const migrationApiClient = urlConfig.migrationApi ? new MigrationApiClient(urlConfig.migrationApi, {
|
|
144
|
+
authToken,
|
|
145
|
+
repository
|
|
146
|
+
}) : void 0;
|
|
147
|
+
const assetApiClient = new AssetApiClient(urlConfig.assetApi, {
|
|
148
|
+
authToken,
|
|
149
|
+
repository
|
|
150
|
+
});
|
|
151
|
+
const integrationFieldsClient = urlConfig.integrationFieldApi ? new IntegrationFieldsClient(urlConfig.integrationFieldApi, {
|
|
152
|
+
customTypesApiClient: customTypeClient,
|
|
153
|
+
wroomClient: this.wroomClient,
|
|
154
|
+
repository
|
|
155
|
+
}) : void 0;
|
|
156
|
+
return new RepositoryManager(repository, coreApiClient, this.authClient, this.wroomClient, customTypeClient, migrationApiClient, assetApiClient, this.manageV2Client, integrationFieldsClient);
|
|
157
|
+
}
|
|
172
158
|
};
|
|
173
|
-
//#
|
|
159
|
+
//#endregion
|
|
160
|
+
export { RepositoriesManager, createRepositoriesManager };
|
|
161
|
+
|
|
162
|
+
//# sourceMappingURL=repositories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repositories.js","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":[],"mappings":";;;;;;;;;;;;;;;;;;;AA8Ba,MAAA,4BAA4B,CACxC,kBACwB;AAC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KAAK,EAAE,SAAS,uBAAuB,UAAU,KAAK;AAAA,EAChE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WAAQ;AACP,UAAA,eAAe,KAAK,aAAa;AACvC,eAAW,cAAc,cAAc;AAChC,YAAA,KAAK,iBAAiB,UAAU;AAAA,IACvC;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,qBAAqB,YAAkB;AAChC,UAAA,EAAE,UAAS,IAAK,KAAK;AAC3B,UAAM,YAAY,MAAM,KAAK,WAAW,SAAQ;AAChD,UAAM,mBAAmB,IAAI,qBAC5B,UAAU,gBACV;AAAA,MACC;AAAA,MACA;AAAA,IAAA,CACA;AAEF,UAAM,aAAa,iBAAiB,UAAU,SAAS,UAAU;AACjE,UAAM,gBAAgB,IAAI,cAAc,YAAY,SAAS;AAC7D,UAAM,qBAAqB,UAAU,eAClC,IAAI,mBAAmB,UAAU,cAAc;AAAA,MAC/C;AAAA,MACA;AAAA,IAAA,CACA,IACA;AACH,UAAM,iBAAiB,IAAI,eAAe,UAAU,UAAU;AAAA,MAC7D;AAAA,MACA;AAAA,IAAA,CACA;AACD,UAAM,0BAA0B,UAAU,sBACvC,IAAI,wBAAwB,UAAU,qBAAqB;AAAA,MAC3D,sBAAsB;AAAA,MACtB,aAAa,KAAK;AAAA,MAClB;AAAA,IAAA,CACA,IACA;AAEH,WAAO,IAAI,kBACV,YACA,eACA,KAAK,YACL,KAAK,aACL,kBACA,oBACA,gBACA,KAAK,gBACL,uBAAuB;AAAA,EAEzB;AACA;"}
|
|
1
|
+
{"version":3,"file":"repositories.js","names":[],"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;C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