@prismicio/e2e-tests-utils 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +16 -9
  2. package/dist/clients/apiClient.cjs +39 -0
  3. package/dist/clients/apiClient.cjs.map +1 -0
  4. package/dist/clients/apiClient.d.ts +30 -0
  5. package/dist/clients/apiClient.js +39 -0
  6. package/dist/clients/apiClient.js.map +1 -0
  7. package/dist/clients/authenticationApi.cjs +54 -34
  8. package/dist/clients/authenticationApi.cjs.map +1 -1
  9. package/dist/clients/authenticationApi.d.ts +13 -5
  10. package/dist/clients/authenticationApi.js +55 -35
  11. package/dist/clients/authenticationApi.js.map +1 -1
  12. package/dist/clients/contentApi.cjs +12 -48
  13. package/dist/clients/contentApi.cjs.map +1 -1
  14. package/dist/clients/contentApi.d.ts +5 -6
  15. package/dist/clients/contentApi.js +12 -48
  16. package/dist/clients/contentApi.js.map +1 -1
  17. package/dist/clients/coreApi.cjs +36 -31
  18. package/dist/clients/coreApi.cjs.map +1 -1
  19. package/dist/clients/coreApi.d.ts +21 -3
  20. package/dist/clients/coreApi.js +37 -32
  21. package/dist/clients/coreApi.js.map +1 -1
  22. package/dist/clients/customTypesApi.cjs +48 -42
  23. package/dist/clients/customTypesApi.cjs.map +1 -1
  24. package/dist/clients/customTypesApi.d.ts +34 -6
  25. package/dist/clients/customTypesApi.js +49 -43
  26. package/dist/clients/customTypesApi.js.map +1 -1
  27. package/dist/clients/migrationApi.cjs +30 -29
  28. package/dist/clients/migrationApi.cjs.map +1 -1
  29. package/dist/clients/migrationApi.d.ts +25 -5
  30. package/dist/clients/migrationApi.js +31 -30
  31. package/dist/clients/migrationApi.js.map +1 -1
  32. package/dist/index.cjs +1 -1
  33. package/dist/index.js +2 -2
  34. package/dist/managers/repositories.cjs +19 -9
  35. package/dist/managers/repositories.cjs.map +1 -1
  36. package/dist/managers/repositories.d.ts +2 -2
  37. package/dist/managers/repositories.js +23 -13
  38. package/dist/managers/repositories.js.map +1 -1
  39. package/dist/managers/repository.cjs +5 -0
  40. package/dist/managers/repository.cjs.map +1 -1
  41. package/dist/managers/repository.d.ts +6 -4
  42. package/dist/managers/repository.js +5 -0
  43. package/dist/managers/repository.js.map +1 -1
  44. package/dist/utils/log.cjs +4 -0
  45. package/dist/utils/log.cjs.map +1 -1
  46. package/dist/utils/log.d.ts +2 -0
  47. package/dist/utils/log.js +4 -0
  48. package/dist/utils/log.js.map +1 -1
  49. package/package.json +1 -1
  50. package/src/clients/apiClient.ts +48 -0
  51. package/src/clients/authenticationApi.ts +52 -50
  52. package/src/clients/contentApi.ts +18 -24
  53. package/src/clients/coreApi.ts +36 -42
  54. package/src/clients/customTypesApi.ts +34 -59
  55. package/src/clients/migrationApi.ts +33 -45
  56. package/src/managers/repositories.ts +26 -20
  57. package/src/managers/repository.ts +17 -7
  58. package/src/utils/log.ts +11 -0
@@ -1,44 +1,43 @@
1
- import axios from "axios";
2
1
  import isEqual from "lodash.isequal";
3
- import { logger, logHttpResponse } from "../utils/log.js";
4
- const createCustomTypesApiClient = (baseURL, repository, authClient) => {
5
- const client = axios.create({
6
- baseURL,
7
- validateStatus: () => true,
8
- // Don't throw on 4XX errors
9
- headers: {
10
- repository
11
- }
12
- });
13
- client.interceptors.request.use(async (config) => {
14
- const auth = "Authorization";
15
- if (!config.headers[auth]) {
16
- const token = await authClient.getToken();
17
- config.headers[auth] = `Bearer ${token}`;
18
- }
19
- return config;
20
- });
21
- async function upsert(endpoint, operation, data) {
2
+ import { logger, logPlaywrightApiResponse } from "../utils/log.js";
3
+ import { AuthenticatedApiClient } from "./apiClient.js";
4
+ class CustomTypesApiClient extends AuthenticatedApiClient {
5
+ constructor(baseURL, config) {
6
+ super(baseURL, config.authToken, { repository: config.repository });
7
+ }
8
+ /**
9
+ * Create or update a custom type or slice.
10
+ *
11
+ * @param endpoint - - The API endpoint for custom types or slices
12
+ * ('customtypes' or 'slices').
13
+ * @param data - - The data representing the custom type or slice.
14
+ *
15
+ * @throws Error if the item status cannot be retrieved or the item cannot be
16
+ * created/updated.
17
+ */
18
+ async upsert(endpoint, operation, data) {
22
19
  const profiler = logger.startTimer();
23
20
  const path = `${endpoint}/${operation}`;
24
- const result = await client.post(path, data, { headers: {} });
25
- if (![201, 204].includes(result.status)) {
26
- logHttpResponse(result);
21
+ const context = await this.getContext();
22
+ const result = await context.post(path, { data });
23
+ if (!result.ok()) {
24
+ logPlaywrightApiResponse(result);
27
25
  throw new Error(`Could not ${operation} item`);
28
26
  }
29
27
  profiler.done({
30
28
  message: `called customtypes api /${path} for item with id '${data.id}'`
31
29
  });
32
30
  }
33
- async function getRemoteItems(endpoint) {
34
- const result = await client.get(endpoint);
35
- if (![200].includes(result.status)) {
36
- logHttpResponse(result);
31
+ async getRemoteItems(endpoint) {
32
+ const context = await this.getContext();
33
+ const result = await context.get(endpoint);
34
+ if (!result.ok()) {
35
+ logPlaywrightApiResponse(result);
37
36
  throw new Error("Could not get items status from the Custom Type api.");
38
37
  }
39
- return result.data;
38
+ return result.json();
40
39
  }
41
- async function getDifference(remoteItems, local) {
40
+ async getDifference(remoteItems, local) {
42
41
  const remoteItem = remoteItems.find((remote) => remote.id === local.id);
43
42
  if (!remoteItem) {
44
43
  return "insert";
@@ -48,25 +47,32 @@ const createCustomTypesApiClient = (baseURL, repository, authClient) => {
48
47
  }
49
48
  return;
50
49
  }
51
- async function upsertIfChanged(itemType, localItems = []) {
52
- const remoteItems = await getRemoteItems(itemType);
50
+ /** Create items only if they have changed compared to their remote status */
51
+ async upsertIfChanged(itemType, localItems = []) {
52
+ const remoteItems = await this.getRemoteItems(itemType);
53
53
  await Promise.all(localItems.map(async (localItem) => {
54
- const operation = await getDifference(remoteItems, localItem);
55
- return operation && upsert(itemType, operation, localItem);
54
+ const operation = await this.getDifference(remoteItems, localItem);
55
+ return operation && this.upsert(itemType, operation, localItem);
56
56
  }));
57
57
  }
58
- async function createCustomTypes(customTypes = []) {
59
- await upsertIfChanged("customtypes", customTypes);
58
+ /**
59
+ * Create Custom Types using the Custom types api.
60
+ *
61
+ * @param customTypes -
62
+ */
63
+ async createCustomTypes(customTypes = []) {
64
+ await this.upsertIfChanged("customtypes", customTypes);
60
65
  }
61
- async function createSlices(slices = []) {
62
- await upsertIfChanged("slices", slices);
66
+ /**
67
+ * Create slices using the Custom types api.
68
+ *
69
+ * @param slices -
70
+ */
71
+ async createSlices(slices = []) {
72
+ await this.upsertIfChanged("slices", slices);
63
73
  }
64
- return {
65
- createCustomTypes,
66
- createSlices
67
- };
68
- };
74
+ }
69
75
  export {
70
- createCustomTypesApiClient
76
+ CustomTypesApiClient
71
77
  };
72
78
  //# sourceMappingURL=customTypesApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"customTypesApi.js","sources":["../../../src/clients/customTypesApi.ts"],"sourcesContent":["import axios, { AxiosInstance } from \"axios\";\nimport isEqual from \"lodash.isequal\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { logHttpResponse, logger } from \"../utils/log\";\n\nimport { AuthenticationClient } from \"./authenticationApi\";\n\nexport type CustomTypesClient = {\n\tcreateCustomTypes(customTypes: CustomType[]): Promise<void>;\n\tcreateSlices(slices: SharedSlice[]): Promise<void>;\n};\n\n/**\n * Client for interacting with the Custom Types API to create/update custom\n * types and slices.\n */\nexport const createCustomTypesApiClient = (\n\tbaseURL: string,\n\trepository: string,\n\tauthClient: AuthenticationClient,\n): CustomTypesClient => {\n\ttype ItemType = CustomType | SharedSlice;\n\ttype ItemTypePath = \"customtypes\" | \"slices\";\n\ttype ItemOperation = \"insert\" | \"update\";\n\n\tconst client: AxiosInstance = axios.create({\n\t\tbaseURL,\n\t\tvalidateStatus: () => true, // Don't throw on 4XX errors\n\t\theaders: {\n\t\t\trepository,\n\t\t},\n\t});\n\n\t// Add an interceptor to authenticate requests\n\tclient.interceptors.request.use(async (config) => {\n\t\tconst auth = \"Authorization\";\n\t\tif (!config.headers[auth]) {\n\t\t\tconst token = await authClient.getToken();\n\t\t\tconfig.headers[auth] = `Bearer ${token}`;\n\t\t}\n\n\t\treturn config;\n\t});\n\n\t/**\n\t * Create or update a custom type or slice.\n\t *\n\t * @param endpoint - - The API endpoint for custom types or slices\n\t * ('customtypes' or 'slices').\n\t * @param data - - The data representing the custom type or slice.\n\t *\n\t * @throws Error if the item status cannot be retrieved or the item cannot be\n\t * created/updated.\n\t */\n\tasync function upsert(\n\t\tendpoint: ItemTypePath,\n\t\toperation: ItemOperation,\n\t\tdata: ItemType,\n\t) {\n\t\tconst profiler = logger.startTimer();\n\t\tconst path = `${endpoint}/${operation}`;\n\n\t\tconst result = await client.post(path, data, { headers: {} });\n\t\tif (![201, 204].includes(result.status)) {\n\t\t\tlogHttpResponse(result);\n\t\t\tthrow new Error(`Could not ${operation} item`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `called customtypes api /${path} for item with id '${data.id}'`,\n\t\t});\n\t}\n\n\tasync function getRemoteItems(\n\t\tendpoint: ItemTypePath,\n\t): Promise<CustomType[] | SharedSlice[]> {\n\t\tconst result = await client.get(endpoint);\n\n\t\tif (![200].includes(result.status)) {\n\t\t\tlogHttpResponse(result);\n\t\t\tthrow new Error(\"Could not get items status from the Custom Type api.\");\n\t\t}\n\n\t\treturn result.data;\n\t}\n\n\tasync function getDifference(\n\t\tremoteItems: CustomType[] | SharedSlice[],\n\t\tlocal: ItemType,\n\t): Promise<ItemOperation | undefined> {\n\t\tconst remoteItem = remoteItems.find(\n\t\t\t(remote: CustomType | SharedSlice) => remote.id === local.id,\n\t\t);\n\t\tif (!remoteItem) {\n\t\t\treturn \"insert\";\n\t\t}\n\t\tif (!isEqual(local, remoteItem)) {\n\t\t\treturn \"update\";\n\t\t}\n\n\t\treturn;\n\t}\n\n\t/** Create items only if they have changed compared to their remote status */\n\tasync function upsertIfChanged(\n\t\titemType: ItemTypePath,\n\t\tlocalItems: ItemType[] = [],\n\t) {\n\t\tconst remoteItems = await getRemoteItems(itemType);\n\t\tawait Promise.all(\n\t\t\tlocalItems.map(async (localItem) => {\n\t\t\t\tconst operation = await getDifference(remoteItems, localItem);\n\n\t\t\t\treturn operation && upsert(itemType, operation, localItem);\n\t\t\t}),\n\t\t);\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 function createCustomTypes(customTypes: CustomType[] = []) {\n\t\tawait upsertIfChanged(\"customtypes\", 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 function createSlices(slices: SharedSlice[] = []) {\n\t\tawait upsertIfChanged(\"slices\", slices);\n\t}\n\n\treturn {\n\t\tcreateCustomTypes,\n\t\tcreateSlices,\n\t};\n};\n"],"names":[],"mappings":";;;AAqBO,MAAM,6BAA6B,CACzC,SACA,YACA,eACsB;AAKhB,QAAA,SAAwB,MAAM,OAAO;AAAA,IAC1C;AAAA,IACA,gBAAgB,MAAM;AAAA;AAAA,IACtB,SAAS;AAAA,MACR;AAAA,IACA;AAAA,EAAA,CACD;AAGD,SAAO,aAAa,QAAQ,IAAI,OAAO,WAAU;AAChD,UAAM,OAAO;AACb,QAAI,CAAC,OAAO,QAAQ,IAAI,GAAG;AACpB,YAAA,QAAQ,MAAM,WAAW;AAC/B,aAAO,QAAQ,IAAI,IAAI,UAAU,KAAK;AAAA,IACvC;AAEO,WAAA;AAAA,EAAA,CACP;AAYc,iBAAA,OACd,UACA,WACA,MAAc;AAER,UAAA,WAAW,OAAO;AACxB,UAAM,OAAO,GAAG,QAAQ,IAAI,SAAS;AAE/B,UAAA,SAAS,MAAM,OAAO,KAAK,MAAM,MAAM,EAAE,SAAS,CAAE,EAAA,CAAE;AACxD,QAAA,CAAC,CAAC,KAAK,GAAG,EAAE,SAAS,OAAO,MAAM,GAAG;AACxC,sBAAgB,MAAM;AACtB,YAAM,IAAI,MAAM,aAAa,SAAS,OAAO;AAAA,IAC9C;AACA,aAAS,KAAK;AAAA,MACb,SAAS,2BAA2B,IAAI,sBAAsB,KAAK,EAAE;AAAA,IAAA,CACrE;AAAA,EACF;AAEA,iBAAe,eACd,UAAsB;AAEtB,UAAM,SAAS,MAAM,OAAO,IAAI,QAAQ;AAExC,QAAI,CAAC,CAAC,GAAG,EAAE,SAAS,OAAO,MAAM,GAAG;AACnC,sBAAgB,MAAM;AAChB,YAAA,IAAI,MAAM,sDAAsD;AAAA,IACvE;AAEA,WAAO,OAAO;AAAA,EACf;AAEe,iBAAA,cACd,aACA,OAAe;AAET,UAAA,aAAa,YAAY,KAC9B,CAAC,WAAqC,OAAO,OAAO,MAAM,EAAE;AAE7D,QAAI,CAAC,YAAY;AACT,aAAA;AAAA,IACR;AACA,QAAI,CAAC,QAAQ,OAAO,UAAU,GAAG;AACzB,aAAA;AAAA,IACR;AAEA;AAAA,EACD;AAGA,iBAAe,gBACd,UACA,aAAyB,IAAE;AAErB,UAAA,cAAc,MAAM,eAAe,QAAQ;AACjD,UAAM,QAAQ,IACb,WAAW,IAAI,OAAO,cAAa;AAClC,YAAM,YAAY,MAAM,cAAc,aAAa,SAAS;AAE5D,aAAO,aAAa,OAAO,UAAU,WAAW,SAAS;AAAA,IACzD,CAAA,CAAC;AAAA,EAEJ;AAOe,iBAAA,kBAAkB,cAA4B,IAAE;AACxD,UAAA,gBAAgB,eAAe,WAAW;AAAA,EACjD;AAOe,iBAAA,aAAa,SAAwB,IAAE;AAC/C,UAAA,gBAAgB,UAAU,MAAM;AAAA,EACvC;AAEO,SAAA;AAAA,IACN;AAAA,IACA;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"customTypesApi.js","sources":["../../../src/clients/customTypesApi.ts"],"sourcesContent":["import isEqual from \"lodash.isequal\";\n\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\n\nimport { logPlaywrightApiResponse, logger } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\ntype ItemType = CustomType | SharedSlice;\ntype ItemTypePath = \"customtypes\" | \"slices\";\ntype ItemOperation = \"insert\" | \"update\";\n\n/**\n * Client for interacting with the Custom Types API to create/update custom\n * types and slices.\n */\nexport class CustomTypesApiClient extends AuthenticatedApiClient {\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { authToken: AuthServerToken; repository: string },\n\t) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository });\n\t}\n\n\t/**\n\t * Create or update a custom type or slice.\n\t *\n\t * @param endpoint - - The API endpoint for custom types or slices\n\t * ('customtypes' or 'slices').\n\t * @param data - - The data representing the custom type or slice.\n\t *\n\t * @throws Error if the item status cannot be retrieved or the item cannot be\n\t * created/updated.\n\t */\n\tprivate async upsert(\n\t\tendpoint: ItemTypePath,\n\t\toperation: ItemOperation,\n\t\tdata: ItemType,\n\t) {\n\t\tconst profiler = logger.startTimer();\n\t\tconst path = `${endpoint}/${operation}`;\n\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.post(path, { data });\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result);\n\t\t\tthrow new Error(`Could not ${operation} item`);\n\t\t}\n\t\tprofiler.done({\n\t\t\tmessage: `called customtypes api /${path} for item with id '${data.id}'`,\n\t\t});\n\t}\n\n\tprivate async getRemoteItems(\n\t\tendpoint: ItemTypePath,\n\t): Promise<CustomType[] | SharedSlice[]> {\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.get(endpoint);\n\n\t\tif (!result.ok()) {\n\t\t\tlogPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not get items status from the Custom Type api.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n\n\tprivate async getDifference(\n\t\tremoteItems: CustomType[] | SharedSlice[],\n\t\tlocal: ItemType,\n\t): Promise<ItemOperation | undefined> {\n\t\tconst remoteItem = remoteItems.find(\n\t\t\t(remote: CustomType | SharedSlice) => remote.id === local.id,\n\t\t);\n\t\tif (!remoteItem) {\n\t\t\treturn \"insert\";\n\t\t}\n\t\tif (!isEqual(local, remoteItem)) {\n\t\t\treturn \"update\";\n\t\t}\n\n\t\treturn;\n\t}\n\n\t/** Create items only if they have changed compared to their remote status */\n\tprivate async upsertIfChanged(\n\t\titemType: ItemTypePath,\n\t\tlocalItems: ItemType[] = [],\n\t): Promise<void> {\n\t\tconst remoteItems = await this.getRemoteItems(itemType);\n\t\tawait Promise.all(\n\t\t\tlocalItems.map(async (localItem) => {\n\t\t\t\tconst operation = await this.getDifference(remoteItems, localItem);\n\n\t\t\t\treturn operation && this.upsert(itemType, operation, localItem);\n\t\t\t}),\n\t\t);\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.upsertIfChanged(\"customtypes\", 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.upsertIfChanged(\"slices\", slices);\n\t}\n}\n"],"names":[],"mappings":";;;AAmBM,MAAO,6BAA6B,uBAAsB;AAAA,EAC/D,YACC,SACA,QAA0D;AAE1D,UAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,YAAY;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYQ,MAAM,OACb,UACA,WACA,MAAc;AAER,UAAA,WAAW,OAAO;AACxB,UAAM,OAAO,GAAG,QAAQ,IAAI,SAAS;AAE/B,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,KAAK,MAAM,EAAE,MAAM;AAC5C,QAAA,CAAC,OAAO,MAAM;AACjB,+BAAyB,MAAM;AAC/B,YAAM,IAAI,MAAM,aAAa,SAAS,OAAO;AAAA,IAC9C;AACA,aAAS,KAAK;AAAA,MACb,SAAS,2BAA2B,IAAI,sBAAsB,KAAK,EAAE;AAAA,IAAA,CACrE;AAAA,EACF;AAAA,EAEQ,MAAM,eACb,UAAsB;AAEhB,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,IAAI,QAAQ;AAErC,QAAA,CAAC,OAAO,MAAM;AACjB,+BAAyB,MAAM;AACzB,YAAA,IAAI,MAAM,sDAAsD;AAAA,IACvE;AAEA,WAAO,OAAO;EACf;AAAA,EAEQ,MAAM,cACb,aACA,OAAe;AAET,UAAA,aAAa,YAAY,KAC9B,CAAC,WAAqC,OAAO,OAAO,MAAM,EAAE;AAE7D,QAAI,CAAC,YAAY;AACT,aAAA;AAAA,IACR;AACA,QAAI,CAAC,QAAQ,OAAO,UAAU,GAAG;AACzB,aAAA;AAAA,IACR;AAEA;AAAA,EACD;AAAA;AAAA,EAGQ,MAAM,gBACb,UACA,aAAyB,IAAE;AAE3B,UAAM,cAAc,MAAM,KAAK,eAAe,QAAQ;AACtD,UAAM,QAAQ,IACb,WAAW,IAAI,OAAO,cAAa;AAClC,YAAM,YAAY,MAAM,KAAK,cAAc,aAAa,SAAS;AAEjE,aAAO,aAAa,KAAK,OAAO,UAAU,WAAW,SAAS;AAAA,IAC9D,CAAA,CAAC;AAAA,EAEJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,kBAAkB,cAA4B,IAAE;AAC/C,UAAA,KAAK,gBAAgB,eAAe,WAAW;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,SAAwB,IAAE;AACtC,UAAA,KAAK,gBAAgB,UAAU,MAAM;AAAA,EAC5C;AACA;"}
@@ -1,36 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const axios = require("axios");
4
3
  const log = require("../utils/log.cjs");
5
- const createMigrationApiClient = (baseURL, repository, authClient) => {
6
- const client = axios.create({
7
- baseURL,
8
- headers: {
9
- repository
10
- },
11
- validateStatus: () => true
12
- // Don't throw on 4XX errors
13
- });
14
- client.interceptors.request.use(async (config) => {
15
- const auth = "Authorization";
16
- if (!config.headers[auth]) {
17
- const token = await authClient.getToken();
18
- config.headers[auth] = `Bearer ${token}`;
19
- }
20
- config.headers["repository"] = repository;
21
- return config;
22
- });
23
- async function createDocument(data) {
24
- const result = await client.post("/documents", data);
25
- if (201 !== result.status) {
26
- log.logHttpResponse(result);
4
+ const apiClient = require("./apiClient.cjs");
5
+ class MigrationApiClient extends apiClient.AuthenticatedApiClient {
6
+ /**
7
+ * @example To instantiate the class:
8
+ *
9
+ * ```js
10
+ * new MigrationApiClient("https://migration.prismic.io", {
11
+ * authToken: "my-secret-token",
12
+ * repository: "my-repo-name",
13
+ * });
14
+ * ```
15
+ *
16
+ * @param baseURL - the api base URL like https://migration.prismic.io
17
+ * @param config - Optional configuration
18
+ *
19
+ * - {@link config.authToken}: Api token generated from the auth service or a
20
+ * function to fetch it when it's needed.
21
+ * - {@link config.repository}: Repository name.
22
+ */
23
+ constructor(baseURL, config) {
24
+ super(baseURL, config.authToken, { repository: config.repository });
25
+ }
26
+ async createDocument(data) {
27
+ const context = await this.getContext();
28
+ const result = await context.post("documents", { data });
29
+ if (201 !== result.status()) {
30
+ await log.logPlaywrightApiResponse(result);
27
31
  throw new Error("Could not create a document with the migration api.");
28
32
  }
29
- return result.data;
33
+ return result.json();
30
34
  }
31
- return {
32
- createDocument
33
- };
34
- };
35
- exports.createMigrationApiClient = createMigrationApiClient;
35
+ }
36
+ exports.MigrationApiClient = MigrationApiClient;
36
37
  //# sourceMappingURL=migrationApi.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrationApi.cjs","sources":["../../../src/clients/migrationApi.ts"],"sourcesContent":["import axios, { AxiosInstance } from \"axios\";\n\nimport { logHttpResponse } from \"../utils/log\";\n\nimport { AuthenticationClient } from \"./authenticationApi\";\n\nexport type MigrationClient = {\n\tcreateDocument(data: DocumentPayload): Promise<DocumentResponse>;\n};\n\nexport type DocumentPayload = {\n\tuid?: string | null;\n\ttype: string;\n\tlang: string;\n\ttitle: string;\n\ttags?: string[];\n\talternate_language_id?: string;\n\tdata: Record<string, unknown>;\n\t// if true, the document will be part of the documents list instead of in the migration release\n\tinDocuments?: boolean;\n};\n\nexport type DocumentResponse = {\n\tid: string;\n\ttype: string;\n\tlang: string;\n\ttitle: string;\n\tuid?: string;\n};\n\nexport const createMigrationApiClient = (\n\tbaseURL: string,\n\trepository: string,\n\tauthClient: AuthenticationClient,\n): MigrationClient => {\n\tconst client: AxiosInstance = axios.create({\n\t\tbaseURL,\n\t\theaders: {\n\t\t\trepository,\n\t\t},\n\t\tvalidateStatus: () => true, // Don't throw on 4XX errors\n\t});\n\n\t// Add an interceptor to authenticate requests\n\tclient.interceptors.request.use(async (config) => {\n\t\tconst auth = \"Authorization\";\n\t\tif (!config.headers[auth]) {\n\t\t\tconst token = await authClient.getToken();\n\t\t\tconfig.headers[auth] = `Bearer ${token}`;\n\t\t}\n\t\tconfig.headers[\"repository\"] = repository;\n\n\t\treturn config;\n\t});\n\n\tasync function createDocument(\n\t\tdata: DocumentPayload,\n\t): Promise<DocumentResponse> {\n\t\tconst result = await client.post<DocumentResponse>(\"/documents\", data);\n\n\t\tif (201 !== result.status) {\n\t\t\tlogHttpResponse(result);\n\t\t\tthrow new Error(\"Could not create a document with the migration api.\");\n\t\t}\n\n\t\treturn result.data;\n\t}\n\n\treturn {\n\t\tcreateDocument,\n\t};\n};\n"],"names":["logHttpResponse"],"mappings":";;;;AA8BO,MAAM,2BAA2B,CACvC,SACA,YACA,eACoB;AACd,QAAA,SAAwB,MAAM,OAAO;AAAA,IAC1C;AAAA,IACA,SAAS;AAAA,MACR;AAAA,IACA;AAAA,IACD,gBAAgB,MAAM;AAAA;AAAA,EAAA,CACtB;AAGD,SAAO,aAAa,QAAQ,IAAI,OAAO,WAAU;AAChD,UAAM,OAAO;AACb,QAAI,CAAC,OAAO,QAAQ,IAAI,GAAG;AACpB,YAAA,QAAQ,MAAM,WAAW;AAC/B,aAAO,QAAQ,IAAI,IAAI,UAAU,KAAK;AAAA,IACvC;AACO,WAAA,QAAQ,YAAY,IAAI;AAExB,WAAA;AAAA,EAAA,CACP;AAED,iBAAe,eACd,MAAqB;AAErB,UAAM,SAAS,MAAM,OAAO,KAAuB,cAAc,IAAI;AAEjE,QAAA,QAAQ,OAAO,QAAQ;AAC1BA,UAAA,gBAAgB,MAAM;AAChB,YAAA,IAAI,MAAM,qDAAqD;AAAA,IACtE;AAEA,WAAO,OAAO;AAAA,EACf;AAEO,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;;"}
1
+ {"version":3,"file":"migrationApi.cjs","sources":["../../../src/clients/migrationApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\nexport type DocumentPayload = {\n\tuid?: string | null;\n\ttype: string;\n\tlang: string;\n\ttitle: string;\n\ttags?: string[];\n\talternate_language_id?: string;\n\tdata: Record<string, unknown>;\n\t// if true, the document will be part of the documents list instead of in the migration release\n\tinDocuments?: boolean;\n};\nexport type DocumentResponse = {\n\tid: string;\n\ttype: string;\n\tlang: string;\n\ttitle: string;\n\tuid?: string;\n};\n\nexport class MigrationApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new MigrationApiClient(\"https://migration.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \trepository: \"my-repo-name\",\n\t * });\n\t * ```\n\t *\n\t * @param baseURL - the api base URL like https://migration.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.authToken}: Api token generated from the auth service or a\n\t * function to fetch it when it's needed.\n\t * - {@link config.repository}: Repository name.\n\t */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { authToken: AuthServerToken; repository: string },\n\t) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository });\n\t}\n\n\tasync createDocument(data: DocumentPayload): Promise<DocumentResponse> {\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.post(\"documents\", { data });\n\n\t\tif (201 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not create a document with the migration api.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n}\n"],"names":["AuthenticatedApiClient","logPlaywrightApiResponse"],"mappings":";;;;AAuBM,MAAO,2BAA2BA,UAAAA,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkB7D,YACC,SACA,QAA0D;AAE1D,UAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,YAAY;AAAA,EACnE;AAAA,EAEA,MAAM,eAAe,MAAqB;AACnC,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,KAAK,aAAa,EAAE,MAAM;AAEnD,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAMC,IAAAA,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,qDAAqD;AAAA,IACtE;AAEA,WAAO,OAAO;EACf;AACA;;"}
@@ -1,7 +1,4 @@
1
- import { AuthenticationClient } from "./authenticationApi";
2
- export type MigrationClient = {
3
- createDocument(data: DocumentPayload): Promise<DocumentResponse>;
4
- };
1
+ import { AuthServerToken, AuthenticatedApiClient } from "./apiClient";
5
2
  export type DocumentPayload = {
6
3
  uid?: string | null;
7
4
  type: string;
@@ -19,4 +16,27 @@ export type DocumentResponse = {
19
16
  title: string;
20
17
  uid?: string;
21
18
  };
22
- export declare const createMigrationApiClient: (baseURL: string, repository: string, authClient: AuthenticationClient) => MigrationClient;
19
+ export declare class MigrationApiClient extends AuthenticatedApiClient {
20
+ /**
21
+ * @example To instantiate the class:
22
+ *
23
+ * ```js
24
+ * new MigrationApiClient("https://migration.prismic.io", {
25
+ * authToken: "my-secret-token",
26
+ * repository: "my-repo-name",
27
+ * });
28
+ * ```
29
+ *
30
+ * @param baseURL - the api base URL like https://migration.prismic.io
31
+ * @param config - Optional configuration
32
+ *
33
+ * - {@link config.authToken}: Api token generated from the auth service or a
34
+ * function to fetch it when it's needed.
35
+ * - {@link config.repository}: Repository name.
36
+ */
37
+ constructor(baseURL: string, config: {
38
+ authToken: AuthServerToken;
39
+ repository: string;
40
+ });
41
+ createDocument(data: DocumentPayload): Promise<DocumentResponse>;
42
+ }
@@ -1,36 +1,37 @@
1
- import axios from "axios";
2
- import { logHttpResponse } from "../utils/log.js";
3
- const createMigrationApiClient = (baseURL, repository, authClient) => {
4
- const client = axios.create({
5
- baseURL,
6
- headers: {
7
- repository
8
- },
9
- validateStatus: () => true
10
- // Don't throw on 4XX errors
11
- });
12
- client.interceptors.request.use(async (config) => {
13
- const auth = "Authorization";
14
- if (!config.headers[auth]) {
15
- const token = await authClient.getToken();
16
- config.headers[auth] = `Bearer ${token}`;
17
- }
18
- config.headers["repository"] = repository;
19
- return config;
20
- });
21
- async function createDocument(data) {
22
- const result = await client.post("/documents", data);
23
- if (201 !== result.status) {
24
- logHttpResponse(result);
1
+ import { logPlaywrightApiResponse } from "../utils/log.js";
2
+ import { AuthenticatedApiClient } from "./apiClient.js";
3
+ class MigrationApiClient extends AuthenticatedApiClient {
4
+ /**
5
+ * @example To instantiate the class:
6
+ *
7
+ * ```js
8
+ * new MigrationApiClient("https://migration.prismic.io", {
9
+ * authToken: "my-secret-token",
10
+ * repository: "my-repo-name",
11
+ * });
12
+ * ```
13
+ *
14
+ * @param baseURL - the api base URL like https://migration.prismic.io
15
+ * @param config - Optional configuration
16
+ *
17
+ * - {@link config.authToken}: Api token generated from the auth service or a
18
+ * function to fetch it when it's needed.
19
+ * - {@link config.repository}: Repository name.
20
+ */
21
+ constructor(baseURL, config) {
22
+ super(baseURL, config.authToken, { repository: config.repository });
23
+ }
24
+ async createDocument(data) {
25
+ const context = await this.getContext();
26
+ const result = await context.post("documents", { data });
27
+ if (201 !== result.status()) {
28
+ await logPlaywrightApiResponse(result);
25
29
  throw new Error("Could not create a document with the migration api.");
26
30
  }
27
- return result.data;
31
+ return result.json();
28
32
  }
29
- return {
30
- createDocument
31
- };
32
- };
33
+ }
33
34
  export {
34
- createMigrationApiClient
35
+ MigrationApiClient
35
36
  };
36
37
  //# sourceMappingURL=migrationApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrationApi.js","sources":["../../../src/clients/migrationApi.ts"],"sourcesContent":["import axios, { AxiosInstance } from \"axios\";\n\nimport { logHttpResponse } from \"../utils/log\";\n\nimport { AuthenticationClient } from \"./authenticationApi\";\n\nexport type MigrationClient = {\n\tcreateDocument(data: DocumentPayload): Promise<DocumentResponse>;\n};\n\nexport type DocumentPayload = {\n\tuid?: string | null;\n\ttype: string;\n\tlang: string;\n\ttitle: string;\n\ttags?: string[];\n\talternate_language_id?: string;\n\tdata: Record<string, unknown>;\n\t// if true, the document will be part of the documents list instead of in the migration release\n\tinDocuments?: boolean;\n};\n\nexport type DocumentResponse = {\n\tid: string;\n\ttype: string;\n\tlang: string;\n\ttitle: string;\n\tuid?: string;\n};\n\nexport const createMigrationApiClient = (\n\tbaseURL: string,\n\trepository: string,\n\tauthClient: AuthenticationClient,\n): MigrationClient => {\n\tconst client: AxiosInstance = axios.create({\n\t\tbaseURL,\n\t\theaders: {\n\t\t\trepository,\n\t\t},\n\t\tvalidateStatus: () => true, // Don't throw on 4XX errors\n\t});\n\n\t// Add an interceptor to authenticate requests\n\tclient.interceptors.request.use(async (config) => {\n\t\tconst auth = \"Authorization\";\n\t\tif (!config.headers[auth]) {\n\t\t\tconst token = await authClient.getToken();\n\t\t\tconfig.headers[auth] = `Bearer ${token}`;\n\t\t}\n\t\tconfig.headers[\"repository\"] = repository;\n\n\t\treturn config;\n\t});\n\n\tasync function createDocument(\n\t\tdata: DocumentPayload,\n\t): Promise<DocumentResponse> {\n\t\tconst result = await client.post<DocumentResponse>(\"/documents\", data);\n\n\t\tif (201 !== result.status) {\n\t\t\tlogHttpResponse(result);\n\t\t\tthrow new Error(\"Could not create a document with the migration api.\");\n\t\t}\n\n\t\treturn result.data;\n\t}\n\n\treturn {\n\t\tcreateDocument,\n\t};\n};\n"],"names":[],"mappings":";;AA8BO,MAAM,2BAA2B,CACvC,SACA,YACA,eACoB;AACd,QAAA,SAAwB,MAAM,OAAO;AAAA,IAC1C;AAAA,IACA,SAAS;AAAA,MACR;AAAA,IACA;AAAA,IACD,gBAAgB,MAAM;AAAA;AAAA,EAAA,CACtB;AAGD,SAAO,aAAa,QAAQ,IAAI,OAAO,WAAU;AAChD,UAAM,OAAO;AACb,QAAI,CAAC,OAAO,QAAQ,IAAI,GAAG;AACpB,YAAA,QAAQ,MAAM,WAAW;AAC/B,aAAO,QAAQ,IAAI,IAAI,UAAU,KAAK;AAAA,IACvC;AACO,WAAA,QAAQ,YAAY,IAAI;AAExB,WAAA;AAAA,EAAA,CACP;AAED,iBAAe,eACd,MAAqB;AAErB,UAAM,SAAS,MAAM,OAAO,KAAuB,cAAc,IAAI;AAEjE,QAAA,QAAQ,OAAO,QAAQ;AAC1B,sBAAgB,MAAM;AAChB,YAAA,IAAI,MAAM,qDAAqD;AAAA,IACtE;AAEA,WAAO,OAAO;AAAA,EACf;AAEO,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"migrationApi.js","sources":["../../../src/clients/migrationApi.ts"],"sourcesContent":["import { logPlaywrightApiResponse } from \"../utils/log\";\n\nimport { AuthServerToken, AuthenticatedApiClient } from \"./apiClient\";\n\nexport type DocumentPayload = {\n\tuid?: string | null;\n\ttype: string;\n\tlang: string;\n\ttitle: string;\n\ttags?: string[];\n\talternate_language_id?: string;\n\tdata: Record<string, unknown>;\n\t// if true, the document will be part of the documents list instead of in the migration release\n\tinDocuments?: boolean;\n};\nexport type DocumentResponse = {\n\tid: string;\n\ttype: string;\n\tlang: string;\n\ttitle: string;\n\tuid?: string;\n};\n\nexport class MigrationApiClient extends AuthenticatedApiClient {\n\t/**\n\t * @example To instantiate the class:\n\t *\n\t * ```js\n\t * new MigrationApiClient(\"https://migration.prismic.io\", {\n\t * \tauthToken: \"my-secret-token\",\n\t * \trepository: \"my-repo-name\",\n\t * });\n\t * ```\n\t *\n\t * @param baseURL - the api base URL like https://migration.prismic.io\n\t * @param config - Optional configuration\n\t *\n\t * - {@link config.authToken}: Api token generated from the auth service or a\n\t * function to fetch it when it's needed.\n\t * - {@link config.repository}: Repository name.\n\t */\n\tconstructor(\n\t\tbaseURL: string,\n\t\tconfig: { authToken: AuthServerToken; repository: string },\n\t) {\n\t\tsuper(baseURL, config.authToken, { repository: config.repository });\n\t}\n\n\tasync createDocument(data: DocumentPayload): Promise<DocumentResponse> {\n\t\tconst context = await this.getContext();\n\t\tconst result = await context.post(\"documents\", { data });\n\n\t\tif (201 !== result.status()) {\n\t\t\tawait logPlaywrightApiResponse(result);\n\t\t\tthrow new Error(\"Could not create a document with the migration api.\");\n\t\t}\n\n\t\treturn result.json();\n\t}\n}\n"],"names":[],"mappings":";;AAuBM,MAAO,2BAA2B,uBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkB7D,YACC,SACA,QAA0D;AAE1D,UAAM,SAAS,OAAO,WAAW,EAAE,YAAY,OAAO,YAAY;AAAA,EACnE;AAAA,EAEA,MAAM,eAAe,MAAqB;AACnC,UAAA,UAAU,MAAM,KAAK;AAC3B,UAAM,SAAS,MAAM,QAAQ,KAAK,aAAa,EAAE,MAAM;AAEnD,QAAA,QAAQ,OAAO,UAAU;AAC5B,YAAM,yBAAyB,MAAM;AAC/B,YAAA,IAAI,MAAM,qDAAqD;AAAA,IACtE;AAEA,WAAO,OAAO;EACf;AACA;"}
package/dist/index.cjs CHANGED
@@ -8,5 +8,5 @@ exports.RepositoriesManager = repositories.RepositoriesManager;
8
8
  exports.createRepositoriesManager = repositories.createRepositoriesManager;
9
9
  exports.RepositoryManager = repository.RepositoryManager;
10
10
  exports.ContentApiClient = contentApi.ContentApiClient;
11
- exports.createMigrationApiClient = migrationApi.createMigrationApiClient;
11
+ exports.MigrationApiClient = migrationApi.MigrationApiClient;
12
12
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { RepositoriesManager, createRepositoriesManager } from "./managers/repositories.js";
2
2
  import { RepositoryManager } from "./managers/repository.js";
3
3
  import { ContentApiClient } from "./clients/contentApi.js";
4
- import { createMigrationApiClient } from "./clients/migrationApi.js";
4
+ import { MigrationApiClient } from "./clients/migrationApi.js";
5
5
  export {
6
6
  ContentApiClient,
7
+ MigrationApiClient,
7
8
  RepositoriesManager,
8
9
  RepositoryManager,
9
- createMigrationApiClient,
10
10
  createRepositoriesManager
11
11
  };
12
12
  //# sourceMappingURL=index.js.map
@@ -42,7 +42,7 @@ class RepositoriesManager {
42
42
  urlConfig: typeof configuration.urlConfig === "string" ? this.inferUrls(configuration.urlConfig) : configuration.urlConfig
43
43
  };
44
44
  this.wroomClient = new wroom.WroomClient(this.config.urlConfig.baseURL, this.config.authConfig);
45
- this.authClient = authenticationApi.createAuthenticationApiClient(this.config.urlConfig.authenticationApi, this.config.authConfig);
45
+ this.authClient = new authenticationApi.AuthenticationApiClient(this.config.urlConfig.authenticationApi, this.config.authConfig);
46
46
  this.manageV2Client = new manageV2.ManageV2Client(this.config.urlConfig.baseURL, this.config.manageV2Config);
47
47
  }
48
48
  /**
@@ -90,8 +90,11 @@ class RepositoriesManager {
90
90
  throw new Error(`Could not create repository ${repositoryName}`);
91
91
  }
92
92
  this.repositories.add(repositoryName);
93
- profiler.done({ message: `created repository '${repositoryName}'` });
94
93
  const repository2 = this.getRepositoryManager(repositoryName);
94
+ const version = await repository2.getDeployedVersion();
95
+ profiler.done({
96
+ message: `created repository '${repositoryName}', Wroom version is "${version}"`
97
+ });
95
98
  await repository2.configure(config);
96
99
  return repository2;
97
100
  }
@@ -132,15 +135,22 @@ class RepositoriesManager {
132
135
  /**
133
136
  * Return a repository utilities object for a repository.
134
137
  *
135
- * @param name - The name of the repository.
138
+ * @param repository - The name of the repository.
136
139
  */
137
- getRepositoryManager(name) {
140
+ getRepositoryManager(repository$1) {
138
141
  const { urlConfig } = this.config;
139
- const customTypeClient = customTypesApi.createCustomTypesApiClient(urlConfig.customTypesApi, name, this.authClient);
140
- const coreApiUrl = urls.getRepositoryUrl(urlConfig.baseURL, name);
141
- const coreApiClient = coreApi.createCoreApiClient(coreApiUrl, this.authClient);
142
- const migrationApiClient = urlConfig.migrationApi ? migrationApi.createMigrationApiClient(urlConfig.migrationApi, name, this.authClient) : void 0;
143
- return new repository.RepositoryManager(name, coreApiClient, this.authClient, this.wroomClient, customTypeClient, migrationApiClient, this.manageV2Client);
142
+ const authToken = () => this.authClient.getToken();
143
+ const customTypeClient = new customTypesApi.CustomTypesApiClient(urlConfig.customTypesApi, {
144
+ authToken,
145
+ repository: repository$1
146
+ });
147
+ const coreApiUrl = urls.getRepositoryUrl(urlConfig.baseURL, repository$1);
148
+ const coreApiClient = new coreApi.CoreApiClient(coreApiUrl, authToken);
149
+ const migrationApiClient = urlConfig.migrationApi ? new migrationApi.MigrationApiClient(urlConfig.migrationApi, {
150
+ authToken,
151
+ repository: repository$1
152
+ }) : void 0;
153
+ return new repository.RepositoryManager(repository$1, coreApiClient, this.authClient, this.wroomClient, customTypeClient, migrationApiClient, this.manageV2Client);
144
154
  }
145
155
  }
146
156
  exports.RepositoriesManager = RepositoriesManager;
@@ -1 +1 @@
1
- {"version":3,"file":"repositories.cjs","sources":["../../../src/managers/repositories.ts"],"sourcesContent":["import { SetupConfiguration, UrlConfig } from \"../types\";\n\nimport {\n\tAuthenticationClient,\n\tcreateAuthenticationApiClient,\n} from \"../clients/authenticationApi\";\nimport { createCoreApiClient } from \"../clients/coreApi\";\nimport { createCustomTypesApiClient } from \"../clients/customTypesApi\";\nimport { ManageV2Client } from \"../clients/manageV2\";\nimport { createMigrationApiClient } 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: AuthenticationClient;\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\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);\n\t\tthis.authClient = createAuthenticationApiClient(\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\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};\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: \"vue\",\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\tprofiler.done({ message: `created repository '${repositoryName}'` });\n\n\t\tconst repository = this.getRepositoryManager(repositoryName);\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 name - The name of the repository.\n\t */\n\tgetRepositoryManager(name: string): RepositoryManager {\n\t\tconst { urlConfig } = this.config;\n\t\tconst customTypeClient = createCustomTypesApiClient(\n\t\t\turlConfig.customTypesApi,\n\t\t\tname,\n\t\t\tthis.authClient,\n\t\t);\n\t\tconst coreApiUrl = getRepositoryUrl(urlConfig.baseURL, name);\n\t\tconst coreApiClient = createCoreApiClient(coreApiUrl, this.authClient);\n\t\tconst migrationApiClient = urlConfig.migrationApi\n\t\t\t? createMigrationApiClient(urlConfig.migrationApi, name, this.authClient)\n\t\t\t: undefined;\n\n\t\treturn new RepositoryManager(\n\t\t\tname,\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\tthis.manageV2Client,\n\t\t);\n\t}\n}\n"],"names":["EnvVariableManager","WroomClient","createAuthenticationApiClient","ManageV2Client","logger","randomString","logHttpResponse","repository","createCustomTypesApiClient","getRepositoryUrl","createCoreApiClient","createMigrationApiClient","RepositoryManager"],"mappings":"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"}
1
+ {"version":3,"file":"repositories.cjs","sources":["../../../src/managers/repositories.ts"],"sourcesContent":["import { SetupConfiguration, UrlConfig } from \"../types\";\n\nimport { AuthenticationApiClient } from \"../clients/authenticationApi\";\nimport { CoreApiClient } from \"../clients/coreApi\";\nimport { CustomTypesApiClient } from \"../clients/customTypesApi\";\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\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);\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\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};\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: \"vue\",\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\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\tthis.manageV2Client,\n\t\t);\n\t}\n}\n"],"names":["EnvVariableManager","WroomClient","AuthenticationApiClient","ManageV2Client","logger","randomString","logHttpResponse","repository","CustomTypesApiClient","getRepositoryUrl","CoreApiClient","MigrationApiClient","RepositoryManager"],"mappings":"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"}
@@ -68,7 +68,7 @@ export declare class RepositoriesManager {
68
68
  /**
69
69
  * Return a repository utilities object for a repository.
70
70
  *
71
- * @param name - The name of the repository.
71
+ * @param repository - The name of the repository.
72
72
  */
73
- getRepositoryManager(name: string): RepositoryManager;
73
+ getRepositoryManager(repository: string): RepositoryManager;
74
74
  }
@@ -4,11 +4,11 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import { createAuthenticationApiClient } from "../clients/authenticationApi.js";
8
- import { createCoreApiClient } from "../clients/coreApi.js";
9
- import { createCustomTypesApiClient } from "../clients/customTypesApi.js";
7
+ import { AuthenticationApiClient } from "../clients/authenticationApi.js";
8
+ import { CoreApiClient } from "../clients/coreApi.js";
9
+ import { CustomTypesApiClient } from "../clients/customTypesApi.js";
10
10
  import { ManageV2Client } from "../clients/manageV2.js";
11
- import { createMigrationApiClient } from "../clients/migrationApi.js";
11
+ import { MigrationApiClient } from "../clients/migrationApi.js";
12
12
  import { WroomClient } from "../clients/wroom.js";
13
13
  import { EnvVariableManager } from "../utils/envVariableManager.js";
14
14
  import { logger, logHttpResponse } from "../utils/log.js";
@@ -40,7 +40,7 @@ class RepositoriesManager {
40
40
  urlConfig: typeof configuration.urlConfig === "string" ? this.inferUrls(configuration.urlConfig) : configuration.urlConfig
41
41
  };
42
42
  this.wroomClient = new WroomClient(this.config.urlConfig.baseURL, this.config.authConfig);
43
- this.authClient = createAuthenticationApiClient(this.config.urlConfig.authenticationApi, this.config.authConfig);
43
+ this.authClient = new AuthenticationApiClient(this.config.urlConfig.authenticationApi, this.config.authConfig);
44
44
  this.manageV2Client = new ManageV2Client(this.config.urlConfig.baseURL, this.config.manageV2Config);
45
45
  }
46
46
  /**
@@ -88,8 +88,11 @@ class RepositoriesManager {
88
88
  throw new Error(`Could not create repository ${repositoryName}`);
89
89
  }
90
90
  this.repositories.add(repositoryName);
91
- profiler.done({ message: `created repository '${repositoryName}'` });
92
91
  const repository = this.getRepositoryManager(repositoryName);
92
+ const version = await repository.getDeployedVersion();
93
+ profiler.done({
94
+ message: `created repository '${repositoryName}', Wroom version is "${version}"`
95
+ });
93
96
  await repository.configure(config);
94
97
  return repository;
95
98
  }
@@ -130,15 +133,22 @@ class RepositoriesManager {
130
133
  /**
131
134
  * Return a repository utilities object for a repository.
132
135
  *
133
- * @param name - The name of the repository.
136
+ * @param repository - The name of the repository.
134
137
  */
135
- getRepositoryManager(name) {
138
+ getRepositoryManager(repository) {
136
139
  const { urlConfig } = this.config;
137
- const customTypeClient = createCustomTypesApiClient(urlConfig.customTypesApi, name, this.authClient);
138
- const coreApiUrl = getRepositoryUrl(urlConfig.baseURL, name);
139
- const coreApiClient = createCoreApiClient(coreApiUrl, this.authClient);
140
- const migrationApiClient = urlConfig.migrationApi ? createMigrationApiClient(urlConfig.migrationApi, name, this.authClient) : void 0;
141
- return new RepositoryManager(name, coreApiClient, this.authClient, this.wroomClient, customTypeClient, migrationApiClient, this.manageV2Client);
140
+ const authToken = () => this.authClient.getToken();
141
+ const customTypeClient = new CustomTypesApiClient(urlConfig.customTypesApi, {
142
+ authToken,
143
+ repository
144
+ });
145
+ const coreApiUrl = getRepositoryUrl(urlConfig.baseURL, repository);
146
+ const coreApiClient = new CoreApiClient(coreApiUrl, authToken);
147
+ const migrationApiClient = urlConfig.migrationApi ? new MigrationApiClient(urlConfig.migrationApi, {
148
+ authToken,
149
+ repository
150
+ }) : void 0;
151
+ return new RepositoryManager(repository, coreApiClient, this.authClient, this.wroomClient, customTypeClient, migrationApiClient, this.manageV2Client);
142
152
  }
143
153
  }
144
154
  export {