@slicemachine/manager 0.22.4-alpha.BI-dt-2482-set-default-master-language-when-creating-new-repo-via-cli.1 → 0.22.4-alpha.BI-dt-2481-set-master-language-for-a-repository-via-manager-package.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const _commonjsHelpers = require("../../../../../../_virtual/_commonjsHelpers.cjs");
3
3
  const client = require("../../../../../../_virtual/client2.cjs");
4
- const index = require("../../../../../../_virtual/index2.cjs");
4
+ const index = require("../../../../../../_virtual/index3.cjs");
5
5
  const experimentCore_esm = require("../../../../../../_virtual/experiment-core.esm.cjs");
6
6
  require("../assignment/assignment.cjs");
7
7
  require("../assignment/assignment-filter.cjs");
@@ -1,6 +1,6 @@
1
1
  import { commonjsGlobal } from "../../../../../../_virtual/_commonjsHelpers.js";
2
2
  import { __exports as client } from "../../../../../../_virtual/client2.js";
3
- import require$$0 from "../../../../../../_virtual/index2.js";
3
+ import require$$0 from "../../../../../../_virtual/index3.js";
4
4
  import require$$1 from "../../../../../../_virtual/experiment-core.esm.js";
5
5
  import "../assignment/assignment.js";
6
6
  import "../assignment/assignment-filter.js";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const _commonjsHelpers = require("../../_virtual/_commonjsHelpers.cjs");
3
- const index = require("../../_virtual/index3.cjs");
3
+ const index = require("../../_virtual/index2.cjs");
4
4
  const require$$0 = require("child_process");
5
5
  const parse$1 = require("./lib/parse.cjs");
6
6
  const enoent$1 = require("./lib/enoent.cjs");
@@ -1,5 +1,5 @@
1
1
  import { getDefaultExportFromCjs } from "../../_virtual/_commonjsHelpers.js";
2
- import { __module as crossSpawn$1 } from "../../_virtual/index3.js";
2
+ import { __module as crossSpawn$1 } from "../../_virtual/index2.js";
3
3
  import require$$0 from "child_process";
4
4
  import { p as parse_1 } from "./lib/parse.js";
5
5
  import { e as enoent$1 } from "./lib/enoent.js";
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
- const _commonjsHelpers = require("./_commonjsHelpers.cjs");
3
- const index = require('./../_node_modules/@amplitude/analytics-node/lib/esm/index.cjs');
4
- const require$$0 = /* @__PURE__ */ _commonjsHelpers.getAugmentedNamespace(index);
5
- module.exports = require$$0;
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ var crossSpawn = { exports: {} };
4
+ exports.__module = crossSpawn;
6
5
  //# sourceMappingURL=index2.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index2.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"index2.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,7 +1,5 @@
1
- import { getAugmentedNamespace } from "./_commonjsHelpers.js";
2
- import * as index from './../_node_modules/@amplitude/analytics-node/lib/esm/index.js';
3
- const require$$0 = /* @__PURE__ */ getAugmentedNamespace(index);
1
+ var crossSpawn = { exports: {} };
4
2
  export {
5
- require$$0 as default
3
+ crossSpawn as __module
6
4
  };
7
5
  //# sourceMappingURL=index2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
1
+ {"version":3,"file":"index2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var crossSpawn = { exports: {} };
4
- exports.__module = crossSpawn;
2
+ const _commonjsHelpers = require("./_commonjsHelpers.cjs");
3
+ const index = require('./../_node_modules/@amplitude/analytics-node/lib/esm/index.cjs');
4
+ const require$$0 = /* @__PURE__ */ _commonjsHelpers.getAugmentedNamespace(index);
5
+ module.exports = require$$0;
5
6
  //# sourceMappingURL=index3.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index3.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"index3.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -1,5 +1,7 @@
1
- var crossSpawn = { exports: {} };
1
+ import { getAugmentedNamespace } from "./_commonjsHelpers.js";
2
+ import * as index from './../_node_modules/@amplitude/analytics-node/lib/esm/index.js';
3
+ const require$$0 = /* @__PURE__ */ getAugmentedNamespace(index);
2
4
  export {
3
- crossSpawn as __module
5
+ require$$0 as default
4
6
  };
5
7
  //# sourceMappingURL=index3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -14,7 +14,8 @@ const API_ENDPOINTS = (() => {
14
14
  PrismicEmbed: trailingSlash.removeTrailingSlash(process.env.oembed_endpoint ?? "https://oembed.wroom.io"),
15
15
  PrismicUnsplash: trailingSlash.addTrailingSlash(process.env.unsplash_endpoint ?? "https://unsplash.wroom.io/"),
16
16
  SliceMachineV1: trailingSlash.addTrailingSlash(process.env.slice_machine_v1_endpoint ?? "https://mc5qopc07a.execute-api.us-east-1.amazonaws.com/v1/"),
17
- RepositoryService: trailingSlash.addTrailingSlash(process.env.repository_api ?? "https://repository.internal.wroom.io/")
17
+ RepositoryService: trailingSlash.addTrailingSlash(process.env.repository_api ?? "https://repository.internal.wroom.io/"),
18
+ LocaleService: trailingSlash.addTrailingSlash(process.env.repository_api ?? "https://locale.internal.wroom.io/")
18
19
  };
19
20
  const missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {
20
21
  return !apiEndpoints[key];
@@ -47,7 +48,8 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
47
48
  PrismicEmbed: "https://oembed.wroom.io",
48
49
  PrismicUnsplash: "https://unsplash.wroom.io/",
49
50
  SliceMachineV1: "https://mc5qopc07a.execute-api.us-east-1.amazonaws.com/v1/",
50
- RepositoryService: "https://repository.internal.wroom.io/"
51
+ RepositoryService: "https://repository.internal.wroom.io/",
52
+ LocaleService: "https://locale.internal.wroom.io/"
51
53
  };
52
54
  }
53
55
  case APPLICATION_MODE.APPLICATION_MODE.Production:
@@ -61,7 +63,8 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
61
63
  PrismicEmbed: "https://oembed.prismic.io",
62
64
  PrismicUnsplash: "https://unsplash.prismic.io/",
63
65
  SliceMachineV1: "https://sm-api.prismic.io/v1/",
64
- RepositoryService: "https://repository.prismic.io/"
66
+ RepositoryService: "https://repository.prismic.io/",
67
+ LocaleService: "https://locale.prismic.io/"
65
68
  };
66
69
  }
67
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"API_ENDPOINTS.cjs","sources":["../../../src/constants/API_ENDPOINTS.ts"],"sourcesContent":["import { addTrailingSlash, removeTrailingSlash } from \"../lib/trailingSlash\";\nimport { APPLICATION_MODE } from \"./APPLICATION_MODE\";\n\nexport type APIEndpoints = {\n\tPrismicWroom: string;\n\tPrismicAuthentication: string;\n\tPrismicModels: string;\n\tPrismicUser: string;\n\tAwsAclProvider: string;\n\tPrismicEmbed: string;\n\tPrismicUnsplash: string;\n\tSliceMachineV1: string;\n\tRepositoryService: string;\n};\n\nexport const API_ENDPOINTS: APIEndpoints = (() => {\n\tswitch (process.env.SM_ENV) {\n\t\tcase APPLICATION_MODE.Development: {\n\t\t\tconst apiEndpoints = {\n\t\t\t\tPrismicWroom: addTrailingSlash(process.env.wroom_endpoint),\n\t\t\t\tPrismicAuthentication: addTrailingSlash(\n\t\t\t\t\tprocess.env.authentication_server_endpoint,\n\t\t\t\t),\n\t\t\t\tPrismicModels: addTrailingSlash(process.env.customtypesapi_endpoint),\n\t\t\t\tPrismicUser: addTrailingSlash(process.env.user_service_endpoint),\n\t\t\t\tAwsAclProvider: addTrailingSlash(process.env.acl_provider_endpoint),\n\t\t\t\tPrismicEmbed: removeTrailingSlash(\n\t\t\t\t\tprocess.env.oembed_endpoint ?? \"https://oembed.wroom.io\",\n\t\t\t\t),\n\t\t\t\tPrismicUnsplash: addTrailingSlash(\n\t\t\t\t\tprocess.env.unsplash_endpoint ?? \"https://unsplash.wroom.io/\",\n\t\t\t\t),\n\t\t\t\tSliceMachineV1: addTrailingSlash(\n\t\t\t\t\tprocess.env.slice_machine_v1_endpoint ??\n\t\t\t\t\t\t\"https://mc5qopc07a.execute-api.us-east-1.amazonaws.com/v1/\",\n\t\t\t\t),\n\t\t\t\tRepositoryService: addTrailingSlash(\n\t\t\t\t\tprocess.env.repository_api ?? \"https://repository.internal.wroom.io/\",\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tconst missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {\n\t\t\t\treturn !apiEndpoints[key as keyof typeof apiEndpoints];\n\t\t\t});\n\n\t\t\tif (missingAPIEndpoints.length > 0) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t\t\t}) where API endpoints are configured via environment variables.\n\nThe following endpoints were not configured: ${missingAPIEndpoints.join(\", \")}.\n\nConfigure them before continuing.`,\n\t\t\t\t);\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tconsole.warn(`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t}).\n\nThe following API endpoints were configured via environment variables:\n${Object.entries(apiEndpoints)\n\t.map(([name, endpoint]) => ` - ${name}: ${endpoint}`)\n\t.join(\"\\n\")}\n\nThese endpoints are different than Slice Machine's normal endpoints and are not trusted.\n\nIf you didn't intend to run Slice Machine this way, stop it immediately and unset the SM_ENV environment variable.`);\n\n\t\t\treturn apiEndpoints as APIEndpoints;\n\t\t}\n\n\t\tcase APPLICATION_MODE.Staging: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://wroom.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.wroom.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.wroom.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.wroom.io/\",\n\t\t\t\tAwsAclProvider:\n\t\t\t\t\t\"https://2iamcvnxf4.execute-api.us-east-1.amazonaws.com/stage/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.wroom.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.wroom.io/\",\n\t\t\t\tSliceMachineV1:\n\t\t\t\t\t\"https://mc5qopc07a.execute-api.us-east-1.amazonaws.com/v1/\",\n\t\t\t\tRepositoryService: \"https://repository.internal.wroom.io/\",\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.Production:\n\t\tdefault: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://prismic.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.prismic.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.prismic.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.prismic.io/\",\n\t\t\t\tAwsAclProvider:\n\t\t\t\t\t\"https://0yyeb2g040.execute-api.us-east-1.amazonaws.com/prod/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.prismic.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.prismic.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.prismic.io/v1/\",\n\t\t\t\tRepositoryService: \"https://repository.prismic.io/\",\n\t\t\t};\n\t\t}\n\t}\n})();\n"],"names":["APPLICATION_MODE","addTrailingSlash","removeTrailingSlash"],"mappings":";;;;AAeO,MAAM,iBAA+B,MAAK;AACxC,UAAA,QAAQ,IAAI,QAAQ;AAAA,IAC3B,KAAKA,iBAAAA,iBAAiB,aAAa;AAClC,YAAM,eAAe;AAAA,QACpB,cAAcC,cAAA,iBAAiB,QAAQ,IAAI,cAAc;AAAA,QACzD,uBAAuBA,cAAA,iBACtB,QAAQ,IAAI,8BAA8B;AAAA,QAE3C,eAAeA,cAAA,iBAAiB,QAAQ,IAAI,uBAAuB;AAAA,QACnE,aAAaA,cAAA,iBAAiB,QAAQ,IAAI,qBAAqB;AAAA,QAC/D,gBAAgBA,cAAA,iBAAiB,QAAQ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AAAA,QACjB,gBAAgB;AAAA,QAChB,mBAAmB;AAAA,MAAA;AAAA,IAErB;AAAA,EACD;AACD;;"}
1
+ {"version":3,"file":"API_ENDPOINTS.cjs","sources":["../../../src/constants/API_ENDPOINTS.ts"],"sourcesContent":["import { addTrailingSlash, removeTrailingSlash } from \"../lib/trailingSlash\";\nimport { APPLICATION_MODE } from \"./APPLICATION_MODE\";\n\nexport type APIEndpoints = {\n\tPrismicWroom: string;\n\tPrismicAuthentication: string;\n\tPrismicModels: string;\n\tPrismicUser: string;\n\tAwsAclProvider: string;\n\tPrismicEmbed: string;\n\tPrismicUnsplash: string;\n\tSliceMachineV1: string;\n\tRepositoryService: string;\n\tLocaleService: string;\n};\n\nexport const API_ENDPOINTS: APIEndpoints = (() => {\n\tswitch (process.env.SM_ENV) {\n\t\tcase APPLICATION_MODE.Development: {\n\t\t\tconst apiEndpoints = {\n\t\t\t\tPrismicWroom: addTrailingSlash(process.env.wroom_endpoint),\n\t\t\t\tPrismicAuthentication: addTrailingSlash(\n\t\t\t\t\tprocess.env.authentication_server_endpoint,\n\t\t\t\t),\n\t\t\t\tPrismicModels: addTrailingSlash(process.env.customtypesapi_endpoint),\n\t\t\t\tPrismicUser: addTrailingSlash(process.env.user_service_endpoint),\n\t\t\t\tAwsAclProvider: addTrailingSlash(process.env.acl_provider_endpoint),\n\t\t\t\tPrismicEmbed: removeTrailingSlash(\n\t\t\t\t\tprocess.env.oembed_endpoint ?? \"https://oembed.wroom.io\",\n\t\t\t\t),\n\t\t\t\tPrismicUnsplash: addTrailingSlash(\n\t\t\t\t\tprocess.env.unsplash_endpoint ?? \"https://unsplash.wroom.io/\",\n\t\t\t\t),\n\t\t\t\tSliceMachineV1: addTrailingSlash(\n\t\t\t\t\tprocess.env.slice_machine_v1_endpoint ??\n\t\t\t\t\t\t\"https://mc5qopc07a.execute-api.us-east-1.amazonaws.com/v1/\",\n\t\t\t\t),\n\t\t\t\tRepositoryService: addTrailingSlash(\n\t\t\t\t\tprocess.env.repository_api ?? \"https://repository.internal.wroom.io/\",\n\t\t\t\t),\n\t\t\t\tLocaleService: addTrailingSlash(\n\t\t\t\t\tprocess.env.repository_api ?? \"https://locale.internal.wroom.io/\",\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tconst missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {\n\t\t\t\treturn !apiEndpoints[key as keyof typeof apiEndpoints];\n\t\t\t});\n\n\t\t\tif (missingAPIEndpoints.length > 0) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t\t\t}) where API endpoints are configured via environment variables.\n\nThe following endpoints were not configured: ${missingAPIEndpoints.join(\", \")}.\n\nConfigure them before continuing.`,\n\t\t\t\t);\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tconsole.warn(`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t}).\n\nThe following API endpoints were configured via environment variables:\n${Object.entries(apiEndpoints)\n\t.map(([name, endpoint]) => ` - ${name}: ${endpoint}`)\n\t.join(\"\\n\")}\n\nThese endpoints are different than Slice Machine's normal endpoints and are not trusted.\n\nIf you didn't intend to run Slice Machine this way, stop it immediately and unset the SM_ENV environment variable.`);\n\n\t\t\treturn apiEndpoints as APIEndpoints;\n\t\t}\n\n\t\tcase APPLICATION_MODE.Staging: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://wroom.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.wroom.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.wroom.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.wroom.io/\",\n\t\t\t\tAwsAclProvider:\n\t\t\t\t\t\"https://2iamcvnxf4.execute-api.us-east-1.amazonaws.com/stage/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.wroom.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.wroom.io/\",\n\t\t\t\tSliceMachineV1:\n\t\t\t\t\t\"https://mc5qopc07a.execute-api.us-east-1.amazonaws.com/v1/\",\n\t\t\t\tRepositoryService: \"https://repository.internal.wroom.io/\",\n\t\t\t\tLocaleService: \"https://locale.internal.wroom.io/\",\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.Production:\n\t\tdefault: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://prismic.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.prismic.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.prismic.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.prismic.io/\",\n\t\t\t\tAwsAclProvider:\n\t\t\t\t\t\"https://0yyeb2g040.execute-api.us-east-1.amazonaws.com/prod/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.prismic.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.prismic.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.prismic.io/v1/\",\n\t\t\t\tRepositoryService: \"https://repository.prismic.io/\",\n\t\t\t\tLocaleService: \"https://locale.prismic.io/\",\n\t\t\t};\n\t\t}\n\t}\n})();\n"],"names":["APPLICATION_MODE","addTrailingSlash","removeTrailingSlash"],"mappings":";;;;AAgBO,MAAM,iBAA+B,MAAK;AACxC,UAAA,QAAQ,IAAI,QAAQ;AAAA,IAC3B,KAAKA,iBAAAA,iBAAiB,aAAa;AAClC,YAAM,eAAe;AAAA,QACpB,cAAcC,cAAA,iBAAiB,QAAQ,IAAI,cAAc;AAAA,QACzD,uBAAuBA,cAAA,iBACtB,QAAQ,IAAI,8BAA8B;AAAA,QAE3C,eAAeA,cAAA,iBAAiB,QAAQ,IAAI,uBAAuB;AAAA,QACnE,aAAaA,cAAA,iBAAiB,QAAQ,IAAI,qBAAqB;AAAA,QAC/D,gBAAgBA,cAAA,iBAAiB,QAAQ,IAAI,qBAAqB;AAAA,QAClE,cAAcC,cAAAA,oBACb,QAAQ,IAA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c;AAAA,QACd,iBAAiB;AAAA,QACjB,gBAAgB;AAAA,QAChB,mBAAmB;AAAA,QACnB,eAAe;AAAA,MAAA;AAAA,IAEjB;AAAA,EACD;AACD;;"}
@@ -8,5 +8,6 @@ export type APIEndpoints = {
8
8
  PrismicUnsplash: string;
9
9
  SliceMachineV1: string;
10
10
  RepositoryService: string;
11
+ LocaleService: string;
11
12
  };
12
13
  export declare const API_ENDPOINTS: APIEndpoints;
@@ -12,7 +12,8 @@ const API_ENDPOINTS = (() => {
12
12
  PrismicEmbed: removeTrailingSlash(process.env.oembed_endpoint ?? "https://oembed.wroom.io"),
13
13
  PrismicUnsplash: addTrailingSlash(process.env.unsplash_endpoint ?? "https://unsplash.wroom.io/"),
14
14
  SliceMachineV1: addTrailingSlash(process.env.slice_machine_v1_endpoint ?? "https://mc5qopc07a.execute-api.us-east-1.amazonaws.com/v1/"),
15
- RepositoryService: addTrailingSlash(process.env.repository_api ?? "https://repository.internal.wroom.io/")
15
+ RepositoryService: addTrailingSlash(process.env.repository_api ?? "https://repository.internal.wroom.io/"),
16
+ LocaleService: addTrailingSlash(process.env.repository_api ?? "https://locale.internal.wroom.io/")
16
17
  };
17
18
  const missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {
18
19
  return !apiEndpoints[key];
@@ -45,7 +46,8 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
45
46
  PrismicEmbed: "https://oembed.wroom.io",
46
47
  PrismicUnsplash: "https://unsplash.wroom.io/",
47
48
  SliceMachineV1: "https://mc5qopc07a.execute-api.us-east-1.amazonaws.com/v1/",
48
- RepositoryService: "https://repository.internal.wroom.io/"
49
+ RepositoryService: "https://repository.internal.wroom.io/",
50
+ LocaleService: "https://locale.internal.wroom.io/"
49
51
  };
50
52
  }
51
53
  case APPLICATION_MODE.Production:
@@ -59,7 +61,8 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
59
61
  PrismicEmbed: "https://oembed.prismic.io",
60
62
  PrismicUnsplash: "https://unsplash.prismic.io/",
61
63
  SliceMachineV1: "https://sm-api.prismic.io/v1/",
62
- RepositoryService: "https://repository.prismic.io/"
64
+ RepositoryService: "https://repository.prismic.io/",
65
+ LocaleService: "https://locale.prismic.io/"
63
66
  };
64
67
  }
65
68
  }
@@ -1 +1 @@
1
- {"version":3,"file":"API_ENDPOINTS.js","sources":["../../../src/constants/API_ENDPOINTS.ts"],"sourcesContent":["import { addTrailingSlash, removeTrailingSlash } from \"../lib/trailingSlash\";\nimport { APPLICATION_MODE } from \"./APPLICATION_MODE\";\n\nexport type APIEndpoints = {\n\tPrismicWroom: string;\n\tPrismicAuthentication: string;\n\tPrismicModels: string;\n\tPrismicUser: string;\n\tAwsAclProvider: string;\n\tPrismicEmbed: string;\n\tPrismicUnsplash: string;\n\tSliceMachineV1: string;\n\tRepositoryService: string;\n};\n\nexport const API_ENDPOINTS: APIEndpoints = (() => {\n\tswitch (process.env.SM_ENV) {\n\t\tcase APPLICATION_MODE.Development: {\n\t\t\tconst apiEndpoints = {\n\t\t\t\tPrismicWroom: addTrailingSlash(process.env.wroom_endpoint),\n\t\t\t\tPrismicAuthentication: addTrailingSlash(\n\t\t\t\t\tprocess.env.authentication_server_endpoint,\n\t\t\t\t),\n\t\t\t\tPrismicModels: addTrailingSlash(process.env.customtypesapi_endpoint),\n\t\t\t\tPrismicUser: addTrailingSlash(process.env.user_service_endpoint),\n\t\t\t\tAwsAclProvider: addTrailingSlash(process.env.acl_provider_endpoint),\n\t\t\t\tPrismicEmbed: removeTrailingSlash(\n\t\t\t\t\tprocess.env.oembed_endpoint ?? \"https://oembed.wroom.io\",\n\t\t\t\t),\n\t\t\t\tPrismicUnsplash: addTrailingSlash(\n\t\t\t\t\tprocess.env.unsplash_endpoint ?? \"https://unsplash.wroom.io/\",\n\t\t\t\t),\n\t\t\t\tSliceMachineV1: addTrailingSlash(\n\t\t\t\t\tprocess.env.slice_machine_v1_endpoint ??\n\t\t\t\t\t\t\"https://mc5qopc07a.execute-api.us-east-1.amazonaws.com/v1/\",\n\t\t\t\t),\n\t\t\t\tRepositoryService: addTrailingSlash(\n\t\t\t\t\tprocess.env.repository_api ?? \"https://repository.internal.wroom.io/\",\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tconst missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {\n\t\t\t\treturn !apiEndpoints[key as keyof typeof apiEndpoints];\n\t\t\t});\n\n\t\t\tif (missingAPIEndpoints.length > 0) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t\t\t}) where API endpoints are configured via environment variables.\n\nThe following endpoints were not configured: ${missingAPIEndpoints.join(\", \")}.\n\nConfigure them before continuing.`,\n\t\t\t\t);\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tconsole.warn(`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t}).\n\nThe following API endpoints were configured via environment variables:\n${Object.entries(apiEndpoints)\n\t.map(([name, endpoint]) => ` - ${name}: ${endpoint}`)\n\t.join(\"\\n\")}\n\nThese endpoints are different than Slice Machine's normal endpoints and are not trusted.\n\nIf you didn't intend to run Slice Machine this way, stop it immediately and unset the SM_ENV environment variable.`);\n\n\t\t\treturn apiEndpoints as APIEndpoints;\n\t\t}\n\n\t\tcase APPLICATION_MODE.Staging: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://wroom.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.wroom.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.wroom.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.wroom.io/\",\n\t\t\t\tAwsAclProvider:\n\t\t\t\t\t\"https://2iamcvnxf4.execute-api.us-east-1.amazonaws.com/stage/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.wroom.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.wroom.io/\",\n\t\t\t\tSliceMachineV1:\n\t\t\t\t\t\"https://mc5qopc07a.execute-api.us-east-1.amazonaws.com/v1/\",\n\t\t\t\tRepositoryService: \"https://repository.internal.wroom.io/\",\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.Production:\n\t\tdefault: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://prismic.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.prismic.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.prismic.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.prismic.io/\",\n\t\t\t\tAwsAclProvider:\n\t\t\t\t\t\"https://0yyeb2g040.execute-api.us-east-1.amazonaws.com/prod/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.prismic.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.prismic.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.prismic.io/v1/\",\n\t\t\t\tRepositoryService: \"https://repository.prismic.io/\",\n\t\t\t};\n\t\t}\n\t}\n})();\n"],"names":[],"mappings":";;AAeO,MAAM,iBAA+B,MAAK;AACxC,UAAA,QAAQ,IAAI,QAAQ;AAAA,IAC3B,KAAK,iBAAiB,aAAa;AAClC,YAAM,eAAe;AAAA,QACpB,cAAc,iBAAiB,QAAQ,IAAI,cAAc;AAAA,QACzD,uBAAuB,iBACtB,QAAQ,IAAI,8BAA8B;AAAA,QAE3C,eAAe,iBAAiB,QAAQ,IAAI,uBAAuB;AAAA,QACnE,aAAa,iBAAiB,QAAQ,IAAI,qBAAqB;AAAA,QAC/D,gBAAgB,iBAAiB,QAAQ,IAAI,qBAAqB;AAAA,QAClE,cAAc,oBACb,QAAQ,IAAI,mBAAmB,yBAAyB;AAAA,QAEzD,iBAAiB,iBAChB,QAAQ,IAAI,qBAAqB,4BAA4B;AAAA,QAE9D,gBAAgB,iBACf,QAAQ,IAAI,6BACX,4DAA4D;AAAA,QAE9D,mBAAmB,iBAClB,QAAQ,IAAI,kBAAkB,uCAAuC;AAAA,MAAA;AAIvE,YAAM,sBAAsB,OAAO,KAAK,YAAY,EAAE,OAAO,CAAC,QAAO;AAC7D,eAAA,CAAC,aAAa,GAAgC;AAAA,MAAA,CACrD;AAEG,UAAA,oBAAoB,SAAS,GAAG;AAC3B,gBAAA,MACP,6DACC,iBAAiB;AAAA;AAAA,+CAGwB,oBAAoB,KAAK,IAAI;AAAA;AAAA,kCAE1C;AAG9B,gBAAQ,KAAK,CAAC;AAAA,MACf;AAEQ,cAAA,KAAK,6DACZ,iBAAiB;AAAA;AAAA;AAAA,EAInB,OAAO,QAAQ,YAAY,EAC3B,IAAI,CAAC,CAAC,MAAM,QAAQ,MAAM,OAAO,SAAS,UAAU,EACpD,KAAK,IAAI;AAAA;AAAA;AAAA;AAAA,mHAIwG;AAEzG,aAAA;AAAA,IACR;AAAA,IAEA,KAAK,iBAAiB,SAAS;AACvB,aAAA;AAAA,QACN,cAAc;AAAA,QACd,uBAAuB;AAAA,QACvB,eAAe;AAAA,QACf,aAAa;AAAA,QACb,gBACC;AAAA,QACD,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,gBACC;AAAA,QACD,mBAAmB;AAAA,MAAA;AAAA,IAErB;AAAA,IAEA,KAAK,iBAAiB;AAAA,IACtB,SAAS;AACD,aAAA;AAAA,QACN,cAAc;AAAA,QACd,uBAAuB;AAAA,QACvB,eAAe;AAAA,QACf,aAAa;AAAA,QACb,gBACC;AAAA,QACD,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,gBAAgB;AAAA,QAChB,mBAAmB;AAAA,MAAA;AAAA,IAErB;AAAA,EACD;AACD;"}
1
+ {"version":3,"file":"API_ENDPOINTS.js","sources":["../../../src/constants/API_ENDPOINTS.ts"],"sourcesContent":["import { addTrailingSlash, removeTrailingSlash } from \"../lib/trailingSlash\";\nimport { APPLICATION_MODE } from \"./APPLICATION_MODE\";\n\nexport type APIEndpoints = {\n\tPrismicWroom: string;\n\tPrismicAuthentication: string;\n\tPrismicModels: string;\n\tPrismicUser: string;\n\tAwsAclProvider: string;\n\tPrismicEmbed: string;\n\tPrismicUnsplash: string;\n\tSliceMachineV1: string;\n\tRepositoryService: string;\n\tLocaleService: string;\n};\n\nexport const API_ENDPOINTS: APIEndpoints = (() => {\n\tswitch (process.env.SM_ENV) {\n\t\tcase APPLICATION_MODE.Development: {\n\t\t\tconst apiEndpoints = {\n\t\t\t\tPrismicWroom: addTrailingSlash(process.env.wroom_endpoint),\n\t\t\t\tPrismicAuthentication: addTrailingSlash(\n\t\t\t\t\tprocess.env.authentication_server_endpoint,\n\t\t\t\t),\n\t\t\t\tPrismicModels: addTrailingSlash(process.env.customtypesapi_endpoint),\n\t\t\t\tPrismicUser: addTrailingSlash(process.env.user_service_endpoint),\n\t\t\t\tAwsAclProvider: addTrailingSlash(process.env.acl_provider_endpoint),\n\t\t\t\tPrismicEmbed: removeTrailingSlash(\n\t\t\t\t\tprocess.env.oembed_endpoint ?? \"https://oembed.wroom.io\",\n\t\t\t\t),\n\t\t\t\tPrismicUnsplash: addTrailingSlash(\n\t\t\t\t\tprocess.env.unsplash_endpoint ?? \"https://unsplash.wroom.io/\",\n\t\t\t\t),\n\t\t\t\tSliceMachineV1: addTrailingSlash(\n\t\t\t\t\tprocess.env.slice_machine_v1_endpoint ??\n\t\t\t\t\t\t\"https://mc5qopc07a.execute-api.us-east-1.amazonaws.com/v1/\",\n\t\t\t\t),\n\t\t\t\tRepositoryService: addTrailingSlash(\n\t\t\t\t\tprocess.env.repository_api ?? \"https://repository.internal.wroom.io/\",\n\t\t\t\t),\n\t\t\t\tLocaleService: addTrailingSlash(\n\t\t\t\t\tprocess.env.repository_api ?? \"https://locale.internal.wroom.io/\",\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tconst missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {\n\t\t\t\treturn !apiEndpoints[key as keyof typeof apiEndpoints];\n\t\t\t});\n\n\t\t\tif (missingAPIEndpoints.length > 0) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t\t\t}) where API endpoints are configured via environment variables.\n\nThe following endpoints were not configured: ${missingAPIEndpoints.join(\", \")}.\n\nConfigure them before continuing.`,\n\t\t\t\t);\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tconsole.warn(`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t}).\n\nThe following API endpoints were configured via environment variables:\n${Object.entries(apiEndpoints)\n\t.map(([name, endpoint]) => ` - ${name}: ${endpoint}`)\n\t.join(\"\\n\")}\n\nThese endpoints are different than Slice Machine's normal endpoints and are not trusted.\n\nIf you didn't intend to run Slice Machine this way, stop it immediately and unset the SM_ENV environment variable.`);\n\n\t\t\treturn apiEndpoints as APIEndpoints;\n\t\t}\n\n\t\tcase APPLICATION_MODE.Staging: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://wroom.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.wroom.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.wroom.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.wroom.io/\",\n\t\t\t\tAwsAclProvider:\n\t\t\t\t\t\"https://2iamcvnxf4.execute-api.us-east-1.amazonaws.com/stage/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.wroom.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.wroom.io/\",\n\t\t\t\tSliceMachineV1:\n\t\t\t\t\t\"https://mc5qopc07a.execute-api.us-east-1.amazonaws.com/v1/\",\n\t\t\t\tRepositoryService: \"https://repository.internal.wroom.io/\",\n\t\t\t\tLocaleService: \"https://locale.internal.wroom.io/\",\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.Production:\n\t\tdefault: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://prismic.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.prismic.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.prismic.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.prismic.io/\",\n\t\t\t\tAwsAclProvider:\n\t\t\t\t\t\"https://0yyeb2g040.execute-api.us-east-1.amazonaws.com/prod/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.prismic.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.prismic.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.prismic.io/v1/\",\n\t\t\t\tRepositoryService: \"https://repository.prismic.io/\",\n\t\t\t\tLocaleService: \"https://locale.prismic.io/\",\n\t\t\t};\n\t\t}\n\t}\n})();\n"],"names":[],"mappings":";;AAgBO,MAAM,iBAA+B,MAAK;AACxC,UAAA,QAAQ,IAAI,QAAQ;AAAA,IAC3B,KAAK,iBAAiB,aAAa;AAClC,YAAM,eAAe;AAAA,QACpB,cAAc,iBAAiB,QAAQ,IAAI,cAAc;AAAA,QACzD,uBAAuB,iBACtB,QAAQ,IAAI,8BAA8B;AAAA,QAE3C,eAAe,iBAAiB,QAAQ,IAAI,uBAAuB;AAAA,QACnE,aAAa,iBAAiB,QAAQ,IAAI,qBAAqB;AAAA,QAC/D,gBAAgB,iBAAiB,QAAQ,IAAI,qBAAqB;AAAA,QAClE,cAAc,oBACb,QAAQ,IAAI,mBAAmB,yBAAyB;AAAA,QAEzD,iBAAiB,iBAChB,QAAQ,IAAI,qBAAqB,4BAA4B;AAAA,QAE9D,gBAAgB,iBACf,QAAQ,IAAI,6BACX,4DAA4D;AAAA,QAE9D,mBAAmB,iBAClB,QAAQ,IAAI,kBAAkB,uCAAuC;AAAA,QAEtE,eAAe,iBACd,QAAQ,IAAI,kBAAkB,mCAAmC;AAAA,MAAA;AAInE,YAAM,sBAAsB,OAAO,KAAK,YAAY,EAAE,OAAO,CAAC,QAAO;AAC7D,eAAA,CAAC,aAAa,GAAgC;AAAA,MAAA,CACrD;AAEG,UAAA,oBAAoB,SAAS,GAAG;AAC3B,gBAAA,MACP,6DACC,iBAAiB;AAAA;AAAA,+CAGwB,oBAAoB,KAAK,IAAI;AAAA;AAAA,kCAE1C;AAG9B,gBAAQ,KAAK,CAAC;AAAA,MACf;AAEQ,cAAA,KAAK,6DACZ,iBAAiB;AAAA;AAAA;AAAA,EAInB,OAAO,QAAQ,YAAY,EAC3B,IAAI,CAAC,CAAC,MAAM,QAAQ,MAAM,OAAO,SAAS,UAAU,EACpD,KAAK,IAAI;AAAA;AAAA;AAAA;AAAA,mHAIwG;AAEzG,aAAA;AAAA,IACR;AAAA,IAEA,KAAK,iBAAiB,SAAS;AACvB,aAAA;AAAA,QACN,cAAc;AAAA,QACd,uBAAuB;AAAA,QACvB,eAAe;AAAA,QACf,aAAa;AAAA,QACb,gBACC;AAAA,QACD,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,gBACC;AAAA,QACD,mBAAmB;AAAA,QACnB,eAAe;AAAA,MAAA;AAAA,IAEjB;AAAA,IAEA,KAAK,iBAAiB;AAAA,IACtB,SAAS;AACD,aAAA;AAAA,QACN,cAAc;AAAA,QACd,uBAAuB;AAAA,QACvB,eAAe;AAAA,QACf,aAAa;AAAA,QACb,gBACC;AAAA,QACD,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,gBAAgB;AAAA,QAChB,mBAAmB;AAAA,QACnB,eAAe;AAAA,MAAA;AAAA,IAEjB;AAAA,EACD;AACD;"}
@@ -461,17 +461,14 @@ class PrismicRepositoryManager extends BaseManager.BaseManager {
461
461
  }
462
462
  async setDefaultMasterLocale() {
463
463
  const repositoryName = await this.project.getRepositoryName();
464
- const localeServiceBaseUrl = new URL("locale/", API_ENDPOINTS.API_ENDPOINTS.PrismicWroom);
465
- localeServiceBaseUrl.hostname = `${repositoryName}.${localeServiceBaseUrl.hostname}`;
466
- const url = new URL("repository/locales", localeServiceBaseUrl);
464
+ const url = new URL("repository/locales", API_ENDPOINTS.API_ENDPOINTS.LocaleService);
467
465
  url.searchParams.set("repository", repositoryName);
468
466
  const res = await this._fetch({
469
467
  url,
470
468
  method: "POST",
471
469
  body: {
472
470
  id: "en-us",
473
- isMaster: true,
474
- label: "English - United States"
471
+ isMaster: true
475
472
  }
476
473
  });
477
474
  if (!res.ok) {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicRepositoryManager.cjs","sources":["../../../../src/managers/prismicRepository/PrismicRepositoryManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport { z } from \"zod\";\nimport fetch, { Response } from \"../../lib/fetch\";\nimport { fold } from \"fp-ts/Either\";\n\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decode } from \"../../lib/decode\";\nimport { serializeCookies } from \"../../lib/serializeCookies\";\n\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { REPOSITORY_NAME_VALIDATION } from \"../../constants/REPOSITORY_NAME_VALIDATION\";\n\nimport {\n\tUnauthenticatedError,\n\tUnauthorizedError,\n\tUnexpectedDataError,\n} from \"../../errors\";\n\nimport { BaseManager } from \"../BaseManager\";\n\nimport {\n\tAllChangeTypes,\n\tBulkBody,\n\tChangeTypes,\n\tClientError,\n\tPushChangesLimit,\n\tPushChangesLimitType,\n\tPrismicRepository,\n\tPrismicRepositoryRole,\n\tPrismicRepositoryUserAgent,\n\tPrismicRepositoryUserAgents,\n\tPushChangesRawLimit,\n\tTransactionalMergeArgs,\n\tTransactionalMergeReturnType,\n\tFrameworkWroomTelemetryID,\n\tStarterId,\n\tEnvironment,\n\tOnboardingState,\n} from \"./types\";\nimport { sortEnvironments } from \"./sortEnvironments\";\n\nconst DEFAULT_REPOSITORY_SETTINGS = {\n\tplan: \"personal\",\n\tisAnnual: \"false\",\n\trole: \"developer\",\n};\n\ntype PrismicRepositoryManagerCheckExistsArgs = {\n\tdomain: string;\n};\n\ntype PrismicRepositoryManagerCreateArgs = {\n\tdomain: string;\n\tframework: FrameworkWroomTelemetryID;\n\tstarterId?: StarterId;\n};\n\ntype PrismicRepositoryManagerDeleteArgs = {\n\tdomain: string;\n\tpassword: string;\n};\n\ntype PrismicRepositoryManagerPushDocumentsArgs = {\n\tdomain: string;\n\tsignature: string;\n\tdocuments: Record<string, unknown>; // TODO: Type unknown if possible(?)\n};\n\ntype PrismicRepositoryManagerFetchEnvironmentsArgs = {\n\t/**\n\t * If set to `true`, all environments are returned regardless of the user's\n\t * permission level.\n\t *\n\t * If set to `false`, only environments the user can access are returned.\n\t *\n\t * @defaultValue `false`\n\t */\n\tincludeAll?: boolean;\n};\n\ntype PrismicRepositoryManagerFetchEnvironmentsReturnType = {\n\tenvironments?: Environment[];\n};\n\nexport class PrismicRepositoryManager extends BaseManager {\n\t// TODO: Add methods for repository-specific actions. E.g. creating a\n\t// new repository.\n\n\tasync readAll(): Promise<PrismicRepository[]> {\n\t\tconst url = new URL(\"./repositories\", API_ENDPOINTS.PrismicUser);\n\t\tconst res = await this._fetch({ url });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value: repositories, error } = decode(\n\t\t\t\tt.array(PrismicRepository),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to decode repositories: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn repositories;\n\t\t} else {\n\t\t\tconst text = await res.text();\n\t\t\tthrow new Error(`Failed to read repositories`, { cause: text });\n\t\t}\n\t}\n\n\t// Should this be in manager? It's one of the few sync method\n\t//\n\t// Reply from Angelo 2022-12-22: I think it should be in manager\n\t// because we shouldn't be exporting root-level utilities from this\n\t// package. If we want to make it more inline with the other methods,\n\t// we could simplify the API by changing its signature to the\n\t// following:\n\t//\n\t// ```ts\n\t// (repositoryName: string) => Promise<boolean>\n\t// ```\n\t//\n\t// This method would:\n\t//\n\t// 1. Fetch the list of repositories for the user using `readAll()`.\n\t// The list would be cached.\n\t// 2. Determine if the user has write access to the given repository.\n\t//\n\t// This version has the following benefits:\n\t//\n\t// - Does not expect the consumer to supply a repository object; it\n\t// only requires a repository name, which could be sourced from\n\t// anything (incl. the project's `slicemachine.config.json`).\n\t//\n\t// - Similarly, it does not expect the consumer to call `readAll()`\n\t// before calling this method.\n\t//\n\t// - Works for repositories that the user does not have access to. For\n\t// example, I could use it to check if I have access to \"qwerty\",\n\t// even if I am not added as a user. The purpose of the method is\n\t// still valid: do I have write access to a given repository?\n\thasWriteAccess(repository: PrismicRepository): boolean {\n\t\tswitch (repository.role) {\n\t\t\tcase PrismicRepositoryRole.SuperUser:\n\t\t\tcase PrismicRepositoryRole.Owner:\n\t\t\tcase PrismicRepositoryRole.Administrator:\n\t\t\t\treturn true;\n\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tasync checkExists(\n\t\targs: PrismicRepositoryManagerCheckExistsArgs,\n\t): Promise<boolean> {\n\t\tconst url = new URL(\n\t\t\t`./app/dashboard/repositories/${args.domain}/exists`,\n\t\t\tAPI_ENDPOINTS.PrismicWroom,\n\t\t);\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tskipAuthentication: true,\n\t\t});\n\n\t\tconst text = await res.text();\n\n\t\tif (res.ok) {\n\t\t\treturn text === \"false\"; // Endpoint returns `false` when repository exists\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to check repository existence for domain \\`${args.domain}\\``,\n\t\t\t\t{ cause: text },\n\t\t\t);\n\t\t}\n\t}\n\n\tasync create(args: PrismicRepositoryManagerCreateArgs): Promise<void> {\n\t\tconst url = new URL(\n\t\t\t\"./authentication/newrepository?app=slicemachine\",\n\t\t\tAPI_ENDPOINTS.PrismicWroom,\n\t\t);\n\n\t\tconst body = {\n\t\t\t...DEFAULT_REPOSITORY_SETTINGS,\n\t\t\tdomain: args.domain,\n\t\t\t// These properties are optional in the API but needed for tracking\n\t\t\tframework: args.framework,\n\t\t\tstarterId: args.starterId,\n\t\t};\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody,\n\t\t\tuserAgent: PrismicRepositoryUserAgent.SliceMachine, // Custom User Agent is required\n\t\t});\n\t\tconst text = await res.text();\n\n\t\t// Endpoint returns repository name on success, that should be within the validation range\n\t\t// Even when there is an error, we get a 200 success and so we have to check the name thanks to that\n\t\tif (\n\t\t\t!res.ok ||\n\t\t\ttext.length < REPOSITORY_NAME_VALIDATION.Min ||\n\t\t\ttext.length > REPOSITORY_NAME_VALIDATION.Max\n\t\t) {\n\t\t\tthrow new Error(`Failed to create repository \\`${args.domain}\\``, {\n\t\t\t\tcause: text,\n\t\t\t});\n\t\t}\n\t}\n\n\t// TODO: Delete this endpoint? It doesn't seem to be used (I might be wrong). - Angelo\n\tasync delete(args: PrismicRepositoryManagerDeleteArgs): Promise<void> {\n\t\tconst cookies = await this.user.getAuthenticationCookies();\n\n\t\tconst url = new URL(\n\t\t\t`./app/settings/delete?_=${cookies[\"X_XSRF\"]}`, // TODO: Maybe we want to throw early if the token is no available, or get the token another way\n\t\t\tAPI_ENDPOINTS.PrismicWroom,\n\t\t);\n\t\t// Update hostname to include repository domain\n\t\turl.hostname = `${args.domain}.${url.hostname}`;\n\n\t\tconst body = {\n\t\t\tconfirm: args.domain,\n\t\t\tpassword: args.password,\n\t\t};\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody,\n\t\t\tuserAgent: PrismicRepositoryUserAgent.LegacyZero, // Custom User Agent is required\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(`Failed to delete repository \\`${args.domain}\\``, {\n\t\t\t\tcause: res,\n\t\t\t});\n\t\t}\n\t}\n\n\tasync pushDocuments(\n\t\targs: PrismicRepositoryManagerPushDocumentsArgs,\n\t): Promise<void> {\n\t\tconst url = new URL(\"./starter/documents\", API_ENDPOINTS.PrismicWroom);\n\t\t// Update hostname to include repository domain\n\t\turl.hostname = `${args.domain}.${url.hostname}`;\n\n\t\tconst body = {\n\t\t\tsignature: args.signature,\n\t\t\tdocuments: JSON.stringify(args.documents),\n\t\t};\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody,\n\t\t\tuserAgent: PrismicRepositoryUserAgent.LegacyZero, // Custom User Agent is required\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tlet reason: string | null = null;\n\t\t\ttry {\n\t\t\t\treason = await res.text();\n\t\t\t} catch {\n\t\t\t\t// Noop\n\t\t\t}\n\n\t\t\t// Ideally the API should throw a 409 or something like that...\n\t\t\tif (reason === \"Repository should not contain documents\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to push documents to repository \\`${args.domain}\\`, repository is not empty`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: reason,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to push documents to repository \\`${args.domain}\\`, ${res.status} ${res.statusText}`,\n\t\t\t\t{\n\t\t\t\t\tcause: reason,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\tasync pushChanges(\n\t\targs: TransactionalMergeArgs,\n\t): Promise<TransactionalMergeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tif (!(await this.user.checkIsLoggedIn())) {\n\t\t\tthrow new UnauthenticatedError();\n\t\t}\n\n\t\ttry {\n\t\t\t// Update the AWS ACL before uploading screenshots as it might have expired\n\t\t\tawait this.screenshots.initS3ACL();\n\n\t\t\tconst allChanges: AllChangeTypes[] = await Promise.all(\n\t\t\t\targs.changes.map(async (change) => {\n\t\t\t\t\tif (change.type === \"Slice\") {\n\t\t\t\t\t\tswitch (change.status) {\n\t\t\t\t\t\t\tcase \"NEW\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.slices.readSlice({\n\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\tsliceID: change.id,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst modelWithScreenshots =\n\t\t\t\t\t\t\t\t\tawait this.slices.updateSliceModelScreenshotsInPlace({\n\t\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: modelWithScreenshots,\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.SLICE_INSERT,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"MODIFIED\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.slices.readSlice({\n\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\tsliceID: change.id,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst modelWithScreenshots =\n\t\t\t\t\t\t\t\t\tawait this.slices.updateSliceModelScreenshotsInPlace({\n\t\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: modelWithScreenshots,\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.SLICE_UPDATE,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"DELETED\":\n\t\t\t\t\t\t\t\tawait this.screenshots.deleteScreenshotFolder({\n\t\t\t\t\t\t\t\t\tsliceID: change.id,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: { id: change.id },\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.SLICE_DELETE,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tswitch (change.status) {\n\t\t\t\t\t\t\tcase \"NEW\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.CUSTOM_TYPE_INSERT,\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: model,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"MODIFIED\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.CUSTOM_TYPE_UPDATE,\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: model,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"DELETED\":\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: { id: change.id },\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.CUSTOM_TYPE_DELETE,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\t// Compute the POST body\n\t\t\tconst requestBody: BulkBody = {\n\t\t\t\tconfirmDeleteDocuments: args.confirmDeleteDocuments,\n\t\t\t\tchanges: allChanges,\n\t\t\t};\n\n\t\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t\t// TODO: move to customtypes client\n\t\t\tconst response = await this._fetch({\n\t\t\t\turl: new URL(\"./bulk\", API_ENDPOINTS.PrismicModels),\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: requestBody,\n\t\t\t\trepository: repositoryName,\n\t\t\t});\n\n\t\t\tswitch (response.status) {\n\t\t\t\tcase 202:\n\t\t\t\t\treturn this._decodeLimitOrThrow(\n\t\t\t\t\t\tawait response.json(),\n\t\t\t\t\t\tresponse.status,\n\t\t\t\t\t\tPushChangesLimitType.SOFT,\n\t\t\t\t\t);\n\t\t\t\tcase 204:\n\t\t\t\t\treturn null;\n\t\t\t\tcase 401:\n\t\t\t\t\tthrow new UnauthenticatedError();\n\t\t\t\tcase 403:\n\t\t\t\t\treturn this._decodeLimitOrThrow(\n\t\t\t\t\t\tawait response.json(),\n\t\t\t\t\t\tresponse.status,\n\t\t\t\t\t\tPushChangesLimitType.HARD,\n\t\t\t\t\t);\n\t\t\t\tcase 400:\n\t\t\t\t\tconst text = await response.text();\n\t\t\t\t\tthrow new Error(text);\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(`Unexpected status code ${response.status}`, {\n\t\t\t\t\t\tcause: await response.text(),\n\t\t\t\t\t});\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconsole.error(\"An error happened while pushing your changes\");\n\t\t\tconsole.error(err);\n\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tasync fetchEnvironments(\n\t\targs?: PrismicRepositoryManagerFetchEnvironmentsArgs,\n\t): Promise<PrismicRepositoryManagerFetchEnvironmentsReturnType> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(`./environments`, API_ENDPOINTS.SliceMachineV1);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\n\t\tconst res = await this._fetch({ url });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\n\t\t\tconst { value, error } = decode(\n\t\t\t\tt.union([\n\t\t\t\t\tt.type({\n\t\t\t\t\t\tresults: t.array(Environment),\n\t\t\t\t\t}),\n\t\t\t\t\tt.type({\n\t\t\t\t\t\terror: t.literal(\"invalid_token\"),\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode environments: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\"results\" in value) {\n\t\t\t\tlet environments = value.results;\n\n\t\t\t\tif (!args?.includeAll) {\n\t\t\t\t\tconst profile = await this.user.getProfile();\n\n\t\t\t\t\tenvironments = environments.filter((environment) =>\n\t\t\t\t\t\tenvironment.users.some((user) => user.id === profile.shortId),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn { environments: sortEnvironments(environments) };\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to fetch environments.\");\n\t\t}\n\t}\n\n\tasync fetchOnboarding(): Promise<OnboardingState> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\"/onboarding\", API_ENDPOINTS.RepositoryService);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\tconst res = await this._fetch({ url });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value, error } = decode(OnboardingState, json);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode onboarding: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (value) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to fetch onboarding.\");\n\t\t}\n\t}\n\n\tasync toggleOnboardingStep(\n\t\tstepId: string,\n\t): Promise<{ completedSteps: string[] }> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\n\t\t\t`/onboarding/${stepId}/toggle`,\n\t\t\tAPI_ENDPOINTS.RepositoryService,\n\t\t);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\tconst res = await this._fetch({ url, method: \"PATCH\" });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value, error } = decode(\n\t\t\t\tz.object({ completedSteps: z.array(z.string()) }),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode onboarding step toggle: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (value) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to toggle onboarding step.\");\n\t\t}\n\t}\n\n\tasync completeOnboardingStep(\n\t\t...stepIds: string[]\n\t): Promise<{ completedSteps: string[] }> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst currentState = await this.fetchOnboarding();\n\t\tconst incompleteSteps = stepIds.filter(\n\t\t\t(stepId) => !currentState.completedSteps.includes(stepId),\n\t\t);\n\n\t\tif (incompleteSteps.length > 0) {\n\t\t\t// TODO: Refactor when the API accepts multiple steps (DT-2389)\n\t\t\tfor await (const stepId of incompleteSteps) {\n\t\t\t\tconst url = new URL(\n\t\t\t\t\t`/onboarding/${stepId}/toggle`,\n\t\t\t\t\tAPI_ENDPOINTS.RepositoryService,\n\t\t\t\t);\n\t\t\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\t\t\tconst res = await this._fetch({ url, method: \"PATCH\" });\n\n\t\t\t\tif (res.ok) {\n\t\t\t\t\tconst json = await res.json();\n\t\t\t\t\tconst { value, error } = decode(\n\t\t\t\t\t\tz.object({ completedSteps: z.array(z.string()) }),\n\t\t\t\t\t\tjson,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t\t\t`Failed to decode onboarding step complete response: ${error.errors.join(\n\t\t\t\t\t\t\t\t\", \",\n\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (value) {\n\t\t\t\t\t\tcurrentState.completedSteps = value.completedSteps;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tswitch (res.status) {\n\t\t\t\t\tcase 400:\n\t\t\t\t\tcase 401:\n\t\t\t\t\t\tthrow new UnauthenticatedError();\n\t\t\t\t\tcase 403:\n\t\t\t\t\t\tthrow new UnauthorizedError();\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new Error(\"Failed to complete onboarding step.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { completedSteps: currentState.completedSteps };\n\t}\n\n\tasync toggleOnboarding(): Promise<{ isDismissed: boolean }> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\"/onboarding/toggle\", API_ENDPOINTS.RepositoryService);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\tconst res = await this._fetch({ url, method: \"PATCH\" });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value, error } = decode(\n\t\t\t\tz.object({ isDismissed: z.boolean() }),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode onboarding toggle: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (value) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to toggle onboarding guide.\");\n\t\t}\n\t}\n\n\tasync setDefaultMasterLocale(): Promise<void> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst localeServiceBaseUrl = new URL(\"locale/\", API_ENDPOINTS.PrismicWroom);\n\t\tlocaleServiceBaseUrl.hostname = `${repositoryName}.${localeServiceBaseUrl.hostname}`;\n\t\tconst url = new URL(\"repository/locales\", localeServiceBaseUrl);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody: {\n\t\t\t\tid: \"en-us\",\n\t\t\t\tisMaster: true,\n\t\t\t\tlabel: \"English - United States\",\n\t\t\t},\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(\"Failed to set default master locale.\");\n\t\t}\n\t}\n\n\tprivate _decodeLimitOrThrow(\n\t\tpotentialLimit: unknown,\n\t\tstatusCode: number,\n\t\tlimitType: PushChangesLimitType,\n\t): PushChangesLimit | null {\n\t\treturn fold<t.Errors, PushChangesRawLimit, PushChangesLimit | null>(\n\t\t\t() => {\n\t\t\t\tconst error: ClientError = {\n\t\t\t\t\tstatus: statusCode,\n\t\t\t\t\tmessage: `Unable to parse raw limit from ${JSON.stringify(\n\t\t\t\t\t\tpotentialLimit,\n\t\t\t\t\t)}`,\n\t\t\t\t};\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t\t(rawLimit: PushChangesRawLimit) => {\n\t\t\t\tconst limit = { ...rawLimit, type: limitType };\n\n\t\t\t\treturn limit;\n\t\t\t},\n\t\t)(PushChangesRawLimit.decode(potentialLimit));\n\t}\n\n\tprivate async _fetch(args: {\n\t\turl: URL;\n\t\tmethod?: \"GET\" | \"POST\" | \"PATCH\";\n\t\tbody?: unknown;\n\t\tuserAgent?: PrismicRepositoryUserAgents;\n\t\trepository?: string;\n\t\tskipAuthentication?: boolean;\n\t}): Promise<Response> {\n\t\tlet cookies;\n\t\ttry {\n\t\t\tcookies = await this.user.getAuthenticationCookies();\n\t\t} catch (e) {\n\t\t\tif (!args.skipAuthentication) {\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\n\t\tconst extraHeaders: Record<string, string> = {};\n\n\t\tif (args.body) {\n\t\t\textraHeaders[\"Content-Type\"] = \"application/json\";\n\t\t}\n\n\t\tif (args.repository) {\n\t\t\textraHeaders.repository = args.repository;\n\t\t}\n\n\t\treturn await fetch(args.url.toString(), {\n\t\t\tmethod: args.method,\n\t\t\tbody: args.body ? JSON.stringify(args.body) : undefined,\n\t\t\theaders: {\n\t\t\t\t// Some endpoints rely on the authorization header...\n\n\t\t\t\t...(cookies !== undefined\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tAuthorization: `Bearer ${cookies[\"prismic-auth\"]}`,\n\t\t\t\t\t\t\tCookie: serializeCookies(cookies),\n\t\t\t\t\t }\n\t\t\t\t\t: {}),\n\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t...extraHeaders,\n\t\t\t},\n\t\t});\n\t}\n}\n"],"names":["BaseManager","API_ENDPOINTS","decode","t","PrismicRepository","PrismicRepositoryRole","PrismicRepositoryUserAgent","REPOSITORY_NAME_VALIDATION","assertPluginsInitialized","UnauthenticatedError","ChangeTypes","PushChangesLimitType","Environment","UnexpectedDataError","sortEnvironments","UnauthorizedError","OnboardingState","z","fold","PushChangesRawLimit","fetch","serializeCookies","SLICE_MACHINE_USER_AGENT"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,8BAA8B;AAAA,EACnC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;;AAwCD,MAAO,iCAAiCA,YAAAA,YAAW;AAAA;AAAA;AAAA,EAIxD,MAAM,UAAO;AACZ,UAAM,MAAM,IAAI,IAAI,kBAAkBC,4BAAc,WAAW;AAC/D,UAAM,MAAM,MAAM,KAAK,OAAO,EAAE,IAAK,CAAA;AAErC,QAAI,IAAI,IAAI;AACL,YAAA,OAAO,MAAM,IAAI;AACjB,YAAA,EAAE,OAAO,cAAc,UAAUC,OAAAA,OACtCC,aAAE,MAAMC,MAAAA,iBAAiB,GACzB,IAAI;AAGL,UAAI,OAAO;AACV,cAAM,IAAI,MACT,kCAAkC,MAAM,OAAO,KAAK,IAAI,GAAG;AAAA,MAE7D;AAEO,aAAA;AAAA,IAAA,OACD;AACA,YAAA,OAAO,MAAM,IAAI;AACvB,YAAM,IAAI,MAAM,+BAA+B,EAAE,OAAO,MAAM;AAAA,IAC/D;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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,cAAA;AAAA,MACP;AAAA,IACD;AAEA,UAAM,eAAuC,CAAA;AAE7C,QAAI,KAAK,MAAM;AACd,mBAAa,cAAc,IAAI;AAAA,IAChC;AAEA,QAAI,KAAK,YAAY;AACpB,mBAAa,aAAa,KAAK;AAAA,IAChC;AAEA,WAAO,MAAMC,MAAAA,QAAM,KAAK,IAAI,YAAY;AAAA,MACvC,QAAQ,KAAK;AAAA,MACb,MAAM,KAAK,OAAO,KAAK,UAAU,KAAK,IAAI,IAAI;AAAA,MAC9C,SAAS;AAAA;AAAA,QAGR,GAAI,YAAY,SACb;AAAA,UACA,eAAe,UAAU,QAAQ,cAAc;AAAA,UAC/C,QAAQC,kCAAiB,OAAO;AAAA,QAAA,IAEhC;QACH,cAAc,KAAK,aAAaC,yBAAA;AAAA,QAChC,GAAG;AAAA,MACH;AAAA,IAAA,CACD;AAAA,EACF;AACA;;"}
1
+ {"version":3,"file":"PrismicRepositoryManager.cjs","sources":["../../../../src/managers/prismicRepository/PrismicRepositoryManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport { z } from \"zod\";\nimport fetch, { Response } from \"../../lib/fetch\";\nimport { fold } from \"fp-ts/Either\";\n\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decode } from \"../../lib/decode\";\nimport { serializeCookies } from \"../../lib/serializeCookies\";\n\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { REPOSITORY_NAME_VALIDATION } from \"../../constants/REPOSITORY_NAME_VALIDATION\";\n\nimport {\n\tUnauthenticatedError,\n\tUnauthorizedError,\n\tUnexpectedDataError,\n} from \"../../errors\";\n\nimport { BaseManager } from \"../BaseManager\";\n\nimport {\n\tAllChangeTypes,\n\tBulkBody,\n\tChangeTypes,\n\tClientError,\n\tPushChangesLimit,\n\tPushChangesLimitType,\n\tPrismicRepository,\n\tPrismicRepositoryRole,\n\tPrismicRepositoryUserAgent,\n\tPrismicRepositoryUserAgents,\n\tPushChangesRawLimit,\n\tTransactionalMergeArgs,\n\tTransactionalMergeReturnType,\n\tFrameworkWroomTelemetryID,\n\tStarterId,\n\tEnvironment,\n\tOnboardingState,\n} from \"./types\";\nimport { sortEnvironments } from \"./sortEnvironments\";\n\nconst DEFAULT_REPOSITORY_SETTINGS = {\n\tplan: \"personal\",\n\tisAnnual: \"false\",\n\trole: \"developer\",\n};\n\ntype PrismicRepositoryManagerCheckExistsArgs = {\n\tdomain: string;\n};\n\ntype PrismicRepositoryManagerCreateArgs = {\n\tdomain: string;\n\tframework: FrameworkWroomTelemetryID;\n\tstarterId?: StarterId;\n};\n\ntype PrismicRepositoryManagerDeleteArgs = {\n\tdomain: string;\n\tpassword: string;\n};\n\ntype PrismicRepositoryManagerPushDocumentsArgs = {\n\tdomain: string;\n\tsignature: string;\n\tdocuments: Record<string, unknown>; // TODO: Type unknown if possible(?)\n};\n\ntype PrismicRepositoryManagerFetchEnvironmentsArgs = {\n\t/**\n\t * If set to `true`, all environments are returned regardless of the user's\n\t * permission level.\n\t *\n\t * If set to `false`, only environments the user can access are returned.\n\t *\n\t * @defaultValue `false`\n\t */\n\tincludeAll?: boolean;\n};\n\ntype PrismicRepositoryManagerFetchEnvironmentsReturnType = {\n\tenvironments?: Environment[];\n};\n\nexport class PrismicRepositoryManager extends BaseManager {\n\t// TODO: Add methods for repository-specific actions. E.g. creating a\n\t// new repository.\n\n\tasync readAll(): Promise<PrismicRepository[]> {\n\t\tconst url = new URL(\"./repositories\", API_ENDPOINTS.PrismicUser);\n\t\tconst res = await this._fetch({ url });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value: repositories, error } = decode(\n\t\t\t\tt.array(PrismicRepository),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to decode repositories: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn repositories;\n\t\t} else {\n\t\t\tconst text = await res.text();\n\t\t\tthrow new Error(`Failed to read repositories`, { cause: text });\n\t\t}\n\t}\n\n\t// Should this be in manager? It's one of the few sync method\n\t//\n\t// Reply from Angelo 2022-12-22: I think it should be in manager\n\t// because we shouldn't be exporting root-level utilities from this\n\t// package. If we want to make it more inline with the other methods,\n\t// we could simplify the API by changing its signature to the\n\t// following:\n\t//\n\t// ```ts\n\t// (repositoryName: string) => Promise<boolean>\n\t// ```\n\t//\n\t// This method would:\n\t//\n\t// 1. Fetch the list of repositories for the user using `readAll()`.\n\t// The list would be cached.\n\t// 2. Determine if the user has write access to the given repository.\n\t//\n\t// This version has the following benefits:\n\t//\n\t// - Does not expect the consumer to supply a repository object; it\n\t// only requires a repository name, which could be sourced from\n\t// anything (incl. the project's `slicemachine.config.json`).\n\t//\n\t// - Similarly, it does not expect the consumer to call `readAll()`\n\t// before calling this method.\n\t//\n\t// - Works for repositories that the user does not have access to. For\n\t// example, I could use it to check if I have access to \"qwerty\",\n\t// even if I am not added as a user. The purpose of the method is\n\t// still valid: do I have write access to a given repository?\n\thasWriteAccess(repository: PrismicRepository): boolean {\n\t\tswitch (repository.role) {\n\t\t\tcase PrismicRepositoryRole.SuperUser:\n\t\t\tcase PrismicRepositoryRole.Owner:\n\t\t\tcase PrismicRepositoryRole.Administrator:\n\t\t\t\treturn true;\n\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tasync checkExists(\n\t\targs: PrismicRepositoryManagerCheckExistsArgs,\n\t): Promise<boolean> {\n\t\tconst url = new URL(\n\t\t\t`./app/dashboard/repositories/${args.domain}/exists`,\n\t\t\tAPI_ENDPOINTS.PrismicWroom,\n\t\t);\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tskipAuthentication: true,\n\t\t});\n\n\t\tconst text = await res.text();\n\n\t\tif (res.ok) {\n\t\t\treturn text === \"false\"; // Endpoint returns `false` when repository exists\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to check repository existence for domain \\`${args.domain}\\``,\n\t\t\t\t{ cause: text },\n\t\t\t);\n\t\t}\n\t}\n\n\tasync create(args: PrismicRepositoryManagerCreateArgs): Promise<void> {\n\t\tconst url = new URL(\n\t\t\t\"./authentication/newrepository?app=slicemachine\",\n\t\t\tAPI_ENDPOINTS.PrismicWroom,\n\t\t);\n\n\t\tconst body = {\n\t\t\t...DEFAULT_REPOSITORY_SETTINGS,\n\t\t\tdomain: args.domain,\n\t\t\t// These properties are optional in the API but needed for tracking\n\t\t\tframework: args.framework,\n\t\t\tstarterId: args.starterId,\n\t\t};\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody,\n\t\t\tuserAgent: PrismicRepositoryUserAgent.SliceMachine, // Custom User Agent is required\n\t\t});\n\t\tconst text = await res.text();\n\n\t\t// Endpoint returns repository name on success, that should be within the validation range\n\t\t// Even when there is an error, we get a 200 success and so we have to check the name thanks to that\n\t\tif (\n\t\t\t!res.ok ||\n\t\t\ttext.length < REPOSITORY_NAME_VALIDATION.Min ||\n\t\t\ttext.length > REPOSITORY_NAME_VALIDATION.Max\n\t\t) {\n\t\t\tthrow new Error(`Failed to create repository \\`${args.domain}\\``, {\n\t\t\t\tcause: text,\n\t\t\t});\n\t\t}\n\t}\n\n\t// TODO: Delete this endpoint? It doesn't seem to be used (I might be wrong). - Angelo\n\tasync delete(args: PrismicRepositoryManagerDeleteArgs): Promise<void> {\n\t\tconst cookies = await this.user.getAuthenticationCookies();\n\n\t\tconst url = new URL(\n\t\t\t`./app/settings/delete?_=${cookies[\"X_XSRF\"]}`, // TODO: Maybe we want to throw early if the token is no available, or get the token another way\n\t\t\tAPI_ENDPOINTS.PrismicWroom,\n\t\t);\n\t\t// Update hostname to include repository domain\n\t\turl.hostname = `${args.domain}.${url.hostname}`;\n\n\t\tconst body = {\n\t\t\tconfirm: args.domain,\n\t\t\tpassword: args.password,\n\t\t};\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody,\n\t\t\tuserAgent: PrismicRepositoryUserAgent.LegacyZero, // Custom User Agent is required\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(`Failed to delete repository \\`${args.domain}\\``, {\n\t\t\t\tcause: res,\n\t\t\t});\n\t\t}\n\t}\n\n\tasync pushDocuments(\n\t\targs: PrismicRepositoryManagerPushDocumentsArgs,\n\t): Promise<void> {\n\t\tconst url = new URL(\"./starter/documents\", API_ENDPOINTS.PrismicWroom);\n\t\t// Update hostname to include repository domain\n\t\turl.hostname = `${args.domain}.${url.hostname}`;\n\n\t\tconst body = {\n\t\t\tsignature: args.signature,\n\t\t\tdocuments: JSON.stringify(args.documents),\n\t\t};\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody,\n\t\t\tuserAgent: PrismicRepositoryUserAgent.LegacyZero, // Custom User Agent is required\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tlet reason: string | null = null;\n\t\t\ttry {\n\t\t\t\treason = await res.text();\n\t\t\t} catch {\n\t\t\t\t// Noop\n\t\t\t}\n\n\t\t\t// Ideally the API should throw a 409 or something like that...\n\t\t\tif (reason === \"Repository should not contain documents\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to push documents to repository \\`${args.domain}\\`, repository is not empty`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: reason,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to push documents to repository \\`${args.domain}\\`, ${res.status} ${res.statusText}`,\n\t\t\t\t{\n\t\t\t\t\tcause: reason,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\tasync pushChanges(\n\t\targs: TransactionalMergeArgs,\n\t): Promise<TransactionalMergeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tif (!(await this.user.checkIsLoggedIn())) {\n\t\t\tthrow new UnauthenticatedError();\n\t\t}\n\n\t\ttry {\n\t\t\t// Update the AWS ACL before uploading screenshots as it might have expired\n\t\t\tawait this.screenshots.initS3ACL();\n\n\t\t\tconst allChanges: AllChangeTypes[] = await Promise.all(\n\t\t\t\targs.changes.map(async (change) => {\n\t\t\t\t\tif (change.type === \"Slice\") {\n\t\t\t\t\t\tswitch (change.status) {\n\t\t\t\t\t\t\tcase \"NEW\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.slices.readSlice({\n\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\tsliceID: change.id,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst modelWithScreenshots =\n\t\t\t\t\t\t\t\t\tawait this.slices.updateSliceModelScreenshotsInPlace({\n\t\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: modelWithScreenshots,\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.SLICE_INSERT,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"MODIFIED\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.slices.readSlice({\n\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\tsliceID: change.id,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst modelWithScreenshots =\n\t\t\t\t\t\t\t\t\tawait this.slices.updateSliceModelScreenshotsInPlace({\n\t\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: modelWithScreenshots,\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.SLICE_UPDATE,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"DELETED\":\n\t\t\t\t\t\t\t\tawait this.screenshots.deleteScreenshotFolder({\n\t\t\t\t\t\t\t\t\tsliceID: change.id,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: { id: change.id },\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.SLICE_DELETE,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tswitch (change.status) {\n\t\t\t\t\t\t\tcase \"NEW\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.CUSTOM_TYPE_INSERT,\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: model,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"MODIFIED\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.CUSTOM_TYPE_UPDATE,\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: model,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"DELETED\":\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: { id: change.id },\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.CUSTOM_TYPE_DELETE,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\t// Compute the POST body\n\t\t\tconst requestBody: BulkBody = {\n\t\t\t\tconfirmDeleteDocuments: args.confirmDeleteDocuments,\n\t\t\t\tchanges: allChanges,\n\t\t\t};\n\n\t\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t\t// TODO: move to customtypes client\n\t\t\tconst response = await this._fetch({\n\t\t\t\turl: new URL(\"./bulk\", API_ENDPOINTS.PrismicModels),\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: requestBody,\n\t\t\t\trepository: repositoryName,\n\t\t\t});\n\n\t\t\tswitch (response.status) {\n\t\t\t\tcase 202:\n\t\t\t\t\treturn this._decodeLimitOrThrow(\n\t\t\t\t\t\tawait response.json(),\n\t\t\t\t\t\tresponse.status,\n\t\t\t\t\t\tPushChangesLimitType.SOFT,\n\t\t\t\t\t);\n\t\t\t\tcase 204:\n\t\t\t\t\treturn null;\n\t\t\t\tcase 401:\n\t\t\t\t\tthrow new UnauthenticatedError();\n\t\t\t\tcase 403:\n\t\t\t\t\treturn this._decodeLimitOrThrow(\n\t\t\t\t\t\tawait response.json(),\n\t\t\t\t\t\tresponse.status,\n\t\t\t\t\t\tPushChangesLimitType.HARD,\n\t\t\t\t\t);\n\t\t\t\tcase 400:\n\t\t\t\t\tconst text = await response.text();\n\t\t\t\t\tthrow new Error(text);\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(`Unexpected status code ${response.status}`, {\n\t\t\t\t\t\tcause: await response.text(),\n\t\t\t\t\t});\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconsole.error(\"An error happened while pushing your changes\");\n\t\t\tconsole.error(err);\n\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tasync fetchEnvironments(\n\t\targs?: PrismicRepositoryManagerFetchEnvironmentsArgs,\n\t): Promise<PrismicRepositoryManagerFetchEnvironmentsReturnType> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(`./environments`, API_ENDPOINTS.SliceMachineV1);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\n\t\tconst res = await this._fetch({ url });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\n\t\t\tconst { value, error } = decode(\n\t\t\t\tt.union([\n\t\t\t\t\tt.type({\n\t\t\t\t\t\tresults: t.array(Environment),\n\t\t\t\t\t}),\n\t\t\t\t\tt.type({\n\t\t\t\t\t\terror: t.literal(\"invalid_token\"),\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode environments: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\"results\" in value) {\n\t\t\t\tlet environments = value.results;\n\n\t\t\t\tif (!args?.includeAll) {\n\t\t\t\t\tconst profile = await this.user.getProfile();\n\n\t\t\t\t\tenvironments = environments.filter((environment) =>\n\t\t\t\t\t\tenvironment.users.some((user) => user.id === profile.shortId),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn { environments: sortEnvironments(environments) };\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to fetch environments.\");\n\t\t}\n\t}\n\n\tasync fetchOnboarding(): Promise<OnboardingState> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\"/onboarding\", API_ENDPOINTS.RepositoryService);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\tconst res = await this._fetch({ url });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value, error } = decode(OnboardingState, json);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode onboarding: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (value) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to fetch onboarding.\");\n\t\t}\n\t}\n\n\tasync toggleOnboardingStep(\n\t\tstepId: string,\n\t): Promise<{ completedSteps: string[] }> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\n\t\t\t`/onboarding/${stepId}/toggle`,\n\t\t\tAPI_ENDPOINTS.RepositoryService,\n\t\t);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\tconst res = await this._fetch({ url, method: \"PATCH\" });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value, error } = decode(\n\t\t\t\tz.object({ completedSteps: z.array(z.string()) }),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode onboarding step toggle: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (value) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to toggle onboarding step.\");\n\t\t}\n\t}\n\n\tasync completeOnboardingStep(\n\t\t...stepIds: string[]\n\t): Promise<{ completedSteps: string[] }> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst currentState = await this.fetchOnboarding();\n\t\tconst incompleteSteps = stepIds.filter(\n\t\t\t(stepId) => !currentState.completedSteps.includes(stepId),\n\t\t);\n\n\t\tif (incompleteSteps.length > 0) {\n\t\t\t// TODO: Refactor when the API accepts multiple steps (DT-2389)\n\t\t\tfor await (const stepId of incompleteSteps) {\n\t\t\t\tconst url = new URL(\n\t\t\t\t\t`/onboarding/${stepId}/toggle`,\n\t\t\t\t\tAPI_ENDPOINTS.RepositoryService,\n\t\t\t\t);\n\t\t\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\t\t\tconst res = await this._fetch({ url, method: \"PATCH\" });\n\n\t\t\t\tif (res.ok) {\n\t\t\t\t\tconst json = await res.json();\n\t\t\t\t\tconst { value, error } = decode(\n\t\t\t\t\t\tz.object({ completedSteps: z.array(z.string()) }),\n\t\t\t\t\t\tjson,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t\t\t`Failed to decode onboarding step complete response: ${error.errors.join(\n\t\t\t\t\t\t\t\t\", \",\n\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (value) {\n\t\t\t\t\t\tcurrentState.completedSteps = value.completedSteps;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tswitch (res.status) {\n\t\t\t\t\tcase 400:\n\t\t\t\t\tcase 401:\n\t\t\t\t\t\tthrow new UnauthenticatedError();\n\t\t\t\t\tcase 403:\n\t\t\t\t\t\tthrow new UnauthorizedError();\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new Error(\"Failed to complete onboarding step.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { completedSteps: currentState.completedSteps };\n\t}\n\n\tasync toggleOnboarding(): Promise<{ isDismissed: boolean }> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\"/onboarding/toggle\", API_ENDPOINTS.RepositoryService);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\tconst res = await this._fetch({ url, method: \"PATCH\" });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value, error } = decode(\n\t\t\t\tz.object({ isDismissed: z.boolean() }),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode onboarding toggle: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (value) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to toggle onboarding guide.\");\n\t\t}\n\t}\n\n\tasync setDefaultMasterLocale(): Promise<void> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\"repository/locales\", API_ENDPOINTS.LocaleService);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody: {\n\t\t\t\tid: \"en-us\",\n\t\t\t\tisMaster: true,\n\t\t\t},\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(\"Failed to set default master locale.\");\n\t\t}\n\t}\n\n\tprivate _decodeLimitOrThrow(\n\t\tpotentialLimit: unknown,\n\t\tstatusCode: number,\n\t\tlimitType: PushChangesLimitType,\n\t): PushChangesLimit | null {\n\t\treturn fold<t.Errors, PushChangesRawLimit, PushChangesLimit | null>(\n\t\t\t() => {\n\t\t\t\tconst error: ClientError = {\n\t\t\t\t\tstatus: statusCode,\n\t\t\t\t\tmessage: `Unable to parse raw limit from ${JSON.stringify(\n\t\t\t\t\t\tpotentialLimit,\n\t\t\t\t\t)}`,\n\t\t\t\t};\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t\t(rawLimit: PushChangesRawLimit) => {\n\t\t\t\tconst limit = { ...rawLimit, type: limitType };\n\n\t\t\t\treturn limit;\n\t\t\t},\n\t\t)(PushChangesRawLimit.decode(potentialLimit));\n\t}\n\n\tprivate async _fetch(args: {\n\t\turl: URL;\n\t\tmethod?: \"GET\" | \"POST\" | \"PATCH\";\n\t\tbody?: unknown;\n\t\tuserAgent?: PrismicRepositoryUserAgents;\n\t\trepository?: string;\n\t\tskipAuthentication?: boolean;\n\t}): Promise<Response> {\n\t\tlet cookies;\n\t\ttry {\n\t\t\tcookies = await this.user.getAuthenticationCookies();\n\t\t} catch (e) {\n\t\t\tif (!args.skipAuthentication) {\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\n\t\tconst extraHeaders: Record<string, string> = {};\n\n\t\tif (args.body) {\n\t\t\textraHeaders[\"Content-Type\"] = \"application/json\";\n\t\t}\n\n\t\tif (args.repository) {\n\t\t\textraHeaders.repository = args.repository;\n\t\t}\n\n\t\treturn await fetch(args.url.toString(), {\n\t\t\tmethod: args.method,\n\t\t\tbody: args.body ? JSON.stringify(args.body) : undefined,\n\t\t\theaders: {\n\t\t\t\t// Some endpoints rely on the authorization header...\n\n\t\t\t\t...(cookies !== undefined\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tAuthorization: `Bearer ${cookies[\"prismic-auth\"]}`,\n\t\t\t\t\t\t\tCookie: serializeCookies(cookies),\n\t\t\t\t\t }\n\t\t\t\t\t: {}),\n\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t...extraHeaders,\n\t\t\t},\n\t\t});\n\t}\n}\n"],"names":["BaseManager","API_ENDPOINTS","decode","t","PrismicRepository","PrismicRepositoryRole","PrismicRepositoryUserAgent","REPOSITORY_NAME_VALIDATION","assertPluginsInitialized","UnauthenticatedError","ChangeTypes","PushChangesLimitType","Environment","UnexpectedDataError","sortEnvironments","UnauthorizedError","OnboardingState","z","fold","PushChangesRawLimit","fetch","serializeCookies","SLICE_MACHINE_USER_AGENT"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,8BAA8B;AAAA,EACnC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;;AAwCD,MAAO,iCAAiCA,YAAAA,YAAW;AAAA;AAAA;AAAA,EAIxD,MAAM,UAAO;AACZ,UAAM,MAAM,IAAI,IAAI,kBAAkBC,4BAAc,WAAW;AAC/D,UAAM,MAAM,MAAM,KAAK,OAAO,EAAE,IAAK,CAAA;AAErC,QAAI,IAAI,IAAI;AACL,YAAA,OAAO,MAAM,IAAI;AACjB,YAAA,EAAE,OAAO,cAAc,UAAUC,OAAAA,OACtCC,aAAE,MAAMC,MAAAA,iBAAiB,GACzB,IAAI;AAGL,UAAI,OAAO;AACV,cAAM,IAAI,MACT,kCAAkC,MAAM,OAAO,KAAK,IAAI,GAAG;AAAA,MAE7D;AAEO,aAAA;AAAA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AA,EAC7C;AAAA,EAEQ,MAAM,OAAO,MAOpB;AACI,QAAA;AACA,QAAA;AACO,gBAAA,MAAM,KAAK,KAAK;aAClB;AACJ,UAAA,CAAC,KAAK,oBAAoB;AACvB,cAAA;AAAA,MACP;AAAA,IACD;AAEA,UAAM,eAAuC,CAAA;AAE7C,QAAI,KAAK,MAAM;AACd,mBAAa,cAAc,IAAI;AAAA,IAChC;AAEA,QAAI,KAAK,YAAY;AACpB,mBAAa,aAAa,KAAK;AAAA,IAChC;AAEA,WAAO,MAAMC,MAAAA,QAAM,KAAK,IAAI,YAAY;AAAA,MACvC,QAAQ,KAAK;AAAA,MACb,MAAM,KAAK,OAAO,KAAK,UAAU,KAAK,IAAI,IAAI;AAAA,MAC9C,SAAS;AAAA;AAAA,QAGR,GAAI,YAAY,SACb;AAAA,UACA,eAAe,UAAU,QAAQ,cAAc;AAAA,UAC/C,QAAQC,kCAAiB,OAAO;AAAA,QAAA,IAEhC;QACH,cAAc,KAAK,aAAaC,yBAAA;AAAA,QAChC,GAAG;AAAA,MACH;AAAA,IAAA,CACD;AAAA,EACF;AACA;;"}
@@ -442,17 +442,14 @@ class PrismicRepositoryManager extends BaseManager {
442
442
  }
443
443
  async setDefaultMasterLocale() {
444
444
  const repositoryName = await this.project.getRepositoryName();
445
- const localeServiceBaseUrl = new URL("locale/", API_ENDPOINTS.PrismicWroom);
446
- localeServiceBaseUrl.hostname = `${repositoryName}.${localeServiceBaseUrl.hostname}`;
447
- const url = new URL("repository/locales", localeServiceBaseUrl);
445
+ const url = new URL("repository/locales", API_ENDPOINTS.LocaleService);
448
446
  url.searchParams.set("repository", repositoryName);
449
447
  const res = await this._fetch({
450
448
  url,
451
449
  method: "POST",
452
450
  body: {
453
451
  id: "en-us",
454
- isMaster: true,
455
- label: "English - United States"
452
+ isMaster: true
456
453
  }
457
454
  });
458
455
  if (!res.ok) {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicRepositoryManager.js","sources":["../../../../src/managers/prismicRepository/PrismicRepositoryManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport { z } from \"zod\";\nimport fetch, { Response } from \"../../lib/fetch\";\nimport { fold } from \"fp-ts/Either\";\n\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decode } from \"../../lib/decode\";\nimport { serializeCookies } from \"../../lib/serializeCookies\";\n\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { REPOSITORY_NAME_VALIDATION } from \"../../constants/REPOSITORY_NAME_VALIDATION\";\n\nimport {\n\tUnauthenticatedError,\n\tUnauthorizedError,\n\tUnexpectedDataError,\n} from \"../../errors\";\n\nimport { BaseManager } from \"../BaseManager\";\n\nimport {\n\tAllChangeTypes,\n\tBulkBody,\n\tChangeTypes,\n\tClientError,\n\tPushChangesLimit,\n\tPushChangesLimitType,\n\tPrismicRepository,\n\tPrismicRepositoryRole,\n\tPrismicRepositoryUserAgent,\n\tPrismicRepositoryUserAgents,\n\tPushChangesRawLimit,\n\tTransactionalMergeArgs,\n\tTransactionalMergeReturnType,\n\tFrameworkWroomTelemetryID,\n\tStarterId,\n\tEnvironment,\n\tOnboardingState,\n} from \"./types\";\nimport { sortEnvironments } from \"./sortEnvironments\";\n\nconst DEFAULT_REPOSITORY_SETTINGS = {\n\tplan: \"personal\",\n\tisAnnual: \"false\",\n\trole: \"developer\",\n};\n\ntype PrismicRepositoryManagerCheckExistsArgs = {\n\tdomain: string;\n};\n\ntype PrismicRepositoryManagerCreateArgs = {\n\tdomain: string;\n\tframework: FrameworkWroomTelemetryID;\n\tstarterId?: StarterId;\n};\n\ntype PrismicRepositoryManagerDeleteArgs = {\n\tdomain: string;\n\tpassword: string;\n};\n\ntype PrismicRepositoryManagerPushDocumentsArgs = {\n\tdomain: string;\n\tsignature: string;\n\tdocuments: Record<string, unknown>; // TODO: Type unknown if possible(?)\n};\n\ntype PrismicRepositoryManagerFetchEnvironmentsArgs = {\n\t/**\n\t * If set to `true`, all environments are returned regardless of the user's\n\t * permission level.\n\t *\n\t * If set to `false`, only environments the user can access are returned.\n\t *\n\t * @defaultValue `false`\n\t */\n\tincludeAll?: boolean;\n};\n\ntype PrismicRepositoryManagerFetchEnvironmentsReturnType = {\n\tenvironments?: Environment[];\n};\n\nexport class PrismicRepositoryManager extends BaseManager {\n\t// TODO: Add methods for repository-specific actions. E.g. creating a\n\t// new repository.\n\n\tasync readAll(): Promise<PrismicRepository[]> {\n\t\tconst url = new URL(\"./repositories\", API_ENDPOINTS.PrismicUser);\n\t\tconst res = await this._fetch({ url });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value: repositories, error } = decode(\n\t\t\t\tt.array(PrismicRepository),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to decode repositories: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn repositories;\n\t\t} else {\n\t\t\tconst text = await res.text();\n\t\t\tthrow new Error(`Failed to read repositories`, { cause: text });\n\t\t}\n\t}\n\n\t// Should this be in manager? It's one of the few sync method\n\t//\n\t// Reply from Angelo 2022-12-22: I think it should be in manager\n\t// because we shouldn't be exporting root-level utilities from this\n\t// package. If we want to make it more inline with the other methods,\n\t// we could simplify the API by changing its signature to the\n\t// following:\n\t//\n\t// ```ts\n\t// (repositoryName: string) => Promise<boolean>\n\t// ```\n\t//\n\t// This method would:\n\t//\n\t// 1. Fetch the list of repositories for the user using `readAll()`.\n\t// The list would be cached.\n\t// 2. Determine if the user has write access to the given repository.\n\t//\n\t// This version has the following benefits:\n\t//\n\t// - Does not expect the consumer to supply a repository object; it\n\t// only requires a repository name, which could be sourced from\n\t// anything (incl. the project's `slicemachine.config.json`).\n\t//\n\t// - Similarly, it does not expect the consumer to call `readAll()`\n\t// before calling this method.\n\t//\n\t// - Works for repositories that the user does not have access to. For\n\t// example, I could use it to check if I have access to \"qwerty\",\n\t// even if I am not added as a user. The purpose of the method is\n\t// still valid: do I have write access to a given repository?\n\thasWriteAccess(repository: PrismicRepository): boolean {\n\t\tswitch (repository.role) {\n\t\t\tcase PrismicRepositoryRole.SuperUser:\n\t\t\tcase PrismicRepositoryRole.Owner:\n\t\t\tcase PrismicRepositoryRole.Administrator:\n\t\t\t\treturn true;\n\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tasync checkExists(\n\t\targs: PrismicRepositoryManagerCheckExistsArgs,\n\t): Promise<boolean> {\n\t\tconst url = new URL(\n\t\t\t`./app/dashboard/repositories/${args.domain}/exists`,\n\t\t\tAPI_ENDPOINTS.PrismicWroom,\n\t\t);\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tskipAuthentication: true,\n\t\t});\n\n\t\tconst text = await res.text();\n\n\t\tif (res.ok) {\n\t\t\treturn text === \"false\"; // Endpoint returns `false` when repository exists\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to check repository existence for domain \\`${args.domain}\\``,\n\t\t\t\t{ cause: text },\n\t\t\t);\n\t\t}\n\t}\n\n\tasync create(args: PrismicRepositoryManagerCreateArgs): Promise<void> {\n\t\tconst url = new URL(\n\t\t\t\"./authentication/newrepository?app=slicemachine\",\n\t\t\tAPI_ENDPOINTS.PrismicWroom,\n\t\t);\n\n\t\tconst body = {\n\t\t\t...DEFAULT_REPOSITORY_SETTINGS,\n\t\t\tdomain: args.domain,\n\t\t\t// These properties are optional in the API but needed for tracking\n\t\t\tframework: args.framework,\n\t\t\tstarterId: args.starterId,\n\t\t};\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody,\n\t\t\tuserAgent: PrismicRepositoryUserAgent.SliceMachine, // Custom User Agent is required\n\t\t});\n\t\tconst text = await res.text();\n\n\t\t// Endpoint returns repository name on success, that should be within the validation range\n\t\t// Even when there is an error, we get a 200 success and so we have to check the name thanks to that\n\t\tif (\n\t\t\t!res.ok ||\n\t\t\ttext.length < REPOSITORY_NAME_VALIDATION.Min ||\n\t\t\ttext.length > REPOSITORY_NAME_VALIDATION.Max\n\t\t) {\n\t\t\tthrow new Error(`Failed to create repository \\`${args.domain}\\``, {\n\t\t\t\tcause: text,\n\t\t\t});\n\t\t}\n\t}\n\n\t// TODO: Delete this endpoint? It doesn't seem to be used (I might be wrong). - Angelo\n\tasync delete(args: PrismicRepositoryManagerDeleteArgs): Promise<void> {\n\t\tconst cookies = await this.user.getAuthenticationCookies();\n\n\t\tconst url = new URL(\n\t\t\t`./app/settings/delete?_=${cookies[\"X_XSRF\"]}`, // TODO: Maybe we want to throw early if the token is no available, or get the token another way\n\t\t\tAPI_ENDPOINTS.PrismicWroom,\n\t\t);\n\t\t// Update hostname to include repository domain\n\t\turl.hostname = `${args.domain}.${url.hostname}`;\n\n\t\tconst body = {\n\t\t\tconfirm: args.domain,\n\t\t\tpassword: args.password,\n\t\t};\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody,\n\t\t\tuserAgent: PrismicRepositoryUserAgent.LegacyZero, // Custom User Agent is required\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(`Failed to delete repository \\`${args.domain}\\``, {\n\t\t\t\tcause: res,\n\t\t\t});\n\t\t}\n\t}\n\n\tasync pushDocuments(\n\t\targs: PrismicRepositoryManagerPushDocumentsArgs,\n\t): Promise<void> {\n\t\tconst url = new URL(\"./starter/documents\", API_ENDPOINTS.PrismicWroom);\n\t\t// Update hostname to include repository domain\n\t\turl.hostname = `${args.domain}.${url.hostname}`;\n\n\t\tconst body = {\n\t\t\tsignature: args.signature,\n\t\t\tdocuments: JSON.stringify(args.documents),\n\t\t};\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody,\n\t\t\tuserAgent: PrismicRepositoryUserAgent.LegacyZero, // Custom User Agent is required\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tlet reason: string | null = null;\n\t\t\ttry {\n\t\t\t\treason = await res.text();\n\t\t\t} catch {\n\t\t\t\t// Noop\n\t\t\t}\n\n\t\t\t// Ideally the API should throw a 409 or something like that...\n\t\t\tif (reason === \"Repository should not contain documents\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to push documents to repository \\`${args.domain}\\`, repository is not empty`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: reason,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to push documents to repository \\`${args.domain}\\`, ${res.status} ${res.statusText}`,\n\t\t\t\t{\n\t\t\t\t\tcause: reason,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\tasync pushChanges(\n\t\targs: TransactionalMergeArgs,\n\t): Promise<TransactionalMergeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tif (!(await this.user.checkIsLoggedIn())) {\n\t\t\tthrow new UnauthenticatedError();\n\t\t}\n\n\t\ttry {\n\t\t\t// Update the AWS ACL before uploading screenshots as it might have expired\n\t\t\tawait this.screenshots.initS3ACL();\n\n\t\t\tconst allChanges: AllChangeTypes[] = await Promise.all(\n\t\t\t\targs.changes.map(async (change) => {\n\t\t\t\t\tif (change.type === \"Slice\") {\n\t\t\t\t\t\tswitch (change.status) {\n\t\t\t\t\t\t\tcase \"NEW\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.slices.readSlice({\n\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\tsliceID: change.id,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst modelWithScreenshots =\n\t\t\t\t\t\t\t\t\tawait this.slices.updateSliceModelScreenshotsInPlace({\n\t\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: modelWithScreenshots,\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.SLICE_INSERT,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"MODIFIED\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.slices.readSlice({\n\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\tsliceID: change.id,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst modelWithScreenshots =\n\t\t\t\t\t\t\t\t\tawait this.slices.updateSliceModelScreenshotsInPlace({\n\t\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: modelWithScreenshots,\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.SLICE_UPDATE,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"DELETED\":\n\t\t\t\t\t\t\t\tawait this.screenshots.deleteScreenshotFolder({\n\t\t\t\t\t\t\t\t\tsliceID: change.id,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: { id: change.id },\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.SLICE_DELETE,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tswitch (change.status) {\n\t\t\t\t\t\t\tcase \"NEW\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.CUSTOM_TYPE_INSERT,\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: model,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"MODIFIED\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.CUSTOM_TYPE_UPDATE,\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: model,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"DELETED\":\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: { id: change.id },\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.CUSTOM_TYPE_DELETE,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\t// Compute the POST body\n\t\t\tconst requestBody: BulkBody = {\n\t\t\t\tconfirmDeleteDocuments: args.confirmDeleteDocuments,\n\t\t\t\tchanges: allChanges,\n\t\t\t};\n\n\t\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t\t// TODO: move to customtypes client\n\t\t\tconst response = await this._fetch({\n\t\t\t\turl: new URL(\"./bulk\", API_ENDPOINTS.PrismicModels),\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: requestBody,\n\t\t\t\trepository: repositoryName,\n\t\t\t});\n\n\t\t\tswitch (response.status) {\n\t\t\t\tcase 202:\n\t\t\t\t\treturn this._decodeLimitOrThrow(\n\t\t\t\t\t\tawait response.json(),\n\t\t\t\t\t\tresponse.status,\n\t\t\t\t\t\tPushChangesLimitType.SOFT,\n\t\t\t\t\t);\n\t\t\t\tcase 204:\n\t\t\t\t\treturn null;\n\t\t\t\tcase 401:\n\t\t\t\t\tthrow new UnauthenticatedError();\n\t\t\t\tcase 403:\n\t\t\t\t\treturn this._decodeLimitOrThrow(\n\t\t\t\t\t\tawait response.json(),\n\t\t\t\t\t\tresponse.status,\n\t\t\t\t\t\tPushChangesLimitType.HARD,\n\t\t\t\t\t);\n\t\t\t\tcase 400:\n\t\t\t\t\tconst text = await response.text();\n\t\t\t\t\tthrow new Error(text);\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(`Unexpected status code ${response.status}`, {\n\t\t\t\t\t\tcause: await response.text(),\n\t\t\t\t\t});\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconsole.error(\"An error happened while pushing your changes\");\n\t\t\tconsole.error(err);\n\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tasync fetchEnvironments(\n\t\targs?: PrismicRepositoryManagerFetchEnvironmentsArgs,\n\t): Promise<PrismicRepositoryManagerFetchEnvironmentsReturnType> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(`./environments`, API_ENDPOINTS.SliceMachineV1);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\n\t\tconst res = await this._fetch({ url });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\n\t\t\tconst { value, error } = decode(\n\t\t\t\tt.union([\n\t\t\t\t\tt.type({\n\t\t\t\t\t\tresults: t.array(Environment),\n\t\t\t\t\t}),\n\t\t\t\t\tt.type({\n\t\t\t\t\t\terror: t.literal(\"invalid_token\"),\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode environments: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\"results\" in value) {\n\t\t\t\tlet environments = value.results;\n\n\t\t\t\tif (!args?.includeAll) {\n\t\t\t\t\tconst profile = await this.user.getProfile();\n\n\t\t\t\t\tenvironments = environments.filter((environment) =>\n\t\t\t\t\t\tenvironment.users.some((user) => user.id === profile.shortId),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn { environments: sortEnvironments(environments) };\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to fetch environments.\");\n\t\t}\n\t}\n\n\tasync fetchOnboarding(): Promise<OnboardingState> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\"/onboarding\", API_ENDPOINTS.RepositoryService);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\tconst res = await this._fetch({ url });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value, error } = decode(OnboardingState, json);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode onboarding: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (value) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to fetch onboarding.\");\n\t\t}\n\t}\n\n\tasync toggleOnboardingStep(\n\t\tstepId: string,\n\t): Promise<{ completedSteps: string[] }> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\n\t\t\t`/onboarding/${stepId}/toggle`,\n\t\t\tAPI_ENDPOINTS.RepositoryService,\n\t\t);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\tconst res = await this._fetch({ url, method: \"PATCH\" });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value, error } = decode(\n\t\t\t\tz.object({ completedSteps: z.array(z.string()) }),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode onboarding step toggle: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (value) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to toggle onboarding step.\");\n\t\t}\n\t}\n\n\tasync completeOnboardingStep(\n\t\t...stepIds: string[]\n\t): Promise<{ completedSteps: string[] }> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst currentState = await this.fetchOnboarding();\n\t\tconst incompleteSteps = stepIds.filter(\n\t\t\t(stepId) => !currentState.completedSteps.includes(stepId),\n\t\t);\n\n\t\tif (incompleteSteps.length > 0) {\n\t\t\t// TODO: Refactor when the API accepts multiple steps (DT-2389)\n\t\t\tfor await (const stepId of incompleteSteps) {\n\t\t\t\tconst url = new URL(\n\t\t\t\t\t`/onboarding/${stepId}/toggle`,\n\t\t\t\t\tAPI_ENDPOINTS.RepositoryService,\n\t\t\t\t);\n\t\t\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\t\t\tconst res = await this._fetch({ url, method: \"PATCH\" });\n\n\t\t\t\tif (res.ok) {\n\t\t\t\t\tconst json = await res.json();\n\t\t\t\t\tconst { value, error } = decode(\n\t\t\t\t\t\tz.object({ completedSteps: z.array(z.string()) }),\n\t\t\t\t\t\tjson,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t\t\t`Failed to decode onboarding step complete response: ${error.errors.join(\n\t\t\t\t\t\t\t\t\", \",\n\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (value) {\n\t\t\t\t\t\tcurrentState.completedSteps = value.completedSteps;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tswitch (res.status) {\n\t\t\t\t\tcase 400:\n\t\t\t\t\tcase 401:\n\t\t\t\t\t\tthrow new UnauthenticatedError();\n\t\t\t\t\tcase 403:\n\t\t\t\t\t\tthrow new UnauthorizedError();\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new Error(\"Failed to complete onboarding step.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { completedSteps: currentState.completedSteps };\n\t}\n\n\tasync toggleOnboarding(): Promise<{ isDismissed: boolean }> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\"/onboarding/toggle\", API_ENDPOINTS.RepositoryService);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\tconst res = await this._fetch({ url, method: \"PATCH\" });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value, error } = decode(\n\t\t\t\tz.object({ isDismissed: z.boolean() }),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode onboarding toggle: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (value) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to toggle onboarding guide.\");\n\t\t}\n\t}\n\n\tasync setDefaultMasterLocale(): Promise<void> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst localeServiceBaseUrl = new URL(\"locale/\", API_ENDPOINTS.PrismicWroom);\n\t\tlocaleServiceBaseUrl.hostname = `${repositoryName}.${localeServiceBaseUrl.hostname}`;\n\t\tconst url = new URL(\"repository/locales\", localeServiceBaseUrl);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody: {\n\t\t\t\tid: \"en-us\",\n\t\t\t\tisMaster: true,\n\t\t\t\tlabel: \"English - United States\",\n\t\t\t},\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(\"Failed to set default master locale.\");\n\t\t}\n\t}\n\n\tprivate _decodeLimitOrThrow(\n\t\tpotentialLimit: unknown,\n\t\tstatusCode: number,\n\t\tlimitType: PushChangesLimitType,\n\t): PushChangesLimit | null {\n\t\treturn fold<t.Errors, PushChangesRawLimit, PushChangesLimit | null>(\n\t\t\t() => {\n\t\t\t\tconst error: ClientError = {\n\t\t\t\t\tstatus: statusCode,\n\t\t\t\t\tmessage: `Unable to parse raw limit from ${JSON.stringify(\n\t\t\t\t\t\tpotentialLimit,\n\t\t\t\t\t)}`,\n\t\t\t\t};\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t\t(rawLimit: PushChangesRawLimit) => {\n\t\t\t\tconst limit = { ...rawLimit, type: limitType };\n\n\t\t\t\treturn limit;\n\t\t\t},\n\t\t)(PushChangesRawLimit.decode(potentialLimit));\n\t}\n\n\tprivate async _fetch(args: {\n\t\turl: URL;\n\t\tmethod?: \"GET\" | \"POST\" | \"PATCH\";\n\t\tbody?: unknown;\n\t\tuserAgent?: PrismicRepositoryUserAgents;\n\t\trepository?: string;\n\t\tskipAuthentication?: boolean;\n\t}): Promise<Response> {\n\t\tlet cookies;\n\t\ttry {\n\t\t\tcookies = await this.user.getAuthenticationCookies();\n\t\t} catch (e) {\n\t\t\tif (!args.skipAuthentication) {\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\n\t\tconst extraHeaders: Record<string, string> = {};\n\n\t\tif (args.body) {\n\t\t\textraHeaders[\"Content-Type\"] = \"application/json\";\n\t\t}\n\n\t\tif (args.repository) {\n\t\t\textraHeaders.repository = args.repository;\n\t\t}\n\n\t\treturn await fetch(args.url.toString(), {\n\t\t\tmethod: args.method,\n\t\t\tbody: args.body ? JSON.stringify(args.body) : undefined,\n\t\t\theaders: {\n\t\t\t\t// Some endpoints rely on the authorization header...\n\n\t\t\t\t...(cookies !== undefined\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tAuthorization: `Bearer ${cookies[\"prismic-auth\"]}`,\n\t\t\t\t\t\t\tCookie: serializeCookies(cookies),\n\t\t\t\t\t }\n\t\t\t\t\t: {}),\n\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t...extraHeaders,\n\t\t\t},\n\t\t});\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA0CA,MA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A,MAAA;AAGV,YAAA;AAAA,IACP,GACA,CAAC,aAAiC;AACjC,YAAM,QAAQ,EAAE,GAAG,UAAU,MAAM,UAAS;AAErC,aAAA;AAAA,IACP,CAAA,EACA,oBAAoB,OAAO,cAAc,CAAC;AAAA,EAC7C;AAAA,EAEQ,MAAM,OAAO,MAOpB;AACI,QAAA;AACA,QAAA;AACO,gBAAA,MAAM,KAAK,KAAK;aAClB;AACJ,UAAA,CAAC,KAAK,oBAAoB;AACvB,cAAA;AAAA,MACP;AAAA,IACD;AAEA,UAAM,eAAuC,CAAA;AAE7C,QAAI,KAAK,MAAM;AACd,mBAAa,cAAc,IAAI;AAAA,IAChC;AAEA,QAAI,KAAK,YAAY;AACpB,mBAAa,aAAa,KAAK;AAAA,IAChC;AAEA,WAAO,MAAM,MAAM,KAAK,IAAI,YAAY;AAAA,MACvC,QAAQ,KAAK;AAAA,MACb,MAAM,KAAK,OAAO,KAAK,UAAU,KAAK,IAAI,IAAI;AAAA,MAC9C,SAAS;AAAA;AAAA,QAGR,GAAI,YAAY,SACb;AAAA,UACA,eAAe,UAAU,QAAQ,cAAc;AAAA,UAC/C,QAAQ,iBAAiB,OAAO;AAAA,QAAA,IAEhC;QACH,cAAc,KAAK,aAAa;AAAA,QAChC,GAAG;AAAA,MACH;AAAA,IAAA,CACD;AAAA,EACF;AACA;"}
1
+ {"version":3,"file":"PrismicRepositoryManager.js","sources":["../../../../src/managers/prismicRepository/PrismicRepositoryManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport { z } from \"zod\";\nimport fetch, { Response } from \"../../lib/fetch\";\nimport { fold } from \"fp-ts/Either\";\n\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decode } from \"../../lib/decode\";\nimport { serializeCookies } from \"../../lib/serializeCookies\";\n\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { REPOSITORY_NAME_VALIDATION } from \"../../constants/REPOSITORY_NAME_VALIDATION\";\n\nimport {\n\tUnauthenticatedError,\n\tUnauthorizedError,\n\tUnexpectedDataError,\n} from \"../../errors\";\n\nimport { BaseManager } from \"../BaseManager\";\n\nimport {\n\tAllChangeTypes,\n\tBulkBody,\n\tChangeTypes,\n\tClientError,\n\tPushChangesLimit,\n\tPushChangesLimitType,\n\tPrismicRepository,\n\tPrismicRepositoryRole,\n\tPrismicRepositoryUserAgent,\n\tPrismicRepositoryUserAgents,\n\tPushChangesRawLimit,\n\tTransactionalMergeArgs,\n\tTransactionalMergeReturnType,\n\tFrameworkWroomTelemetryID,\n\tStarterId,\n\tEnvironment,\n\tOnboardingState,\n} from \"./types\";\nimport { sortEnvironments } from \"./sortEnvironments\";\n\nconst DEFAULT_REPOSITORY_SETTINGS = {\n\tplan: \"personal\",\n\tisAnnual: \"false\",\n\trole: \"developer\",\n};\n\ntype PrismicRepositoryManagerCheckExistsArgs = {\n\tdomain: string;\n};\n\ntype PrismicRepositoryManagerCreateArgs = {\n\tdomain: string;\n\tframework: FrameworkWroomTelemetryID;\n\tstarterId?: StarterId;\n};\n\ntype PrismicRepositoryManagerDeleteArgs = {\n\tdomain: string;\n\tpassword: string;\n};\n\ntype PrismicRepositoryManagerPushDocumentsArgs = {\n\tdomain: string;\n\tsignature: string;\n\tdocuments: Record<string, unknown>; // TODO: Type unknown if possible(?)\n};\n\ntype PrismicRepositoryManagerFetchEnvironmentsArgs = {\n\t/**\n\t * If set to `true`, all environments are returned regardless of the user's\n\t * permission level.\n\t *\n\t * If set to `false`, only environments the user can access are returned.\n\t *\n\t * @defaultValue `false`\n\t */\n\tincludeAll?: boolean;\n};\n\ntype PrismicRepositoryManagerFetchEnvironmentsReturnType = {\n\tenvironments?: Environment[];\n};\n\nexport class PrismicRepositoryManager extends BaseManager {\n\t// TODO: Add methods for repository-specific actions. E.g. creating a\n\t// new repository.\n\n\tasync readAll(): Promise<PrismicRepository[]> {\n\t\tconst url = new URL(\"./repositories\", API_ENDPOINTS.PrismicUser);\n\t\tconst res = await this._fetch({ url });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value: repositories, error } = decode(\n\t\t\t\tt.array(PrismicRepository),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to decode repositories: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn repositories;\n\t\t} else {\n\t\t\tconst text = await res.text();\n\t\t\tthrow new Error(`Failed to read repositories`, { cause: text });\n\t\t}\n\t}\n\n\t// Should this be in manager? It's one of the few sync method\n\t//\n\t// Reply from Angelo 2022-12-22: I think it should be in manager\n\t// because we shouldn't be exporting root-level utilities from this\n\t// package. If we want to make it more inline with the other methods,\n\t// we could simplify the API by changing its signature to the\n\t// following:\n\t//\n\t// ```ts\n\t// (repositoryName: string) => Promise<boolean>\n\t// ```\n\t//\n\t// This method would:\n\t//\n\t// 1. Fetch the list of repositories for the user using `readAll()`.\n\t// The list would be cached.\n\t// 2. Determine if the user has write access to the given repository.\n\t//\n\t// This version has the following benefits:\n\t//\n\t// - Does not expect the consumer to supply a repository object; it\n\t// only requires a repository name, which could be sourced from\n\t// anything (incl. the project's `slicemachine.config.json`).\n\t//\n\t// - Similarly, it does not expect the consumer to call `readAll()`\n\t// before calling this method.\n\t//\n\t// - Works for repositories that the user does not have access to. For\n\t// example, I could use it to check if I have access to \"qwerty\",\n\t// even if I am not added as a user. The purpose of the method is\n\t// still valid: do I have write access to a given repository?\n\thasWriteAccess(repository: PrismicRepository): boolean {\n\t\tswitch (repository.role) {\n\t\t\tcase PrismicRepositoryRole.SuperUser:\n\t\t\tcase PrismicRepositoryRole.Owner:\n\t\t\tcase PrismicRepositoryRole.Administrator:\n\t\t\t\treturn true;\n\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tasync checkExists(\n\t\targs: PrismicRepositoryManagerCheckExistsArgs,\n\t): Promise<boolean> {\n\t\tconst url = new URL(\n\t\t\t`./app/dashboard/repositories/${args.domain}/exists`,\n\t\t\tAPI_ENDPOINTS.PrismicWroom,\n\t\t);\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tskipAuthentication: true,\n\t\t});\n\n\t\tconst text = await res.text();\n\n\t\tif (res.ok) {\n\t\t\treturn text === \"false\"; // Endpoint returns `false` when repository exists\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to check repository existence for domain \\`${args.domain}\\``,\n\t\t\t\t{ cause: text },\n\t\t\t);\n\t\t}\n\t}\n\n\tasync create(args: PrismicRepositoryManagerCreateArgs): Promise<void> {\n\t\tconst url = new URL(\n\t\t\t\"./authentication/newrepository?app=slicemachine\",\n\t\t\tAPI_ENDPOINTS.PrismicWroom,\n\t\t);\n\n\t\tconst body = {\n\t\t\t...DEFAULT_REPOSITORY_SETTINGS,\n\t\t\tdomain: args.domain,\n\t\t\t// These properties are optional in the API but needed for tracking\n\t\t\tframework: args.framework,\n\t\t\tstarterId: args.starterId,\n\t\t};\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody,\n\t\t\tuserAgent: PrismicRepositoryUserAgent.SliceMachine, // Custom User Agent is required\n\t\t});\n\t\tconst text = await res.text();\n\n\t\t// Endpoint returns repository name on success, that should be within the validation range\n\t\t// Even when there is an error, we get a 200 success and so we have to check the name thanks to that\n\t\tif (\n\t\t\t!res.ok ||\n\t\t\ttext.length < REPOSITORY_NAME_VALIDATION.Min ||\n\t\t\ttext.length > REPOSITORY_NAME_VALIDATION.Max\n\t\t) {\n\t\t\tthrow new Error(`Failed to create repository \\`${args.domain}\\``, {\n\t\t\t\tcause: text,\n\t\t\t});\n\t\t}\n\t}\n\n\t// TODO: Delete this endpoint? It doesn't seem to be used (I might be wrong). - Angelo\n\tasync delete(args: PrismicRepositoryManagerDeleteArgs): Promise<void> {\n\t\tconst cookies = await this.user.getAuthenticationCookies();\n\n\t\tconst url = new URL(\n\t\t\t`./app/settings/delete?_=${cookies[\"X_XSRF\"]}`, // TODO: Maybe we want to throw early if the token is no available, or get the token another way\n\t\t\tAPI_ENDPOINTS.PrismicWroom,\n\t\t);\n\t\t// Update hostname to include repository domain\n\t\turl.hostname = `${args.domain}.${url.hostname}`;\n\n\t\tconst body = {\n\t\t\tconfirm: args.domain,\n\t\t\tpassword: args.password,\n\t\t};\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody,\n\t\t\tuserAgent: PrismicRepositoryUserAgent.LegacyZero, // Custom User Agent is required\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(`Failed to delete repository \\`${args.domain}\\``, {\n\t\t\t\tcause: res,\n\t\t\t});\n\t\t}\n\t}\n\n\tasync pushDocuments(\n\t\targs: PrismicRepositoryManagerPushDocumentsArgs,\n\t): Promise<void> {\n\t\tconst url = new URL(\"./starter/documents\", API_ENDPOINTS.PrismicWroom);\n\t\t// Update hostname to include repository domain\n\t\turl.hostname = `${args.domain}.${url.hostname}`;\n\n\t\tconst body = {\n\t\t\tsignature: args.signature,\n\t\t\tdocuments: JSON.stringify(args.documents),\n\t\t};\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody,\n\t\t\tuserAgent: PrismicRepositoryUserAgent.LegacyZero, // Custom User Agent is required\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tlet reason: string | null = null;\n\t\t\ttry {\n\t\t\t\treason = await res.text();\n\t\t\t} catch {\n\t\t\t\t// Noop\n\t\t\t}\n\n\t\t\t// Ideally the API should throw a 409 or something like that...\n\t\t\tif (reason === \"Repository should not contain documents\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to push documents to repository \\`${args.domain}\\`, repository is not empty`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: reason,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to push documents to repository \\`${args.domain}\\`, ${res.status} ${res.statusText}`,\n\t\t\t\t{\n\t\t\t\t\tcause: reason,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\tasync pushChanges(\n\t\targs: TransactionalMergeArgs,\n\t): Promise<TransactionalMergeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tif (!(await this.user.checkIsLoggedIn())) {\n\t\t\tthrow new UnauthenticatedError();\n\t\t}\n\n\t\ttry {\n\t\t\t// Update the AWS ACL before uploading screenshots as it might have expired\n\t\t\tawait this.screenshots.initS3ACL();\n\n\t\t\tconst allChanges: AllChangeTypes[] = await Promise.all(\n\t\t\t\targs.changes.map(async (change) => {\n\t\t\t\t\tif (change.type === \"Slice\") {\n\t\t\t\t\t\tswitch (change.status) {\n\t\t\t\t\t\t\tcase \"NEW\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.slices.readSlice({\n\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\tsliceID: change.id,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst modelWithScreenshots =\n\t\t\t\t\t\t\t\t\tawait this.slices.updateSliceModelScreenshotsInPlace({\n\t\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: modelWithScreenshots,\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.SLICE_INSERT,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"MODIFIED\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.slices.readSlice({\n\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\tsliceID: change.id,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst modelWithScreenshots =\n\t\t\t\t\t\t\t\t\tawait this.slices.updateSliceModelScreenshotsInPlace({\n\t\t\t\t\t\t\t\t\t\tlibraryID: change.libraryID,\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: modelWithScreenshots,\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.SLICE_UPDATE,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"DELETED\":\n\t\t\t\t\t\t\t\tawait this.screenshots.deleteScreenshotFolder({\n\t\t\t\t\t\t\t\t\tsliceID: change.id,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: { id: change.id },\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.SLICE_DELETE,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tswitch (change.status) {\n\t\t\t\t\t\t\tcase \"NEW\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.CUSTOM_TYPE_INSERT,\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: model,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"MODIFIED\": {\n\t\t\t\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!model) {\n\t\t\t\t\t\t\t\t\tthrow Error(`Could not find model ${change.id}`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.CUSTOM_TYPE_UPDATE,\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: model,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"DELETED\":\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: change.id,\n\t\t\t\t\t\t\t\t\tpayload: { id: change.id },\n\t\t\t\t\t\t\t\t\ttype: ChangeTypes.CUSTOM_TYPE_DELETE,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\t// Compute the POST body\n\t\t\tconst requestBody: BulkBody = {\n\t\t\t\tconfirmDeleteDocuments: args.confirmDeleteDocuments,\n\t\t\t\tchanges: allChanges,\n\t\t\t};\n\n\t\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t\t// TODO: move to customtypes client\n\t\t\tconst response = await this._fetch({\n\t\t\t\turl: new URL(\"./bulk\", API_ENDPOINTS.PrismicModels),\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: requestBody,\n\t\t\t\trepository: repositoryName,\n\t\t\t});\n\n\t\t\tswitch (response.status) {\n\t\t\t\tcase 202:\n\t\t\t\t\treturn this._decodeLimitOrThrow(\n\t\t\t\t\t\tawait response.json(),\n\t\t\t\t\t\tresponse.status,\n\t\t\t\t\t\tPushChangesLimitType.SOFT,\n\t\t\t\t\t);\n\t\t\t\tcase 204:\n\t\t\t\t\treturn null;\n\t\t\t\tcase 401:\n\t\t\t\t\tthrow new UnauthenticatedError();\n\t\t\t\tcase 403:\n\t\t\t\t\treturn this._decodeLimitOrThrow(\n\t\t\t\t\t\tawait response.json(),\n\t\t\t\t\t\tresponse.status,\n\t\t\t\t\t\tPushChangesLimitType.HARD,\n\t\t\t\t\t);\n\t\t\t\tcase 400:\n\t\t\t\t\tconst text = await response.text();\n\t\t\t\t\tthrow new Error(text);\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(`Unexpected status code ${response.status}`, {\n\t\t\t\t\t\tcause: await response.text(),\n\t\t\t\t\t});\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconsole.error(\"An error happened while pushing your changes\");\n\t\t\tconsole.error(err);\n\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tasync fetchEnvironments(\n\t\targs?: PrismicRepositoryManagerFetchEnvironmentsArgs,\n\t): Promise<PrismicRepositoryManagerFetchEnvironmentsReturnType> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(`./environments`, API_ENDPOINTS.SliceMachineV1);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\n\t\tconst res = await this._fetch({ url });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\n\t\t\tconst { value, error } = decode(\n\t\t\t\tt.union([\n\t\t\t\t\tt.type({\n\t\t\t\t\t\tresults: t.array(Environment),\n\t\t\t\t\t}),\n\t\t\t\t\tt.type({\n\t\t\t\t\t\terror: t.literal(\"invalid_token\"),\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode environments: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\"results\" in value) {\n\t\t\t\tlet environments = value.results;\n\n\t\t\t\tif (!args?.includeAll) {\n\t\t\t\t\tconst profile = await this.user.getProfile();\n\n\t\t\t\t\tenvironments = environments.filter((environment) =>\n\t\t\t\t\t\tenvironment.users.some((user) => user.id === profile.shortId),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn { environments: sortEnvironments(environments) };\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to fetch environments.\");\n\t\t}\n\t}\n\n\tasync fetchOnboarding(): Promise<OnboardingState> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\"/onboarding\", API_ENDPOINTS.RepositoryService);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\tconst res = await this._fetch({ url });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value, error } = decode(OnboardingState, json);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode onboarding: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (value) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to fetch onboarding.\");\n\t\t}\n\t}\n\n\tasync toggleOnboardingStep(\n\t\tstepId: string,\n\t): Promise<{ completedSteps: string[] }> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\n\t\t\t`/onboarding/${stepId}/toggle`,\n\t\t\tAPI_ENDPOINTS.RepositoryService,\n\t\t);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\tconst res = await this._fetch({ url, method: \"PATCH\" });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value, error } = decode(\n\t\t\t\tz.object({ completedSteps: z.array(z.string()) }),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode onboarding step toggle: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (value) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to toggle onboarding step.\");\n\t\t}\n\t}\n\n\tasync completeOnboardingStep(\n\t\t...stepIds: string[]\n\t): Promise<{ completedSteps: string[] }> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst currentState = await this.fetchOnboarding();\n\t\tconst incompleteSteps = stepIds.filter(\n\t\t\t(stepId) => !currentState.completedSteps.includes(stepId),\n\t\t);\n\n\t\tif (incompleteSteps.length > 0) {\n\t\t\t// TODO: Refactor when the API accepts multiple steps (DT-2389)\n\t\t\tfor await (const stepId of incompleteSteps) {\n\t\t\t\tconst url = new URL(\n\t\t\t\t\t`/onboarding/${stepId}/toggle`,\n\t\t\t\t\tAPI_ENDPOINTS.RepositoryService,\n\t\t\t\t);\n\t\t\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\t\t\tconst res = await this._fetch({ url, method: \"PATCH\" });\n\n\t\t\t\tif (res.ok) {\n\t\t\t\t\tconst json = await res.json();\n\t\t\t\t\tconst { value, error } = decode(\n\t\t\t\t\t\tz.object({ completedSteps: z.array(z.string()) }),\n\t\t\t\t\t\tjson,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t\t\t`Failed to decode onboarding step complete response: ${error.errors.join(\n\t\t\t\t\t\t\t\t\", \",\n\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (value) {\n\t\t\t\t\t\tcurrentState.completedSteps = value.completedSteps;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tswitch (res.status) {\n\t\t\t\t\tcase 400:\n\t\t\t\t\tcase 401:\n\t\t\t\t\t\tthrow new UnauthenticatedError();\n\t\t\t\t\tcase 403:\n\t\t\t\t\t\tthrow new UnauthorizedError();\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new Error(\"Failed to complete onboarding step.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { completedSteps: currentState.completedSteps };\n\t}\n\n\tasync toggleOnboarding(): Promise<{ isDismissed: boolean }> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\"/onboarding/toggle\", API_ENDPOINTS.RepositoryService);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\t\tconst res = await this._fetch({ url, method: \"PATCH\" });\n\n\t\tif (res.ok) {\n\t\t\tconst json = await res.json();\n\t\t\tconst { value, error } = decode(\n\t\t\t\tz.object({ isDismissed: z.boolean() }),\n\t\t\t\tjson,\n\t\t\t);\n\n\t\t\tif (error) {\n\t\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t\t`Failed to decode onboarding toggle: ${error.errors.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (value) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\n\t\tswitch (res.status) {\n\t\t\tcase 400:\n\t\t\tcase 401:\n\t\t\t\tthrow new UnauthenticatedError();\n\t\t\tcase 403:\n\t\t\t\tthrow new UnauthorizedError();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Failed to toggle onboarding guide.\");\n\t\t}\n\t}\n\n\tasync setDefaultMasterLocale(): Promise<void> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\"repository/locales\", API_ENDPOINTS.LocaleService);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\n\t\tconst res = await this._fetch({\n\t\t\turl,\n\t\t\tmethod: \"POST\",\n\t\t\tbody: {\n\t\t\t\tid: \"en-us\",\n\t\t\t\tisMaster: true,\n\t\t\t},\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(\"Failed to set default master locale.\");\n\t\t}\n\t}\n\n\tprivate _decodeLimitOrThrow(\n\t\tpotentialLimit: unknown,\n\t\tstatusCode: number,\n\t\tlimitType: PushChangesLimitType,\n\t): PushChangesLimit | null {\n\t\treturn fold<t.Errors, PushChangesRawLimit, PushChangesLimit | null>(\n\t\t\t() => {\n\t\t\t\tconst error: ClientError = {\n\t\t\t\t\tstatus: statusCode,\n\t\t\t\t\tmessage: `Unable to parse raw limit from ${JSON.stringify(\n\t\t\t\t\t\tpotentialLimit,\n\t\t\t\t\t)}`,\n\t\t\t\t};\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t\t(rawLimit: PushChangesRawLimit) => {\n\t\t\t\tconst limit = { ...rawLimit, type: limitType };\n\n\t\t\t\treturn limit;\n\t\t\t},\n\t\t)(PushChangesRawLimit.decode(potentialLimit));\n\t}\n\n\tprivate async _fetch(args: {\n\t\turl: URL;\n\t\tmethod?: \"GET\" | \"POST\" | \"PATCH\";\n\t\tbody?: unknown;\n\t\tuserAgent?: PrismicRepositoryUserAgents;\n\t\trepository?: string;\n\t\tskipAuthentication?: boolean;\n\t}): Promise<Response> {\n\t\tlet cookies;\n\t\ttry {\n\t\t\tcookies = await this.user.getAuthenticationCookies();\n\t\t} catch (e) {\n\t\t\tif (!args.skipAuthentication) {\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\n\t\tconst extraHeaders: Record<string, string> = {};\n\n\t\tif (args.body) {\n\t\t\textraHeaders[\"Content-Type\"] = \"application/json\";\n\t\t}\n\n\t\tif (args.repository) {\n\t\t\textraHeaders.repository = args.repository;\n\t\t}\n\n\t\treturn await fetch(args.url.toString(), {\n\t\t\tmethod: args.method,\n\t\t\tbody: args.body ? JSON.stringify(args.body) : undefined,\n\t\t\theaders: {\n\t\t\t\t// Some endpoints rely on the authorization header...\n\n\t\t\t\t...(cookies !== undefined\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tAuthorization: `Bearer ${cookies[\"prismic-auth\"]}`,\n\t\t\t\t\t\t\tCookie: serializeCookies(cookies),\n\t\t\t\t\t }\n\t\t\t\t\t: {}),\n\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t...extraHeaders,\n\t\t\t},\n\t\t});\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA0CA,MAAM,8BAA8B;AAAA,EACnC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;;AAwCD,MAAO,iCAAiC,YAAW;AAAA;AAAA;AAAA,EAIxD,MAAM,UAAO;AACZ,UAAM,MAAM,IAAI,IAAI,kBAAkB,cAAc,WAAW;AAC/D,UAAM,MAAM,MAAM,KAAK,OAAO,EAAE,IAAK,CAAA;AAErC,QAAI,IAAI,IAAI;AACL,YAAA,OAAO,MAAM,IAAI;AACjB,YAAA,EAAE,OAAO,cAAc,UAAU,OACtC,EAAE,MAAM,iBAAiB,GACzB,IAAI;AAGL,UAAI,OAAO;AACV,cAAM,IAAI,MACT,kCAAkC,MAAM,OAAO,KAAK,IAAI,GAAG;AAAA,MAE7D;AAEO,aAAA;AAAA,IAAA,OACD;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AAI,IAAI;AAAA,MAC9C,SAAS;AAAA;AAAA,QAGR,GAAI,YAAY,SACb;AAAA,UACA,eAAe,UAAU,QAAQ,cAAc;AAAA,UAC/C,QAAQ,iBAAiB,OAAO;AAAA,QAAA,IAEhC;QACH,cAAc,KAAK,aAAa;AAAA,QAChC,GAAG;AAAA,MACH;AAAA,IAAA,CACD;AAAA,EACF;AACA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/manager",
3
- "version": "0.22.4-alpha.BI-dt-2482-set-default-master-language-when-creating-new-repo-via-cli.1",
3
+ "version": "0.22.4-alpha.BI-dt-2481-set-master-language-for-a-repository-via-manager-package.3",
4
4
  "description": "Manage all aspects of a Slice Machine project.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -70,7 +70,7 @@
70
70
  "@prismicio/mocks": "^2.4.0",
71
71
  "@prismicio/types-internal": "^2.8.0",
72
72
  "@segment/analytics-node": "^2.1.2",
73
- "@slicemachine/plugin-kit": "0.4.58-alpha.BI-dt-2482-set-default-master-language-when-creating-new-repo-via-cli.1",
73
+ "@slicemachine/plugin-kit": "0.4.58-alpha.BI-dt-2481-set-master-language-for-a-repository-via-manager-package.3",
74
74
  "cookie": "^1.0.1",
75
75
  "cors": "^2.8.5",
76
76
  "execa": "^7.1.1",
@@ -11,6 +11,7 @@ export type APIEndpoints = {
11
11
  PrismicUnsplash: string;
12
12
  SliceMachineV1: string;
13
13
  RepositoryService: string;
14
+ LocaleService: string;
14
15
  };
15
16
 
16
17
  export const API_ENDPOINTS: APIEndpoints = (() => {
@@ -37,6 +38,9 @@ export const API_ENDPOINTS: APIEndpoints = (() => {
37
38
  RepositoryService: addTrailingSlash(
38
39
  process.env.repository_api ?? "https://repository.internal.wroom.io/",
39
40
  ),
41
+ LocaleService: addTrailingSlash(
42
+ process.env.repository_api ?? "https://locale.internal.wroom.io/",
43
+ ),
40
44
  };
41
45
 
42
46
  const missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {
@@ -86,6 +90,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
86
90
  SliceMachineV1:
87
91
  "https://mc5qopc07a.execute-api.us-east-1.amazonaws.com/v1/",
88
92
  RepositoryService: "https://repository.internal.wroom.io/",
93
+ LocaleService: "https://locale.internal.wroom.io/",
89
94
  };
90
95
  }
91
96
 
@@ -102,6 +107,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
102
107
  PrismicUnsplash: "https://unsplash.prismic.io/",
103
108
  SliceMachineV1: "https://sm-api.prismic.io/v1/",
104
109
  RepositoryService: "https://repository.prismic.io/",
110
+ LocaleService: "https://locale.prismic.io/",
105
111
  };
106
112
  }
107
113
  }
@@ -676,9 +676,7 @@ export class PrismicRepositoryManager extends BaseManager {
676
676
  async setDefaultMasterLocale(): Promise<void> {
677
677
  const repositoryName = await this.project.getRepositoryName();
678
678
 
679
- const localeServiceBaseUrl = new URL("locale/", API_ENDPOINTS.PrismicWroom);
680
- localeServiceBaseUrl.hostname = `${repositoryName}.${localeServiceBaseUrl.hostname}`;
681
- const url = new URL("repository/locales", localeServiceBaseUrl);
679
+ const url = new URL("repository/locales", API_ENDPOINTS.LocaleService);
682
680
  url.searchParams.set("repository", repositoryName);
683
681
 
684
682
  const res = await this._fetch({
@@ -687,7 +685,6 @@ export class PrismicRepositoryManager extends BaseManager {
687
685
  body: {
688
686
  id: "en-us",
689
687
  isMaster: true,
690
- label: "English - United States",
691
688
  },
692
689
  });
693
690