@prismicio/e2e-tests-utils 1.0.0-alpha.1
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/LICENSE +202 -0
- package/README.md +128 -0
- package/dist/clients/authenticationApi.cjs +36 -0
- package/dist/clients/authenticationApi.cjs.map +1 -0
- package/dist/clients/authenticationApi.d.ts +6 -0
- package/dist/clients/authenticationApi.js +36 -0
- package/dist/clients/authenticationApi.js.map +1 -0
- package/dist/clients/customTypesApi.cjs +71 -0
- package/dist/clients/customTypesApi.cjs.map +1 -0
- package/dist/clients/customTypesApi.d.ts +11 -0
- package/dist/clients/customTypesApi.js +71 -0
- package/dist/clients/customTypesApi.js.map +1 -0
- package/dist/clients/wroom.cjs +78 -0
- package/dist/clients/wroom.cjs.map +1 -0
- package/dist/clients/wroom.d.ts +25 -0
- package/dist/clients/wroom.js +78 -0
- package/dist/clients/wroom.js.map +1 -0
- package/dist/index.cjs +8 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/managers/repositories.cjs +130 -0
- package/dist/managers/repositories.cjs.map +1 -0
- package/dist/managers/repositories.d.ts +84 -0
- package/dist/managers/repositories.js +130 -0
- package/dist/managers/repositories.js.map +1 -0
- package/dist/managers/repository.cjs +187 -0
- package/dist/managers/repository.cjs.map +1 -0
- package/dist/managers/repository.d.ts +114 -0
- package/dist/managers/repository.js +187 -0
- package/dist/managers/repository.js.map +1 -0
- package/dist/types.d.ts +4 -0
- package/dist/utils/cookies.cjs +20 -0
- package/dist/utils/cookies.cjs.map +1 -0
- package/dist/utils/cookies.d.ts +8 -0
- package/dist/utils/cookies.js +20 -0
- package/dist/utils/cookies.js.map +1 -0
- package/dist/utils/envVariableManager.cjs +36 -0
- package/dist/utils/envVariableManager.cjs.map +1 -0
- package/dist/utils/envVariableManager.d.ts +16 -0
- package/dist/utils/envVariableManager.js +36 -0
- package/dist/utils/envVariableManager.js.map +1 -0
- package/dist/utils/log.cjs +25 -0
- package/dist/utils/log.cjs.map +1 -0
- package/dist/utils/log.d.ts +3 -0
- package/dist/utils/log.js +25 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/random.cjs +9 -0
- package/dist/utils/random.cjs.map +1 -0
- package/dist/utils/random.d.ts +8 -0
- package/dist/utils/random.js +9 -0
- package/dist/utils/random.js.map +1 -0
- package/package.json +88 -0
- package/src/clients/authenticationApi.ts +53 -0
- package/src/clients/customTypesApi.ts +145 -0
- package/src/clients/wroom.ts +91 -0
- package/src/index.ts +3 -0
- package/src/managers/repositories.ts +194 -0
- package/src/managers/repository.ts +277 -0
- package/src/types.ts +1 -0
- package/src/utils/cookies.ts +30 -0
- package/src/utils/envVariableManager.ts +35 -0
- package/src/utils/log.ts +26 -0
- package/src/utils/random.ts +14 -0
|
@@ -0,0 +1,187 @@
|
|
|
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 log = require("../utils/log.cjs");
|
|
10
|
+
class RepositoryManager {
|
|
11
|
+
constructor(name, wroomClient, customTypesApiClient) {
|
|
12
|
+
__publicField(this, "name");
|
|
13
|
+
__publicField(this, "wroomClient");
|
|
14
|
+
__publicField(this, "customTypesApiClient");
|
|
15
|
+
this.name = name;
|
|
16
|
+
this.wroomClient = wroomClient;
|
|
17
|
+
this.customTypesApiClient = customTypesApiClient;
|
|
18
|
+
}
|
|
19
|
+
async configure(config) {
|
|
20
|
+
if (config.locales) {
|
|
21
|
+
await this.createLocales(config.locales);
|
|
22
|
+
}
|
|
23
|
+
if (config.customLocale) {
|
|
24
|
+
await this.createCustomLocale(config.customLocale);
|
|
25
|
+
}
|
|
26
|
+
if (config.defaultLocale) {
|
|
27
|
+
await this.setDefaultLocale(config.defaultLocale);
|
|
28
|
+
}
|
|
29
|
+
if (config.slices) {
|
|
30
|
+
await this.createSlices(config.slices);
|
|
31
|
+
}
|
|
32
|
+
if (config.customTypes) {
|
|
33
|
+
await this.createCustomTypes(config.customTypes);
|
|
34
|
+
}
|
|
35
|
+
if (config.preview) {
|
|
36
|
+
await this.createPreview(config.preview);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** @returns the repository base url, like https://my-repo.prismic.io */
|
|
40
|
+
getBaseURL() {
|
|
41
|
+
const url = new URL(this.wroomClient.getBaseURL());
|
|
42
|
+
url.hostname = `${this.name}.${url.hostname}`;
|
|
43
|
+
return url.toString();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Set additional standard locales for a repository in Wroom, does not fail if
|
|
47
|
+
* the locales already exist.
|
|
48
|
+
*
|
|
49
|
+
* @param locales - An array of all locales to be added to the repository.
|
|
50
|
+
*
|
|
51
|
+
* @throws Error if setting the locales fails.
|
|
52
|
+
*/
|
|
53
|
+
async createLocales(locales) {
|
|
54
|
+
const profiler = log.logger.startTimer();
|
|
55
|
+
const response = await this.wroomClient.post(this.name, "app/settings/multilanguages", { languages: locales });
|
|
56
|
+
const { data, status } = response;
|
|
57
|
+
const success = status === 200 || status === 400 && data.includes("already existing languages");
|
|
58
|
+
if (!success) {
|
|
59
|
+
log.logHttpResponse(response);
|
|
60
|
+
throw new Error(`Could not add locales ${locales.join(", ")}`);
|
|
61
|
+
}
|
|
62
|
+
profiler.done({ message: `standard locales '${locales}' set` });
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Set additional custom locale for a repository in Wroom, does not fail if
|
|
66
|
+
* the locales already exist.
|
|
67
|
+
*
|
|
68
|
+
* @param locale - The locale to be added to the repository.
|
|
69
|
+
*
|
|
70
|
+
* @throws Error if setting the locale fails.
|
|
71
|
+
*/
|
|
72
|
+
async createCustomLocale(locale) {
|
|
73
|
+
const profiler = log.logger.startTimer();
|
|
74
|
+
const response = await this.wroomClient.post(this.name, "app/settings/multilanguages/custom", locale);
|
|
75
|
+
const { data, status } = response;
|
|
76
|
+
const success = status === 200 || status === 400 && data.includes("code is already used");
|
|
77
|
+
if (!success) {
|
|
78
|
+
log.logHttpResponse(response);
|
|
79
|
+
throw new Error(`Could not create custom locale ${locale}`);
|
|
80
|
+
}
|
|
81
|
+
profiler.done({
|
|
82
|
+
message: `custom locale ${JSON.stringify(locale)} created`
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
failIfNot200(response, msg) {
|
|
86
|
+
if (response.status !== 200) {
|
|
87
|
+
log.logHttpResponse(response);
|
|
88
|
+
throw new Error(msg);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Delete a locale from a repository.
|
|
93
|
+
*
|
|
94
|
+
* @param locale - locale to remove from the repository configuration.
|
|
95
|
+
*
|
|
96
|
+
* @throws Error if deleting the locale fails.
|
|
97
|
+
*/
|
|
98
|
+
async deleteLocale(locale) {
|
|
99
|
+
const profiler = log.logger.startTimer();
|
|
100
|
+
const response = await this.wroomClient.post(this.name, `app/settings/multilanguages/${locale}/delete`);
|
|
101
|
+
this.failIfNot200(response, `Could not delete locale ${locale}`);
|
|
102
|
+
profiler.done({ message: `locale '${locale}' deleted` });
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Set the default (master) locale for a repository in Wroom, the locale needs
|
|
106
|
+
* to exist for the repository.
|
|
107
|
+
*
|
|
108
|
+
* @param locale - The locale to be set as the default.
|
|
109
|
+
*
|
|
110
|
+
* @throws Error if setting the default locale fails.
|
|
111
|
+
*/
|
|
112
|
+
async setDefaultLocale(locale) {
|
|
113
|
+
const profiler = log.logger.startTimer();
|
|
114
|
+
const response = await this.wroomClient.post(this.name, `/app/settings/multilanguages/${locale}/defineAsMaster`);
|
|
115
|
+
this.failIfNot200(response, `Could not set default locale to ${locale}`);
|
|
116
|
+
profiler.done({ message: `default locale set to '${locale}'` });
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Creates a release.
|
|
120
|
+
*
|
|
121
|
+
* @param label - The label for the release.
|
|
122
|
+
*
|
|
123
|
+
* @returns A Promise that resolves when the release is created.
|
|
124
|
+
*/
|
|
125
|
+
async createRelease(label) {
|
|
126
|
+
const profiler = log.logger.startTimer();
|
|
127
|
+
const response = await this.wroomClient.post(this.name, "./app/releases", {
|
|
128
|
+
label
|
|
129
|
+
});
|
|
130
|
+
this.failIfNot200(response, `Could not create release ${label}`);
|
|
131
|
+
profiler.done({ message: `release '${label}' created` });
|
|
132
|
+
return response.data;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Deletes a repository release.
|
|
136
|
+
*
|
|
137
|
+
* @param repository - The name of the repository.
|
|
138
|
+
* @param id - The ID of the release to be deleted.
|
|
139
|
+
*/
|
|
140
|
+
async deleteRelease(id) {
|
|
141
|
+
const profiler = log.logger.startTimer();
|
|
142
|
+
const response = await this.wroomClient.post(this.name, `./app/releases/${id}/delete`, {});
|
|
143
|
+
this.failIfNot200(response, `Could not delete release with id ${id}`);
|
|
144
|
+
profiler.done({ message: `release '${id}' deleted` });
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Creates a preview for a repository.
|
|
148
|
+
*
|
|
149
|
+
* @param data - The data for creating the preview.
|
|
150
|
+
*/
|
|
151
|
+
async createPreview(data) {
|
|
152
|
+
const profiler = log.logger.startTimer();
|
|
153
|
+
const response = await this.wroomClient.post(this.name, `./previews/new`, data);
|
|
154
|
+
this.failIfNot200(response, `Could not create preview ${data.name}`);
|
|
155
|
+
profiler.done({ message: `preview '${data.name}' created` });
|
|
156
|
+
return response.data;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Deletes a preview from a repository.
|
|
160
|
+
*
|
|
161
|
+
* @param id - The ID of the preview to be deleted.
|
|
162
|
+
*/
|
|
163
|
+
async deletePreview(id) {
|
|
164
|
+
const profiler = log.logger.startTimer();
|
|
165
|
+
const response = await this.wroomClient.post(this.name, `./previews/delete/${id}`, {});
|
|
166
|
+
this.failIfNot200(response, `Could not delete preview with id${id}`);
|
|
167
|
+
profiler.done({ message: `preview '${id}' deleted` });
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Create Custom Types using the Custom types api.
|
|
171
|
+
*
|
|
172
|
+
* @param customTypes -
|
|
173
|
+
*/
|
|
174
|
+
async createCustomTypes(customTypes) {
|
|
175
|
+
await this.customTypesApiClient.createCustomTypes(customTypes);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Create slices using the Custom types api.
|
|
179
|
+
*
|
|
180
|
+
* @param slices -
|
|
181
|
+
*/
|
|
182
|
+
async createSlices(slices) {
|
|
183
|
+
await this.customTypesApiClient.createSlices(slices);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.RepositoryManager = RepositoryManager;
|
|
187
|
+
//# sourceMappingURL=repository.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.cjs","sources":["../../../src/managers/repository.ts"],"sourcesContent":["import { AxiosResponse } from \"axios\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { CustomTypesClient } from \"../clients/customTypesApi\";\nimport { WroomClient } from \"../clients/wroom\";\nimport { logHttpResponse, logger } from \"../utils/log\";\n\n/** Utility to manage test data for a Prismic repository */\nexport class RepositoryManager {\n\tconstructor(\n\t\treadonly name: string,\n\t\tprivate readonly wroomClient: WroomClient,\n\t\tprivate readonly customTypesApiClient: CustomTypesClient,\n\t) {}\n\n\tasync configure(config: RepositoryConfig): Promise<void> {\n\t\tif (config.locales) {\n\t\t\tawait this.createLocales(config.locales);\n\t\t}\n\n\t\tif (config.customLocale) {\n\t\t\tawait this.createCustomLocale(config.customLocale);\n\t\t}\n\n\t\tif (config.defaultLocale) {\n\t\t\tawait this.setDefaultLocale(config.defaultLocale);\n\t\t}\n\n\t\tif (config.slices) {\n\t\t\tawait this.createSlices(config.slices);\n\t\t}\n\n\t\tif (config.customTypes) {\n\t\t\tawait this.createCustomTypes(config.customTypes);\n\t\t}\n\n\t\tif (config.preview) {\n\t\t\tawait this.createPreview(config.preview);\n\t\t}\n\t}\n\t/** @returns the repository base url, like https://my-repo.prismic.io */\n\tgetBaseURL(): string {\n\t\tconst url = new URL(this.wroomClient.getBaseURL());\n\t\turl.hostname = `${this.name}.${url.hostname}`;\n\n\t\treturn url.toString();\n\t}\n\n\t/**\n\t * Set additional standard locales for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locales - An array of all locales to be added to the repository.\n\t *\n\t * @throws Error if setting the locales fails.\n\t */\n\tasync createLocales(locales: string[]): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages\",\n\t\t\t{ languages: locales },\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t(data as string).includes(\"already existing languages\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add locales ${locales.join(\", \")}`);\n\t\t}\n\t\tprofiler.done({ message: `standard locales '${locales}' set` });\n\t}\n\n\t/**\n\t * Set additional custom locale for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locale - The locale to be added to the repository.\n\t *\n\t * @throws Error if setting the locale fails.\n\t */\n\tasync createCustomLocale(locale: CustomLocale): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages/custom\",\n\t\t\tlocale,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 && (data as string).includes(\"code is already used\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not create custom locale ${locale}`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `custom locale ${JSON.stringify(locale)} created`,\n\t\t});\n\t}\n\n\tprivate failIfNot200(response: AxiosResponse, msg: string) {\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(msg);\n\t\t}\n\t}\n\n\t/**\n\t * Delete a locale from a repository.\n\t *\n\t * @param locale - locale to remove from the repository configuration.\n\t *\n\t * @throws Error if deleting the locale fails.\n\t */\n\tasync deleteLocale(locale: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/multilanguages/${locale}/delete`,\n\t\t);\n\t\tthis.failIfNot200(response, `Could not delete locale ${locale}`);\n\t\tprofiler.done({ message: `locale '${locale}' deleted` });\n\t}\n\n\t/**\n\t * Set the default (master) locale for a repository in Wroom, the locale needs\n\t * to exist for the repository.\n\t *\n\t * @param locale - The locale to be set as the default.\n\t *\n\t * @throws Error if setting the default locale fails.\n\t */\n\tasync setDefaultLocale(locale: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`/app/settings/multilanguages/${locale}/defineAsMaster`,\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not set default locale to ${locale}`);\n\t\tprofiler.done({ message: `default locale set to '${locale}'` });\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\n\t *\n\t * @returns A Promise that resolves when the release is created.\n\t */\n\tasync createRelease(label: string): Promise<{ id: string }> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(this.name, \"./app/releases\", {\n\t\t\tlabel,\n\t\t});\n\t\tthis.failIfNot200(response, `Could not create release ${label}`);\n\t\tprofiler.done({ message: `release '${label}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\n\t * @param repository - The name of the repository.\n\t * @param id - The ID of the release to be deleted.\n\t */\n\tasync deleteRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`./app/releases/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete release with id ${id}`);\n\t\tprofiler.done({ message: `release '${id}' deleted` });\n\t}\n\n\t/**\n\t * Creates a preview for a repository.\n\t *\n\t * @param data - The data for creating the preview.\n\t */\n\tasync createPreview(data: Preview): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`./previews/new`,\n\t\t\tdata,\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not create preview ${data.name}`);\n\t\tprofiler.done({ message: `preview '${data.name}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a preview from a repository.\n\t *\n\t * @param id - The ID of the preview to be deleted.\n\t */\n\tasync deletePreview(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`./previews/delete/${id}`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete preview with id${id}`);\n\t\tprofiler.done({ message: `preview '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes -\n\t */\n\tasync createCustomTypes(customTypes: CustomType[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes);\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices -\n\t */\n\tasync createSlices(slices: SharedSlice[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createSlices(slices);\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale;\n\tlocales?: string[];\n\tdefaultLocale?: string;\n\tslices?: SharedSlice[];\n\tcustomTypes?: CustomType[];\n\tpreview?: Preview;\n};\n\nexport type Preview = {\n\tname: string;\n\twebsiteURL: string;\n\tresolverPath: string;\n};\n\nexport type CustomLocale = {\n\tlang: {\n\t\tlabel: string;\n\t\tid: string;\n\t\tuseStandardAnalyzer?: boolean;\n\t};\n\tregion: {\n\t\tlabel: string;\n\t\tid: string;\n\t};\n};\n"],"names":["logger","logHttpResponse"],"mappings":";;;;;;;;;MAYa,kBAAiB;AAAA,EAC7B,YACU,MACQ,aACA,sBAAuC;AAF/C;AACQ;AACA;AAFR,SAAI,OAAJ;AACQ,SAAW,cAAX;AACA,SAAoB,uBAApB;AAAA,EACf;AAAA,EAEH,MAAM,UAAU,QAAwB;AACvC,QAAI,OAAO,SAAS;AACb,YAAA,KAAK,cAAc,OAAO,OAAO;AAAA,IACvC;AAED,QAAI,OAAO,cAAc;AAClB,YAAA,KAAK,mBAAmB,OAAO,YAAY;AAAA,IACjD;AAED,QAAI,OAAO,eAAe;AACnB,YAAA,KAAK,iBAAiB,OAAO,aAAa;AAAA,IAChD;AAED,QAAI,OAAO,QAAQ;AACZ,YAAA,KAAK,aAAa,OAAO,MAAM;AAAA,IACrC;AAED,QAAI,OAAO,aAAa;AACjB,YAAA,KAAK,kBAAkB,OAAO,WAAW;AAAA,IAC/C;AAED,QAAI,OAAO,SAAS;AACb,YAAA,KAAK,cAAc,OAAO,OAAO;AAAA,IACvC;AAAA,EACF;AAAA;AAAA,EAEA,aAAU;AACT,UAAM,MAAM,IAAI,IAAI,KAAK,YAAY,YAAY;AACjD,QAAI,WAAW,GAAG,KAAK,IAAI,IAAI,IAAI,QAAQ;AAE3C,WAAO,IAAI;EACZ;AAAA;AAAA;AAA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AK,EAAE,SAAS,YAAY,KAAK,IAAI,aAAa;AAE3D,WAAO,SAAS;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,cAAc,IAAU;AACvB,UAAA,WAAWA,WAAO;AAElB,UAAA,WAAW,MAAM,KAAK,YAAY,KACvC,KAAK,MACL,qBAAqB,EAAE,IACvB,CAAE,CAAA;AAGH,SAAK,aAAa,UAAU,mCAAmC,EAAE,EAAE;AACnE,aAAS,KAAK,EAAE,SAAS,YAAY,EAAE,aAAa;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,kBAAkB,aAAyB;AAC1C,UAAA,KAAK,qBAAqB,kBAAkB,WAAW;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,QAAqB;AACjC,UAAA,KAAK,qBAAqB,aAAa,MAAM;AAAA,EACpD;AACA;;"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { CustomType, SharedSlice } from "@prismicio/types-internal/lib/customtypes";
|
|
2
|
+
import { CustomTypesClient } from "../clients/customTypesApi";
|
|
3
|
+
import { WroomClient } from "../clients/wroom";
|
|
4
|
+
/** Utility to manage test data for a Prismic repository */
|
|
5
|
+
export declare class RepositoryManager {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
private readonly wroomClient;
|
|
8
|
+
private readonly customTypesApiClient;
|
|
9
|
+
constructor(name: string, wroomClient: WroomClient, customTypesApiClient: CustomTypesClient);
|
|
10
|
+
configure(config: RepositoryConfig): Promise<void>;
|
|
11
|
+
/** @returns the repository base url, like https://my-repo.prismic.io */
|
|
12
|
+
getBaseURL(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Set additional standard locales for a repository in Wroom, does not fail if
|
|
15
|
+
* the locales already exist.
|
|
16
|
+
*
|
|
17
|
+
* @param locales - An array of all locales to be added to the repository.
|
|
18
|
+
*
|
|
19
|
+
* @throws Error if setting the locales fails.
|
|
20
|
+
*/
|
|
21
|
+
createLocales(locales: string[]): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Set additional custom locale for a repository in Wroom, does not fail if
|
|
24
|
+
* the locales already exist.
|
|
25
|
+
*
|
|
26
|
+
* @param locale - The locale to be added to the repository.
|
|
27
|
+
*
|
|
28
|
+
* @throws Error if setting the locale fails.
|
|
29
|
+
*/
|
|
30
|
+
createCustomLocale(locale: CustomLocale): Promise<void>;
|
|
31
|
+
private failIfNot200;
|
|
32
|
+
/**
|
|
33
|
+
* Delete a locale from a repository.
|
|
34
|
+
*
|
|
35
|
+
* @param locale - locale to remove from the repository configuration.
|
|
36
|
+
*
|
|
37
|
+
* @throws Error if deleting the locale fails.
|
|
38
|
+
*/
|
|
39
|
+
deleteLocale(locale: string): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Set the default (master) locale for a repository in Wroom, the locale needs
|
|
42
|
+
* to exist for the repository.
|
|
43
|
+
*
|
|
44
|
+
* @param locale - The locale to be set as the default.
|
|
45
|
+
*
|
|
46
|
+
* @throws Error if setting the default locale fails.
|
|
47
|
+
*/
|
|
48
|
+
setDefaultLocale(locale: string): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a release.
|
|
51
|
+
*
|
|
52
|
+
* @param label - The label for the release.
|
|
53
|
+
*
|
|
54
|
+
* @returns A Promise that resolves when the release is created.
|
|
55
|
+
*/
|
|
56
|
+
createRelease(label: string): Promise<{
|
|
57
|
+
id: string;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Deletes a repository release.
|
|
61
|
+
*
|
|
62
|
+
* @param repository - The name of the repository.
|
|
63
|
+
* @param id - The ID of the release to be deleted.
|
|
64
|
+
*/
|
|
65
|
+
deleteRelease(id: string): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Creates a preview for a repository.
|
|
68
|
+
*
|
|
69
|
+
* @param data - The data for creating the preview.
|
|
70
|
+
*/
|
|
71
|
+
createPreview(data: Preview): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Deletes a preview from a repository.
|
|
74
|
+
*
|
|
75
|
+
* @param id - The ID of the preview to be deleted.
|
|
76
|
+
*/
|
|
77
|
+
deletePreview(id: string): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Create Custom Types using the Custom types api.
|
|
80
|
+
*
|
|
81
|
+
* @param customTypes -
|
|
82
|
+
*/
|
|
83
|
+
createCustomTypes(customTypes: CustomType[]): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Create slices using the Custom types api.
|
|
86
|
+
*
|
|
87
|
+
* @param slices -
|
|
88
|
+
*/
|
|
89
|
+
createSlices(slices: SharedSlice[]): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
export type RepositoryConfig = {
|
|
92
|
+
customLocale?: CustomLocale;
|
|
93
|
+
locales?: string[];
|
|
94
|
+
defaultLocale?: string;
|
|
95
|
+
slices?: SharedSlice[];
|
|
96
|
+
customTypes?: CustomType[];
|
|
97
|
+
preview?: Preview;
|
|
98
|
+
};
|
|
99
|
+
export type Preview = {
|
|
100
|
+
name: string;
|
|
101
|
+
websiteURL: string;
|
|
102
|
+
resolverPath: string;
|
|
103
|
+
};
|
|
104
|
+
export type CustomLocale = {
|
|
105
|
+
lang: {
|
|
106
|
+
label: string;
|
|
107
|
+
id: string;
|
|
108
|
+
useStandardAnalyzer?: boolean;
|
|
109
|
+
};
|
|
110
|
+
region: {
|
|
111
|
+
label: string;
|
|
112
|
+
id: string;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import { logger, logHttpResponse } from "../utils/log.js";
|
|
8
|
+
class RepositoryManager {
|
|
9
|
+
constructor(name, wroomClient, customTypesApiClient) {
|
|
10
|
+
__publicField(this, "name");
|
|
11
|
+
__publicField(this, "wroomClient");
|
|
12
|
+
__publicField(this, "customTypesApiClient");
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.wroomClient = wroomClient;
|
|
15
|
+
this.customTypesApiClient = customTypesApiClient;
|
|
16
|
+
}
|
|
17
|
+
async configure(config) {
|
|
18
|
+
if (config.locales) {
|
|
19
|
+
await this.createLocales(config.locales);
|
|
20
|
+
}
|
|
21
|
+
if (config.customLocale) {
|
|
22
|
+
await this.createCustomLocale(config.customLocale);
|
|
23
|
+
}
|
|
24
|
+
if (config.defaultLocale) {
|
|
25
|
+
await this.setDefaultLocale(config.defaultLocale);
|
|
26
|
+
}
|
|
27
|
+
if (config.slices) {
|
|
28
|
+
await this.createSlices(config.slices);
|
|
29
|
+
}
|
|
30
|
+
if (config.customTypes) {
|
|
31
|
+
await this.createCustomTypes(config.customTypes);
|
|
32
|
+
}
|
|
33
|
+
if (config.preview) {
|
|
34
|
+
await this.createPreview(config.preview);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** @returns the repository base url, like https://my-repo.prismic.io */
|
|
38
|
+
getBaseURL() {
|
|
39
|
+
const url = new URL(this.wroomClient.getBaseURL());
|
|
40
|
+
url.hostname = `${this.name}.${url.hostname}`;
|
|
41
|
+
return url.toString();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Set additional standard locales for a repository in Wroom, does not fail if
|
|
45
|
+
* the locales already exist.
|
|
46
|
+
*
|
|
47
|
+
* @param locales - An array of all locales to be added to the repository.
|
|
48
|
+
*
|
|
49
|
+
* @throws Error if setting the locales fails.
|
|
50
|
+
*/
|
|
51
|
+
async createLocales(locales) {
|
|
52
|
+
const profiler = logger.startTimer();
|
|
53
|
+
const response = await this.wroomClient.post(this.name, "app/settings/multilanguages", { languages: locales });
|
|
54
|
+
const { data, status } = response;
|
|
55
|
+
const success = status === 200 || status === 400 && data.includes("already existing languages");
|
|
56
|
+
if (!success) {
|
|
57
|
+
logHttpResponse(response);
|
|
58
|
+
throw new Error(`Could not add locales ${locales.join(", ")}`);
|
|
59
|
+
}
|
|
60
|
+
profiler.done({ message: `standard locales '${locales}' set` });
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Set additional custom locale for a repository in Wroom, does not fail if
|
|
64
|
+
* the locales already exist.
|
|
65
|
+
*
|
|
66
|
+
* @param locale - The locale to be added to the repository.
|
|
67
|
+
*
|
|
68
|
+
* @throws Error if setting the locale fails.
|
|
69
|
+
*/
|
|
70
|
+
async createCustomLocale(locale) {
|
|
71
|
+
const profiler = logger.startTimer();
|
|
72
|
+
const response = await this.wroomClient.post(this.name, "app/settings/multilanguages/custom", locale);
|
|
73
|
+
const { data, status } = response;
|
|
74
|
+
const success = status === 200 || status === 400 && data.includes("code is already used");
|
|
75
|
+
if (!success) {
|
|
76
|
+
logHttpResponse(response);
|
|
77
|
+
throw new Error(`Could not create custom locale ${locale}`);
|
|
78
|
+
}
|
|
79
|
+
profiler.done({
|
|
80
|
+
message: `custom locale ${JSON.stringify(locale)} created`
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
failIfNot200(response, msg) {
|
|
84
|
+
if (response.status !== 200) {
|
|
85
|
+
logHttpResponse(response);
|
|
86
|
+
throw new Error(msg);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Delete a locale from a repository.
|
|
91
|
+
*
|
|
92
|
+
* @param locale - locale to remove from the repository configuration.
|
|
93
|
+
*
|
|
94
|
+
* @throws Error if deleting the locale fails.
|
|
95
|
+
*/
|
|
96
|
+
async deleteLocale(locale) {
|
|
97
|
+
const profiler = logger.startTimer();
|
|
98
|
+
const response = await this.wroomClient.post(this.name, `app/settings/multilanguages/${locale}/delete`);
|
|
99
|
+
this.failIfNot200(response, `Could not delete locale ${locale}`);
|
|
100
|
+
profiler.done({ message: `locale '${locale}' deleted` });
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Set the default (master) locale for a repository in Wroom, the locale needs
|
|
104
|
+
* to exist for the repository.
|
|
105
|
+
*
|
|
106
|
+
* @param locale - The locale to be set as the default.
|
|
107
|
+
*
|
|
108
|
+
* @throws Error if setting the default locale fails.
|
|
109
|
+
*/
|
|
110
|
+
async setDefaultLocale(locale) {
|
|
111
|
+
const profiler = logger.startTimer();
|
|
112
|
+
const response = await this.wroomClient.post(this.name, `/app/settings/multilanguages/${locale}/defineAsMaster`);
|
|
113
|
+
this.failIfNot200(response, `Could not set default locale to ${locale}`);
|
|
114
|
+
profiler.done({ message: `default locale set to '${locale}'` });
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Creates a release.
|
|
118
|
+
*
|
|
119
|
+
* @param label - The label for the release.
|
|
120
|
+
*
|
|
121
|
+
* @returns A Promise that resolves when the release is created.
|
|
122
|
+
*/
|
|
123
|
+
async createRelease(label) {
|
|
124
|
+
const profiler = logger.startTimer();
|
|
125
|
+
const response = await this.wroomClient.post(this.name, "./app/releases", {
|
|
126
|
+
label
|
|
127
|
+
});
|
|
128
|
+
this.failIfNot200(response, `Could not create release ${label}`);
|
|
129
|
+
profiler.done({ message: `release '${label}' created` });
|
|
130
|
+
return response.data;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Deletes a repository release.
|
|
134
|
+
*
|
|
135
|
+
* @param repository - The name of the repository.
|
|
136
|
+
* @param id - The ID of the release to be deleted.
|
|
137
|
+
*/
|
|
138
|
+
async deleteRelease(id) {
|
|
139
|
+
const profiler = logger.startTimer();
|
|
140
|
+
const response = await this.wroomClient.post(this.name, `./app/releases/${id}/delete`, {});
|
|
141
|
+
this.failIfNot200(response, `Could not delete release with id ${id}`);
|
|
142
|
+
profiler.done({ message: `release '${id}' deleted` });
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Creates a preview for a repository.
|
|
146
|
+
*
|
|
147
|
+
* @param data - The data for creating the preview.
|
|
148
|
+
*/
|
|
149
|
+
async createPreview(data) {
|
|
150
|
+
const profiler = logger.startTimer();
|
|
151
|
+
const response = await this.wroomClient.post(this.name, `./previews/new`, data);
|
|
152
|
+
this.failIfNot200(response, `Could not create preview ${data.name}`);
|
|
153
|
+
profiler.done({ message: `preview '${data.name}' created` });
|
|
154
|
+
return response.data;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Deletes a preview from a repository.
|
|
158
|
+
*
|
|
159
|
+
* @param id - The ID of the preview to be deleted.
|
|
160
|
+
*/
|
|
161
|
+
async deletePreview(id) {
|
|
162
|
+
const profiler = logger.startTimer();
|
|
163
|
+
const response = await this.wroomClient.post(this.name, `./previews/delete/${id}`, {});
|
|
164
|
+
this.failIfNot200(response, `Could not delete preview with id${id}`);
|
|
165
|
+
profiler.done({ message: `preview '${id}' deleted` });
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Create Custom Types using the Custom types api.
|
|
169
|
+
*
|
|
170
|
+
* @param customTypes -
|
|
171
|
+
*/
|
|
172
|
+
async createCustomTypes(customTypes) {
|
|
173
|
+
await this.customTypesApiClient.createCustomTypes(customTypes);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Create slices using the Custom types api.
|
|
177
|
+
*
|
|
178
|
+
* @param slices -
|
|
179
|
+
*/
|
|
180
|
+
async createSlices(slices) {
|
|
181
|
+
await this.customTypesApiClient.createSlices(slices);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
export {
|
|
185
|
+
RepositoryManager
|
|
186
|
+
};
|
|
187
|
+
//# sourceMappingURL=repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.js","sources":["../../../src/managers/repository.ts"],"sourcesContent":["import { AxiosResponse } from \"axios\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { CustomTypesClient } from \"../clients/customTypesApi\";\nimport { WroomClient } from \"../clients/wroom\";\nimport { logHttpResponse, logger } from \"../utils/log\";\n\n/** Utility to manage test data for a Prismic repository */\nexport class RepositoryManager {\n\tconstructor(\n\t\treadonly name: string,\n\t\tprivate readonly wroomClient: WroomClient,\n\t\tprivate readonly customTypesApiClient: CustomTypesClient,\n\t) {}\n\n\tasync configure(config: RepositoryConfig): Promise<void> {\n\t\tif (config.locales) {\n\t\t\tawait this.createLocales(config.locales);\n\t\t}\n\n\t\tif (config.customLocale) {\n\t\t\tawait this.createCustomLocale(config.customLocale);\n\t\t}\n\n\t\tif (config.defaultLocale) {\n\t\t\tawait this.setDefaultLocale(config.defaultLocale);\n\t\t}\n\n\t\tif (config.slices) {\n\t\t\tawait this.createSlices(config.slices);\n\t\t}\n\n\t\tif (config.customTypes) {\n\t\t\tawait this.createCustomTypes(config.customTypes);\n\t\t}\n\n\t\tif (config.preview) {\n\t\t\tawait this.createPreview(config.preview);\n\t\t}\n\t}\n\t/** @returns the repository base url, like https://my-repo.prismic.io */\n\tgetBaseURL(): string {\n\t\tconst url = new URL(this.wroomClient.getBaseURL());\n\t\turl.hostname = `${this.name}.${url.hostname}`;\n\n\t\treturn url.toString();\n\t}\n\n\t/**\n\t * Set additional standard locales for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locales - An array of all locales to be added to the repository.\n\t *\n\t * @throws Error if setting the locales fails.\n\t */\n\tasync createLocales(locales: string[]): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages\",\n\t\t\t{ languages: locales },\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 &&\n\t\t\t\t(data as string).includes(\"already existing languages\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not add locales ${locales.join(\", \")}`);\n\t\t}\n\t\tprofiler.done({ message: `standard locales '${locales}' set` });\n\t}\n\n\t/**\n\t * Set additional custom locale for a repository in Wroom, does not fail if\n\t * the locales already exist.\n\t *\n\t * @param locale - The locale to be added to the repository.\n\t *\n\t * @throws Error if setting the locale fails.\n\t */\n\tasync createCustomLocale(locale: CustomLocale): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t\"app/settings/multilanguages/custom\",\n\t\t\tlocale,\n\t\t);\n\n\t\tconst { data, status } = response;\n\t\tconst success =\n\t\t\tstatus === 200 ||\n\t\t\t(status === 400 && (data as string).includes(\"code is already used\"));\n\t\tif (!success) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(`Could not create custom locale ${locale}`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `custom locale ${JSON.stringify(locale)} created`,\n\t\t});\n\t}\n\n\tprivate failIfNot200(response: AxiosResponse, msg: string) {\n\t\tif (response.status !== 200) {\n\t\t\tlogHttpResponse(response);\n\t\t\tthrow new Error(msg);\n\t\t}\n\t}\n\n\t/**\n\t * Delete a locale from a repository.\n\t *\n\t * @param locale - locale to remove from the repository configuration.\n\t *\n\t * @throws Error if deleting the locale fails.\n\t */\n\tasync deleteLocale(locale: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`app/settings/multilanguages/${locale}/delete`,\n\t\t);\n\t\tthis.failIfNot200(response, `Could not delete locale ${locale}`);\n\t\tprofiler.done({ message: `locale '${locale}' deleted` });\n\t}\n\n\t/**\n\t * Set the default (master) locale for a repository in Wroom, the locale needs\n\t * to exist for the repository.\n\t *\n\t * @param locale - The locale to be set as the default.\n\t *\n\t * @throws Error if setting the default locale fails.\n\t */\n\tasync setDefaultLocale(locale: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`/app/settings/multilanguages/${locale}/defineAsMaster`,\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not set default locale to ${locale}`);\n\t\tprofiler.done({ message: `default locale set to '${locale}'` });\n\t}\n\n\t/**\n\t * Creates a release.\n\t *\n\t * @param label - The label for the release.\n\t *\n\t * @returns A Promise that resolves when the release is created.\n\t */\n\tasync createRelease(label: string): Promise<{ id: string }> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(this.name, \"./app/releases\", {\n\t\t\tlabel,\n\t\t});\n\t\tthis.failIfNot200(response, `Could not create release ${label}`);\n\t\tprofiler.done({ message: `release '${label}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a repository release.\n\t *\n\t * @param repository - The name of the repository.\n\t * @param id - The ID of the release to be deleted.\n\t */\n\tasync deleteRelease(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`./app/releases/${id}/delete`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete release with id ${id}`);\n\t\tprofiler.done({ message: `release '${id}' deleted` });\n\t}\n\n\t/**\n\t * Creates a preview for a repository.\n\t *\n\t * @param data - The data for creating the preview.\n\t */\n\tasync createPreview(data: Preview): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`./previews/new`,\n\t\t\tdata,\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not create preview ${data.name}`);\n\t\tprofiler.done({ message: `preview '${data.name}' created` });\n\n\t\treturn response.data;\n\t}\n\n\t/**\n\t * Deletes a preview from a repository.\n\t *\n\t * @param id - The ID of the preview to be deleted.\n\t */\n\tasync deletePreview(id: string): Promise<void> {\n\t\tconst profiler = logger.startTimer();\n\n\t\tconst response = await this.wroomClient.post(\n\t\t\tthis.name,\n\t\t\t`./previews/delete/${id}`,\n\t\t\t{},\n\t\t);\n\n\t\tthis.failIfNot200(response, `Could not delete preview with id${id}`);\n\t\tprofiler.done({ message: `preview '${id}' deleted` });\n\t}\n\n\t/**\n\t * Create Custom Types using the Custom types api.\n\t *\n\t * @param customTypes -\n\t */\n\tasync createCustomTypes(customTypes: CustomType[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createCustomTypes(customTypes);\n\t}\n\n\t/**\n\t * Create slices using the Custom types api.\n\t *\n\t * @param slices -\n\t */\n\tasync createSlices(slices: SharedSlice[]): Promise<void> {\n\t\tawait this.customTypesApiClient.createSlices(slices);\n\t}\n}\n\nexport type RepositoryConfig = {\n\tcustomLocale?: CustomLocale;\n\tlocales?: string[];\n\tdefaultLocale?: string;\n\tslices?: SharedSlice[];\n\tcustomTypes?: CustomType[];\n\tpreview?: Preview;\n};\n\nexport type Preview = {\n\tname: string;\n\twebsiteURL: string;\n\tresolverPath: string;\n};\n\nexport type CustomLocale = {\n\tlang: {\n\t\tlabel: string;\n\t\tid: string;\n\t\tuseStandardAnalyzer?: boolean;\n\t};\n\tregion: {\n\t\tlabel: string;\n\t\tid: string;\n\t};\n};\n"],"names":[],"mappings":";;;;;;;MAYa,kBAAiB;AAAA,EAC7B,YACU,MACQ,aACA,sBAAuC;AAF/C;AACQ;AACA;AAFR,SAAI,OAAJ;AACQ,SAAW,cAAX;AACA,SAAoB,uBAApB;AAAA,EACf;AAAA,EAEH,MAAM,UAAU,QAAwB;AACvC,QAAI,OAAO,SAAS;AACb,YAAA,KAAK,cAAc,OAAO,OAAO;AAAA,IACvC;AAED,QAAI,OAAO,cAAc;AAClB,YAAA,KAAK,mBAAmB,OAAO,YAAY;AAAA,IACjD;AAED,QAAI,OAAO,eAAe;AACnB,YAAA,KAAK,iBAAiB,OAAO,aAAa;AAAA,IAChD;AAED,QAAI,OAAO,QAAQ;AACZ,YAAA,KAAK,aAAa,OAAO,MAAM;AAAA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AU,oCAAoC,EAAE,EAAE;AACpE,aAAS,KAAK,EAAE,SAAS,YAAY,EAAE,aAAa;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,cAAc,MAAa;AAC1B,UAAA,WAAW,OAAO;AAElB,UAAA,WAAW,MAAM,KAAK,YAAY,KACvC,KAAK,MACL,kBACA,IAAI;AAGL,SAAK,aAAa,UAAU,4BAA4B,KAAK,IAAI,EAAE;AACnE,aAAS,KAAK,EAAE,SAAS,YAAY,KAAK,IAAI,aAAa;AAE3D,WAAO,SAAS;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,cAAc,IAAU;AACvB,UAAA,WAAW,OAAO;AAElB,UAAA,WAAW,MAAM,KAAK,YAAY,KACvC,KAAK,MACL,qBAAqB,EAAE,IACvB,CAAE,CAAA;AAGH,SAAK,aAAa,UAAU,mCAAmC,EAAE,EAAE;AACnE,aAAS,KAAK,EAAE,SAAS,YAAY,EAAE,aAAa;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,kBAAkB,aAAyB;AAC1C,UAAA,KAAK,qBAAqB,kBAAkB,WAAW;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,QAAqB;AACjC,UAAA,KAAK,qBAAqB,aAAa,MAAM;AAAA,EACpD;AACA;"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const extractCookie = (cookies, cookieName) => {
|
|
4
|
+
const regex = new RegExp(`${cookieName}=([^;]+)`, "i");
|
|
5
|
+
if (typeof cookies === "string") {
|
|
6
|
+
const match = cookies.match(regex);
|
|
7
|
+
return match ? match[1] : void 0;
|
|
8
|
+
}
|
|
9
|
+
if (cookies instanceof Array) {
|
|
10
|
+
for (const cookie of cookies) {
|
|
11
|
+
const match = cookie.match(regex);
|
|
12
|
+
if (match) {
|
|
13
|
+
return match[1];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return void 0;
|
|
18
|
+
};
|
|
19
|
+
exports.extractCookie = extractCookie;
|
|
20
|
+
//# sourceMappingURL=cookies.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookies.cjs","sources":["../../../src/utils/cookies.ts"],"sourcesContent":["import { AxiosHeaderValue } from \"axios\";\n\n/**\n * Extract the value of a specific cookie from Axios cookies.\n *\n * @param cookies - Axios cookies, can be a string or an array\n * @param cookieName - The name of the cookie to extract.\n */\nexport const extractCookie = (\n\tcookies: AxiosHeaderValue | undefined,\n\tcookieName: string,\n): string | undefined => {\n\tconst regex = new RegExp(`${cookieName}=([^;]+)`, \"i\"); // 'i' flag for case-insensitivity\n\n\tif (typeof cookies === \"string\") {\n\t\tconst match = cookies.match(regex);\n\n\t\treturn match ? match[1] : undefined;\n\t}\n\tif (cookies instanceof Array) {\n\t\tfor (const cookie of cookies) {\n\t\t\tconst match = cookie.match(regex);\n\t\t\tif (match) {\n\t\t\t\treturn match[1];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined;\n};\n"],"names":[],"mappings":";;AAQa,MAAA,gBAAgB,CAC5B,SACA,eACuB;AACvB,QAAM,QAAQ,IAAI,OAAO,GAAG,UAAU,YAAY,GAAG;AAEjD,MAAA,OAAO,YAAY,UAAU;AAC1B,UAAA,QAAQ,QAAQ,MAAM,KAAK;AAE1B,WAAA,QAAQ,MAAM,CAAC,IAAI;AAAA,EAC1B;AACD,MAAI,mBAAmB,OAAO;AAC7B,eAAW,UAAU,SAAS;AACvB,YAAA,QAAQ,OAAO,MAAM,KAAK;AAChC,UAAI,OAAO;AACV,eAAO,MAAM,CAAC;AAAA,MACd;AAAA,IACD;AAAA,EACD;AAEM,SAAA;AACR;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AxiosHeaderValue } from "axios";
|
|
2
|
+
/**
|
|
3
|
+
* Extract the value of a specific cookie from Axios cookies.
|
|
4
|
+
*
|
|
5
|
+
* @param cookies - Axios cookies, can be a string or an array
|
|
6
|
+
* @param cookieName - The name of the cookie to extract.
|
|
7
|
+
*/
|
|
8
|
+
export declare const extractCookie: (cookies: AxiosHeaderValue | undefined, cookieName: string) => string | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const extractCookie = (cookies, cookieName) => {
|
|
2
|
+
const regex = new RegExp(`${cookieName}=([^;]+)`, "i");
|
|
3
|
+
if (typeof cookies === "string") {
|
|
4
|
+
const match = cookies.match(regex);
|
|
5
|
+
return match ? match[1] : void 0;
|
|
6
|
+
}
|
|
7
|
+
if (cookies instanceof Array) {
|
|
8
|
+
for (const cookie of cookies) {
|
|
9
|
+
const match = cookie.match(regex);
|
|
10
|
+
if (match) {
|
|
11
|
+
return match[1];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return void 0;
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
extractCookie
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=cookies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookies.js","sources":["../../../src/utils/cookies.ts"],"sourcesContent":["import { AxiosHeaderValue } from \"axios\";\n\n/**\n * Extract the value of a specific cookie from Axios cookies.\n *\n * @param cookies - Axios cookies, can be a string or an array\n * @param cookieName - The name of the cookie to extract.\n */\nexport const extractCookie = (\n\tcookies: AxiosHeaderValue | undefined,\n\tcookieName: string,\n): string | undefined => {\n\tconst regex = new RegExp(`${cookieName}=([^;]+)`, \"i\"); // 'i' flag for case-insensitivity\n\n\tif (typeof cookies === \"string\") {\n\t\tconst match = cookies.match(regex);\n\n\t\treturn match ? match[1] : undefined;\n\t}\n\tif (cookies instanceof Array) {\n\t\tfor (const cookie of cookies) {\n\t\t\tconst match = cookie.match(regex);\n\t\t\tif (match) {\n\t\t\t\treturn match[1];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined;\n};\n"],"names":[],"mappings":"AAQa,MAAA,gBAAgB,CAC5B,SACA,eACuB;AACvB,QAAM,QAAQ,IAAI,OAAO,GAAG,UAAU,YAAY,GAAG;AAEjD,MAAA,OAAO,YAAY,UAAU;AAC1B,UAAA,QAAQ,QAAQ,MAAM,KAAK;AAE1B,WAAA,QAAQ,MAAM,CAAC,IAAI;AAAA,EAC1B;AACD,MAAI,mBAAmB,OAAO;AAC7B,eAAW,UAAU,SAAS;AACvB,YAAA,QAAQ,OAAO,MAAM,KAAK;AAChC,UAAI,OAAO;AACV,eAAO,MAAM,CAAC;AAAA,MACd;AAAA,IACD;AAAA,EACD;AAEM,SAAA;AACR;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
class EnvVariableManager {
|
|
10
|
+
constructor(variableName) {
|
|
11
|
+
__publicField(this, "variableName");
|
|
12
|
+
this.variableName = variableName;
|
|
13
|
+
}
|
|
14
|
+
/** add a string and persist it in the environment variable */
|
|
15
|
+
add(value) {
|
|
16
|
+
const existingValues = this.getAll();
|
|
17
|
+
existingValues.push(value);
|
|
18
|
+
this.setAll(existingValues);
|
|
19
|
+
}
|
|
20
|
+
/** remove a string from the environment variable */
|
|
21
|
+
remove(value) {
|
|
22
|
+
const existingValues = this.getAll();
|
|
23
|
+
const updatedValues = existingValues.filter((item) => item !== value);
|
|
24
|
+
this.setAll(updatedValues);
|
|
25
|
+
}
|
|
26
|
+
/** return all items stored in the environment variable */
|
|
27
|
+
getAll() {
|
|
28
|
+
const value = process.env[this.variableName] || "[]";
|
|
29
|
+
return JSON.parse(value);
|
|
30
|
+
}
|
|
31
|
+
setAll(values) {
|
|
32
|
+
process.env[this.variableName] = JSON.stringify(values);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.EnvVariableManager = EnvVariableManager;
|
|
36
|
+
//# sourceMappingURL=envVariableManager.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envVariableManager.cjs","sources":["../../../src/utils/envVariableManager.ts"],"sourcesContent":["/**\n * Manage a list of strings within an environment variable. This is useful to\n * share data across different test phases (setup, teardown, test execution) as\n * most test frameworks run these in independent states\n */\nexport class EnvVariableManager {\n\tconstructor(private variableName: string) {}\n\n\t/** add a string and persist it in the environment variable */\n\tadd(value: string): void {\n\t\tconst existingValues = this.getAll();\n\t\texistingValues.push(value);\n\n\t\tthis.setAll(existingValues);\n\t}\n\n\t/** remove a string from the environment variable */\n\tremove(value: string): void {\n\t\tconst existingValues = this.getAll();\n\t\tconst updatedValues = existingValues.filter((item) => item !== value);\n\n\t\tthis.setAll(updatedValues);\n\t}\n\n\t/** return all items stored in the environment variable */\n\tgetAll(): string[] {\n\t\tconst value = process.env[this.variableName] || \"[]\";\n\n\t\treturn JSON.parse(value);\n\t}\n\n\tprivate setAll(values: string[]): void {\n\t\tprocess.env[this.variableName] = JSON.stringify(values);\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;MAKa,mBAAkB;AAAA,EAC9B,YAAoB,cAAoB;AAApB;AAAA,SAAY,eAAZ;AAAA,EAAuB;AAAA;AAAA,EAG3C,IAAI,OAAa;AACV,UAAA,iBAAiB,KAAK;AAC5B,mBAAe,KAAK,KAAK;AAEzB,SAAK,OAAO,cAAc;AAAA,EAC3B;AAAA;AAAA,EAGA,OAAO,OAAa;AACb,UAAA,iBAAiB,KAAK;AAC5B,UAAM,gBAAgB,eAAe,OAAO,CAAC,SAAS,SAAS,KAAK;AAEpE,SAAK,OAAO,aAAa;AAAA,EAC1B;AAAA;AAAA,EAGA,SAAM;AACL,UAAM,QAAQ,QAAQ,IAAI,KAAK,YAAY,KAAK;AAEzC,WAAA,KAAK,MAAM,KAAK;AAAA,EACxB;AAAA,EAEQ,OAAO,QAAgB;AAC9B,YAAQ,IAAI,KAAK,YAAY,IAAI,KAAK,UAAU,MAAM;AAAA,EACvD;AACA;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manage a list of strings within an environment variable. This is useful to
|
|
3
|
+
* share data across different test phases (setup, teardown, test execution) as
|
|
4
|
+
* most test frameworks run these in independent states
|
|
5
|
+
*/
|
|
6
|
+
export declare class EnvVariableManager {
|
|
7
|
+
private variableName;
|
|
8
|
+
constructor(variableName: string);
|
|
9
|
+
/** add a string and persist it in the environment variable */
|
|
10
|
+
add(value: string): void;
|
|
11
|
+
/** remove a string from the environment variable */
|
|
12
|
+
remove(value: string): void;
|
|
13
|
+
/** return all items stored in the environment variable */
|
|
14
|
+
getAll(): string[];
|
|
15
|
+
private setAll;
|
|
16
|
+
}
|