@slicemachine/manager 0.26.5-alpha.jp-import-slices-3.2 → 0.26.5-alpha.jp-import-slices-3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,7 @@ const API_ENDPOINTS = (() => {
17
17
  RepositoryService: trailingSlash.addTrailingSlash(process.env.repository_api ?? "https://api.internal.wroom.io/repository/"),
18
18
  LocaleService: trailingSlash.addTrailingSlash(process.env.locale_api ?? "https://api.internal.wroom.io/locale/"),
19
19
  CustomTypeService: trailingSlash.addTrailingSlash(process.env.custom_type_api ?? "https://api.internal.wroom.io/custom-type/"),
20
- GitService: trailingSlash.addTrailingSlash(process.env.git_service_endpoint ?? "https://git.internal.wroom.io/")
20
+ GitService: trailingSlash.addTrailingSlash(process.env.git_service_api ?? "https://api.internal.wroom.io/git/")
21
21
  };
22
22
  const missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {
23
23
  return !apiEndpoints[key];
@@ -53,7 +53,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
53
53
  RepositoryService: "https://api.internal.wroom.io/repository/",
54
54
  LocaleService: "https://api.internal.wroom.io/locale/",
55
55
  CustomTypeService: "https://api.internal.wroom.io/custom-type/",
56
- GitService: "https://git.internal.wroom.io/"
56
+ GitService: "https://api.internal.wroom.io/git/"
57
57
  };
58
58
  }
59
59
  case APPLICATION_MODE.APPLICATION_MODE.DevTools:
@@ -71,7 +71,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
71
71
  RepositoryService: `https://api.internal.${process.env.SM_ENV}-wroom.com/repository/`,
72
72
  LocaleService: `https://api.internal.${process.env.SM_ENV}-wroom.com/locale/`,
73
73
  CustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`,
74
- GitService: `https://git.internal.${process.env.SM_ENV}-wroom.com/`
74
+ GitService: `https://api.internal.${process.env.SM_ENV}-wroom.com/git/`
75
75
  };
76
76
  }
77
77
  case APPLICATION_MODE.APPLICATION_MODE.Production:
@@ -88,7 +88,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
88
88
  RepositoryService: "https://api.internal.prismic.io/repository/",
89
89
  LocaleService: "https://api.internal.prismic.io/locale/",
90
90
  CustomTypeService: "https://api.internal.prismic.io/custom-type/",
91
- GitService: "https://git.internal.prismic.io/"
91
+ GitService: "https://api.internal.prismic.io/git/"
92
92
  };
93
93
  }
94
94
  }
@@ -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\tLocaleService: string;\n\tCustomTypeService: string;\n\tGitService: 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://sm-api.wroom.io/v1/\",\n\t\t\t\t),\n\t\t\t\tRepositoryService: addTrailingSlash(\n\t\t\t\t\tprocess.env.repository_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/repository/\",\n\t\t\t\t),\n\t\t\t\tLocaleService: addTrailingSlash(\n\t\t\t\t\tprocess.env.locale_api ?? \"https://api.internal.wroom.io/locale/\",\n\t\t\t\t),\n\t\t\t\tCustomTypeService: addTrailingSlash(\n\t\t\t\t\tprocess.env.custom_type_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/custom-type/\",\n\t\t\t\t),\n\t\t\t\tGitService: addTrailingSlash(\n\t\t\t\t\tprocess.env.git_service_endpoint ?? \"https://git.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: \"https://acl-provider.wroom.io/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.wroom.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.wroom.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.wroom.io/v1/\",\n\t\t\t\tRepositoryService: \"https://api.internal.wroom.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.wroom.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.wroom.io/custom-type/\",\n\t\t\t\tGitService: \"https://git.internal.wroom.io/\",\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.DevTools:\n\t\tcase APPLICATION_MODE.MarketingTools:\n\t\tcase APPLICATION_MODE.Platform: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: `https://${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicAuthentication: `https://auth.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicModels: `https://customtypes.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicUser: `https://user-service.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tAwsAclProvider: `https://acl-provider.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicEmbed: `https://oembed.${process.env.SM_ENV}-wroom.com`,\n\t\t\t\tPrismicUnsplash: `https://unsplash.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tSliceMachineV1: `https://sm-api.${process.env.SM_ENV}-wroom.com/v1/`,\n\t\t\t\tRepositoryService: `https://api.internal.${process.env.SM_ENV}-wroom.com/repository/`,\n\t\t\t\tLocaleService: `https://api.internal.${process.env.SM_ENV}-wroom.com/locale/`,\n\t\t\t\tCustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`,\n\t\t\t\tGitService: `https://git.internal.${process.env.SM_ENV}-wroom.com/`,\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: \"https://acl-provider.prismic.io/\",\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://api.internal.prismic.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.prismic.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.prismic.io/custom-type/\",\n\t\t\t\tGitService: \"https://git.internal.prismic.io/\",\n\t\t\t};\n\t\t}\n\t}\n})();\n"],"names":["APPLICATION_MODE","addTrailingSlash","removeTrailingSlash"],"mappings":";;;;AAkBO,MAAM,iBAA+B,MAAK;AAChD,UAAQ,QAAQ,IAAI,QAAA;AAAA,IACnB,KAAKA,iBAAAA,iBAAiB,aAAa;AAClC,YAAM,eAAe;AAAA,QACpB,cAAcC,cAAAA,iBAAiB,QAAQ,IAAI,cAAc;AAAA,QACzD,uBAAuBA,cAAAA,iBACtB,QAAQ,IAAI,8BAA8B;AAAA,QAE3C,eAAeA,cAAAA,iBAAiB,QAAQ,IAAI,uBAAuB;AAAA,QACnE,aAAaA,cAAAA,iBAAiB,QAAQ,IAAI,q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.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\tCustomTypeService: string;\n\tGitService: 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://sm-api.wroom.io/v1/\",\n\t\t\t\t),\n\t\t\t\tRepositoryService: addTrailingSlash(\n\t\t\t\t\tprocess.env.repository_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/repository/\",\n\t\t\t\t),\n\t\t\t\tLocaleService: addTrailingSlash(\n\t\t\t\t\tprocess.env.locale_api ?? \"https://api.internal.wroom.io/locale/\",\n\t\t\t\t),\n\t\t\t\tCustomTypeService: addTrailingSlash(\n\t\t\t\t\tprocess.env.custom_type_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/custom-type/\",\n\t\t\t\t),\n\t\t\t\tGitService: addTrailingSlash(\n\t\t\t\t\tprocess.env.git_service_api ?? \"https://api.internal.wroom.io/git/\",\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: \"https://acl-provider.wroom.io/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.wroom.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.wroom.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.wroom.io/v1/\",\n\t\t\t\tRepositoryService: \"https://api.internal.wroom.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.wroom.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.wroom.io/custom-type/\",\n\t\t\t\tGitService: \"https://api.internal.wroom.io/git/\",\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.DevTools:\n\t\tcase APPLICATION_MODE.MarketingTools:\n\t\tcase APPLICATION_MODE.Platform: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: `https://${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicAuthentication: `https://auth.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicModels: `https://customtypes.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicUser: `https://user-service.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tAwsAclProvider: `https://acl-provider.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicEmbed: `https://oembed.${process.env.SM_ENV}-wroom.com`,\n\t\t\t\tPrismicUnsplash: `https://unsplash.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tSliceMachineV1: `https://sm-api.${process.env.SM_ENV}-wroom.com/v1/`,\n\t\t\t\tRepositoryService: `https://api.internal.${process.env.SM_ENV}-wroom.com/repository/`,\n\t\t\t\tLocaleService: `https://api.internal.${process.env.SM_ENV}-wroom.com/locale/`,\n\t\t\t\tCustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`,\n\t\t\t\tGitService: `https://api.internal.${process.env.SM_ENV}-wroom.com/git/`,\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: \"https://acl-provider.prismic.io/\",\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://api.internal.prismic.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.prismic.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.prismic.io/custom-type/\",\n\t\t\t\tGitService: \"https://api.internal.prismic.io/git/\",\n\t\t\t};\n\t\t}\n\t}\n})();\n"],"names":["APPLICATION_MODE","addTrailingSlash","removeTrailingSlash"],"mappings":";;;;AAkBO,MAAM,iBAA+B,MAAK;AAChD,UAAQ,QAAQ,IAAI,QAAA;AAAA,IACnB,KAAKA,iBAAAA,iBAAiB,aAAa;AAClC,YAAM,eAAe;AAAA,QACpB,cAAcC,cAAAA,iBAAiB,QAAQ,IAAI,cAAc;AAAA,QACzD,uBAAuBA,cAAAA,iBACtB,QAAQ,IAAI,8BAA8B;AAAA,QAE3C,eAAeA,cAAAA,iBAAiB,QAAQ,IAAI,uBAAuB;AAAA,QACnE,aAAaA,cAAAA,iBAAiB,QAAQ,IAAI,qBAAqB;AAAA,QAC/D,gBAAgBA,cAAAA,iBAAiB,QAAQ,IAAI,qBAAqB;AAAA,QAClE,cAAcC,cAAAA,oBACb,QAAQ,IAAI,mBAAmB,yBAAyB;AAAA,QAEzD,iBAAiBD,cAAAA,iBAChB,QAAQ,IAAI,qBAAqB,4BAA4B;AAAA,QAE9D,gBAAgBA,cAAAA,iBACf,QAAQ,IAAI,6BACX,6BAA6B;AAAA,QAE/B,mBAAmBA,cAAAA,iBAClB,QAAQ,IAAI,kBACX,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AAA,QAC3C,uBAAuB,gBAAgB,QAAQ,IAAI,MAAM;AAAA,QACzD,eAAe,uBAAuB,QAAQ,IAAI,MAAM;AAAA,QACxD,aAAa,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QACvD,gBAAgB,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QAC1D,cAAc,kBAAkB,QAAQ,IAAI,MAAM;AAAA,QAClD,iBAAiB,oBAAoB,QAAQ,IAAI,MAAM;AAAA,QACvD,gBAAgB,kBAAkB,QAAQ,IAAI,MAAM;AAAA,QACpD,mBAAmB,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QAC7D,eAAe,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QACzD,mBAAmB,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QAC7D,YAAY,wBAAwB,QAAQ,IAAI,MAAM;AAAA,MAAA;AAAA,IAExD;AAAA,IAEA,KAAKA,iBAAAA,iBAAiB;AAAA,IACtB,SAAS;AACR,aAAO;AAAA,QACN,cAAc;AAAA,QACd,uBAAuB;AAAA,QACvB,eAAe;AAAA,QACf,aAAa;AAAA,QACb,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,gBAAgB;AAAA,QAChB,mBAAmB;AAAA,QACnB,eAAe;AAAA,QACf,mBAAmB;AAAA,QACnB,YAAY;AAAA,MAAA;AAAA,IAEd;AAAA,EAAA;AAEF,GAAA;;"}
@@ -15,7 +15,7 @@ const API_ENDPOINTS = (() => {
15
15
  RepositoryService: addTrailingSlash(process.env.repository_api ?? "https://api.internal.wroom.io/repository/"),
16
16
  LocaleService: addTrailingSlash(process.env.locale_api ?? "https://api.internal.wroom.io/locale/"),
17
17
  CustomTypeService: addTrailingSlash(process.env.custom_type_api ?? "https://api.internal.wroom.io/custom-type/"),
18
- GitService: addTrailingSlash(process.env.git_service_endpoint ?? "https://git.internal.wroom.io/")
18
+ GitService: addTrailingSlash(process.env.git_service_api ?? "https://api.internal.wroom.io/git/")
19
19
  };
20
20
  const missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {
21
21
  return !apiEndpoints[key];
@@ -51,7 +51,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
51
51
  RepositoryService: "https://api.internal.wroom.io/repository/",
52
52
  LocaleService: "https://api.internal.wroom.io/locale/",
53
53
  CustomTypeService: "https://api.internal.wroom.io/custom-type/",
54
- GitService: "https://git.internal.wroom.io/"
54
+ GitService: "https://api.internal.wroom.io/git/"
55
55
  };
56
56
  }
57
57
  case APPLICATION_MODE.DevTools:
@@ -69,7 +69,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
69
69
  RepositoryService: `https://api.internal.${process.env.SM_ENV}-wroom.com/repository/`,
70
70
  LocaleService: `https://api.internal.${process.env.SM_ENV}-wroom.com/locale/`,
71
71
  CustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`,
72
- GitService: `https://git.internal.${process.env.SM_ENV}-wroom.com/`
72
+ GitService: `https://api.internal.${process.env.SM_ENV}-wroom.com/git/`
73
73
  };
74
74
  }
75
75
  case APPLICATION_MODE.Production:
@@ -86,7 +86,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
86
86
  RepositoryService: "https://api.internal.prismic.io/repository/",
87
87
  LocaleService: "https://api.internal.prismic.io/locale/",
88
88
  CustomTypeService: "https://api.internal.prismic.io/custom-type/",
89
- GitService: "https://git.internal.prismic.io/"
89
+ GitService: "https://api.internal.prismic.io/git/"
90
90
  };
91
91
  }
92
92
  }
@@ -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\tLocaleService: string;\n\tCustomTypeService: string;\n\tGitService: 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://sm-api.wroom.io/v1/\",\n\t\t\t\t),\n\t\t\t\tRepositoryService: addTrailingSlash(\n\t\t\t\t\tprocess.env.repository_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/repository/\",\n\t\t\t\t),\n\t\t\t\tLocaleService: addTrailingSlash(\n\t\t\t\t\tprocess.env.locale_api ?? \"https://api.internal.wroom.io/locale/\",\n\t\t\t\t),\n\t\t\t\tCustomTypeService: addTrailingSlash(\n\t\t\t\t\tprocess.env.custom_type_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/custom-type/\",\n\t\t\t\t),\n\t\t\t\tGitService: addTrailingSlash(\n\t\t\t\t\tprocess.env.git_service_endpoint ?? \"https://git.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: \"https://acl-provider.wroom.io/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.wroom.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.wroom.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.wroom.io/v1/\",\n\t\t\t\tRepositoryService: \"https://api.internal.wroom.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.wroom.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.wroom.io/custom-type/\",\n\t\t\t\tGitService: \"https://git.internal.wroom.io/\",\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.DevTools:\n\t\tcase APPLICATION_MODE.MarketingTools:\n\t\tcase APPLICATION_MODE.Platform: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: `https://${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicAuthentication: `https://auth.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicModels: `https://customtypes.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicUser: `https://user-service.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tAwsAclProvider: `https://acl-provider.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicEmbed: `https://oembed.${process.env.SM_ENV}-wroom.com`,\n\t\t\t\tPrismicUnsplash: `https://unsplash.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tSliceMachineV1: `https://sm-api.${process.env.SM_ENV}-wroom.com/v1/`,\n\t\t\t\tRepositoryService: `https://api.internal.${process.env.SM_ENV}-wroom.com/repository/`,\n\t\t\t\tLocaleService: `https://api.internal.${process.env.SM_ENV}-wroom.com/locale/`,\n\t\t\t\tCustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`,\n\t\t\t\tGitService: `https://git.internal.${process.env.SM_ENV}-wroom.com/`,\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: \"https://acl-provider.prismic.io/\",\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://api.internal.prismic.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.prismic.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.prismic.io/custom-type/\",\n\t\t\t\tGitService: \"https://git.internal.prismic.io/\",\n\t\t\t};\n\t\t}\n\t}\n})();\n"],"names":[],"mappings":";;AAkBO,MAAM,iBAA+B,MAAK;AAChD,UAAQ,QAAQ,IAAI,QAAA;AAAA,IACnB,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,6BAA6B;AAAA,QAE/B,mBAAmB,iBAClB,QAAQ,IAAI,kBACX,2CAA2C;AAAA,QAE7C,eAAe,iBACd,QAAQ,IAAI,cAAc,uCAAuC;AAAA,QAElE,mBAAmB,iBAClB,QAAQ,IAAI,mBACX,4CAA4C;AAAA,QAE9C,YAAY,iBACX,QAAQ,IAAI,wBAAwB,gCAAgC;AAAA,MAAA;AAItE,YAAM,sBAAsB,OAAO,KAAK,YAAY,EAAE,OAAO,CAAC,QAAO;AACpE,eAAO,CAAC,aAAa,GAAgC;AAAA,MACtD,CAAC;AAED,UAAI,oBAAoB,SAAS,GAAG;AACnC,gBAAQ,MACP,6DACC,iBAAiB,WAClB;AAAA;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AAQ,IAAI,MAAM;AAAA,QAC7D,YAAY,wBAAwB,QAAQ,IAAI,MAAM;AAAA,MAAA;AAAA,IAExD;AAAA,IAEA,KAAK,iBAAiB;AAAA,IACtB,SAAS;AACR,aAAO;AAAA,QACN,cAAc;AAAA,QACd,uBAAuB;AAAA,QACvB,eAAe;AAAA,QACf,aAAa;AAAA,QACb,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,gBAAgB;AAAA,QAChB,mBAAmB;AAAA,QACnB,eAAe;AAAA,QACf,mBAAmB;AAAA,QACnB,YAAY;AAAA,MAAA;AAAA,IAEd;AAAA,EAAA;AAEF,GAAA;"}
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\tCustomTypeService: string;\n\tGitService: 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://sm-api.wroom.io/v1/\",\n\t\t\t\t),\n\t\t\t\tRepositoryService: addTrailingSlash(\n\t\t\t\t\tprocess.env.repository_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/repository/\",\n\t\t\t\t),\n\t\t\t\tLocaleService: addTrailingSlash(\n\t\t\t\t\tprocess.env.locale_api ?? \"https://api.internal.wroom.io/locale/\",\n\t\t\t\t),\n\t\t\t\tCustomTypeService: addTrailingSlash(\n\t\t\t\t\tprocess.env.custom_type_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/custom-type/\",\n\t\t\t\t),\n\t\t\t\tGitService: addTrailingSlash(\n\t\t\t\t\tprocess.env.git_service_api ?? \"https://api.internal.wroom.io/git/\",\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: \"https://acl-provider.wroom.io/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.wroom.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.wroom.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.wroom.io/v1/\",\n\t\t\t\tRepositoryService: \"https://api.internal.wroom.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.wroom.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.wroom.io/custom-type/\",\n\t\t\t\tGitService: \"https://api.internal.wroom.io/git/\",\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.DevTools:\n\t\tcase APPLICATION_MODE.MarketingTools:\n\t\tcase APPLICATION_MODE.Platform: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: `https://${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicAuthentication: `https://auth.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicModels: `https://customtypes.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicUser: `https://user-service.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tAwsAclProvider: `https://acl-provider.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicEmbed: `https://oembed.${process.env.SM_ENV}-wroom.com`,\n\t\t\t\tPrismicUnsplash: `https://unsplash.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tSliceMachineV1: `https://sm-api.${process.env.SM_ENV}-wroom.com/v1/`,\n\t\t\t\tRepositoryService: `https://api.internal.${process.env.SM_ENV}-wroom.com/repository/`,\n\t\t\t\tLocaleService: `https://api.internal.${process.env.SM_ENV}-wroom.com/locale/`,\n\t\t\t\tCustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`,\n\t\t\t\tGitService: `https://api.internal.${process.env.SM_ENV}-wroom.com/git/`,\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: \"https://acl-provider.prismic.io/\",\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://api.internal.prismic.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.prismic.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.prismic.io/custom-type/\",\n\t\t\t\tGitService: \"https://api.internal.prismic.io/git/\",\n\t\t\t};\n\t\t}\n\t}\n})();\n"],"names":[],"mappings":";;AAkBO,MAAM,iBAA+B,MAAK;AAChD,UAAQ,QAAQ,IAAI,QAAA;AAAA,IACnB,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,uB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AAA,QAChB,mBAAmB;AAAA,QACnB,eAAe;AAAA,QACf,mBAAmB;AAAA,QACnB,YAAY;AAAA,MAAA;AAAA,IAEd;AAAA,IAEA,KAAK,iBAAiB;AAAA,IACtB,KAAK,iBAAiB;AAAA,IACtB,KAAK,iBAAiB,UAAU;AAC/B,aAAO;AAAA,QACN,cAAc,WAAW,QAAQ,IAAI,MAAM;AAAA,QAC3C,uBAAuB,gBAAgB,QAAQ,IAAI,MAAM;AAAA,QACzD,eAAe,uBAAuB,QAAQ,IAAI,MAAM;AAAA,QACxD,aAAa,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QACvD,gBAAgB,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QAC1D,cAAc,kBAAkB,QAAQ,IAAI,MAAM;AAAA,QAClD,iBAAiB,oBAAoB,QAAQ,IAAI,MAAM;AAAA,QACvD,gBAAgB,kBAAkB,QAAQ,IAAI,MAAM;AAAA,QACpD,mBAAmB,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QAC7D,eAAe,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QACzD,mBAAmB,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QAC7D,YAAY,wBAAwB,QAAQ,IAAI,MAAM;AAAA,MAAA;AAAA,IAExD;AAAA,IAEA,KAAK,iBAAiB;AAAA,IACtB,SAAS;AACR,aAAO;AAAA,QACN,cAAc;AAAA,QACd,uBAAuB;AAAA,QACvB,eAAe;AAAA,QACf,aAAa;AAAA,QACb,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,gBAAgB;AAAA,QAChB,mBAAmB;AAAA,QACnB,eAAe;AAAA,QACf,mBAAmB;AAAA,QACnB,YAAY;AAAA,MAAA;AAAA,IAEd;AAAA,EAAA;AAEF,GAAA;"}
@@ -524,19 +524,17 @@ class PrismicRepositoryManager extends BaseManager.BaseManager {
524
524
  if (error) {
525
525
  throw new errors.UnexpectedDataError(`Failed to decode integrations: ${error.errors.join(", ")}`);
526
526
  }
527
- if (value) {
528
- return value;
529
- }
530
- throw new Error("Failed to fetch integrations.");
527
+ return value;
531
528
  }
532
529
  async fetchGitIntegrationToken(args) {
530
+ const { integrationId } = args;
533
531
  const repositoryName = await this.project.getRepositoryName();
534
- const url = new URL(`integrations/${args.integrationId}/token`, API_ENDPOINTS.API_ENDPOINTS.GitService);
532
+ const url = new URL(`integrations/${integrationId}/token`, API_ENDPOINTS.API_ENDPOINTS.GitService);
535
533
  url.searchParams.set("repository", repositoryName);
536
534
  const res = await this._fetch({ url, method: "POST" });
537
535
  if (!res.ok) {
538
536
  const text = await res.text();
539
- throw new Error(`Failed to fetch token for integration ${args.integrationId}`, { cause: text });
537
+ throw new Error(`Failed to fetch token for integration ${integrationId}`, { cause: text });
540
538
  }
541
539
  const json = await res.json();
542
540
  const { value, error } = decode.decode(GitIntegrationTokenSchema, json);
@@ -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\tPushBody,\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\nconst GitIntegrationsSchema = z.object({\n\tintegrations: z.array(\n\t\tz.discriminatedUnion(\"status\", [\n\t\t\tz.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tstatus: z.literal(\"connected\"),\n\t\t\t\towner: z.string(),\n\t\t\t\trepositories: z.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\tname: z.string(),\n\t\t\t\t\t\tfullName: z.string(),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tstatus: z.literal(\"broken\"),\n\t\t\t\towner: z.string().optional(),\n\t\t\t\trepositories: z.tuple([]),\n\t\t\t}),\n\t\t]),\n\t),\n});\n\nconst GitIntegrationTokenSchema = z.object({\n\ttoken: z.string(),\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\tvariationImageUrlMap: change.variationImageUrlMap,\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\tvariationImageUrlMap: change.variationImageUrlMap,\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: PushBody = {\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\tconst response = await this._fetch({\n\t\t\t\turl: new URL(\"./push\", API_ENDPOINTS.SliceMachineV1),\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\tswitch (res.status) {\n\t\t\t\tcase 400:\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\tthrow new UnauthorizedError();\n\t\t\t\tdefault:\n\t\t\t\t\tconst text = await res.text();\n\t\t\t\t\tthrow new Error(\"Failed to set main content language.\", {\n\t\t\t\t\t\tcause: text,\n\t\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tasync fetchGitIntegrations(): Promise<z.infer<typeof GitIntegrationsSchema>> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\"integrations\", API_ENDPOINTS.GitService);\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 text = await res.text();\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to fetch integrations for repository ${repositoryName}`,\n\t\t\t\t{ cause: text },\n\t\t\t);\n\t\t}\n\n\t\tconst json = await res.json();\n\t\tconst { value, error } = decode(GitIntegrationsSchema, json);\n\n\t\tif (error) {\n\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t`Failed to decode integrations: ${error.errors.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\tif (value) {\n\t\t\treturn value;\n\t\t}\n\n\t\tthrow new Error(\"Failed to fetch integrations.\");\n\t}\n\n\tasync fetchGitIntegrationToken(args: {\n\t\tintegrationId: string;\n\t}): Promise<z.infer<typeof GitIntegrationTokenSchema>> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\n\t\t\t`integrations/${args.integrationId}/token`,\n\t\t\tAPI_ENDPOINTS.GitService,\n\t\t);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\n\t\tconst res = await this._fetch({ url, method: \"POST\" });\n\n\t\tif (!res.ok) {\n\t\t\tconst text = await res.text();\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to fetch token for integration ${args.integrationId}`,\n\t\t\t\t{ cause: text },\n\t\t\t);\n\t\t}\n\n\t\tconst json = await res.json();\n\t\tconst { value, error } = decode(GitIntegrationTokenSchema, json);\n\n\t\tif (error) {\n\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t`Failed to decode integration token: ${error.errors.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\treturn value;\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":["z","BaseManager","API_ENDPOINTS","decode","t","PrismicRepository","PrismicRepositoryRole","PrismicRepositoryUserAgent","REPOSITORY_NAME_VALIDATION","assertPluginsInitialized","UnauthenticatedError","ChangeTypes","PushChangesLimitType","Environment","UnexpectedDataError","sortEnvironments","UnauthorizedError","OnboardingState","fold","PushChangesRawLimit","fetch","serializeCookies","SLICE_MACHINE_USER_AGENT"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,8BAA8B;AAAA,EACnC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;;AAwCP,MAAM,wBAAwBA,MAAAA,QAAE,OAAO;AAAA,EACtC,cAAcA,MAAAA,QAAE,MACfA,MAAAA,QAAE,mBAAmB,UAAU;AAAA,IAC9BA,MAAAA,QAAE,OAAO;AAAA,MACR,IAAIA,MAAAA,QAAE,OAAA;AAAA,MACN,QAAQA,MAAAA,QAAE,QAAQ,WAAW;AAAA,MAC7B,OAAOA,MAAAA,QAAE,OAAA;AAAA,MACT,cAAcA,MAAAA,QAAE,MACfA,MAAAA,QAAE,OAAO;AAAA,QACR,MAAMA,MAAAA,QAAE,OAAA;AAAA,QACR,UAAUA,MAAAA,QAAE,OAAA;AAAA,MAAM,CAClB,CAAC;AAAA,IAAA,CAEH;AAAA,IACDA,MAAAA,QAAE,OAAO;AAAA,MACR,IAAIA,MAAAA,QAAE,OAAA;AAAA,MACN,QAAQA,MAAAA,QAAE,QAAQ,QAAQ;AAAA,MAC1B,OAAOA,MAAAA,QAAE,OAAA,EAAS,SAAA;AAAA,MAClB,cAAcA,MAAAA,QAAE,MAAM,CAAA,CAAE;AAAA,IAAA,CACxB;AAAA,EAAA,CACD,CAAC;AAEH,CAAA;AAED,MAAM,4BAA4BA,MAAAA,QAAE,OAAO;AAAA,EAC1C,OAAOA,MAAAA,QAAE,OAAA;AACT,CAAA;AAEK,MAAO,iCAAiCC,YAAAA,YAAW;AAAA;AAAA;AAAA,EAIxD,MAAM,UAAO;AACZ,UAAM,MAAM,IAAI,IAAI,kBAAkBC,cAA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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,CAAC;AAAA,UAChD,QAAQC,iBAAAA,iBAAiB,OAAO;AAAA,QAAA,IAEhC,CAAA;AAAA,QACH,cAAc,KAAK,aAAaC,yBAAAA;AAAAA,QAChC,GAAG;AAAA,MAAA;AAAA,IACH,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\tPushBody,\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\nconst GitIntegrationsSchema = z.object({\n\tintegrations: z.array(\n\t\tz.discriminatedUnion(\"status\", [\n\t\t\tz.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tstatus: z.literal(\"connected\"),\n\t\t\t\towner: z.string(),\n\t\t\t\trepositories: z.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\tname: z.string(),\n\t\t\t\t\t\tfullName: z.string(),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tstatus: z.literal(\"broken\"),\n\t\t\t\towner: z.string().optional(),\n\t\t\t\trepositories: z.tuple([]),\n\t\t\t}),\n\t\t]),\n\t),\n});\n\nconst GitIntegrationTokenSchema = z.object({\n\ttoken: z.string(),\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\tvariationImageUrlMap: change.variationImageUrlMap,\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\tvariationImageUrlMap: change.variationImageUrlMap,\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: PushBody = {\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\tconst response = await this._fetch({\n\t\t\t\turl: new URL(\"./push\", API_ENDPOINTS.SliceMachineV1),\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\tswitch (res.status) {\n\t\t\t\tcase 400:\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\tthrow new UnauthorizedError();\n\t\t\t\tdefault:\n\t\t\t\t\tconst text = await res.text();\n\t\t\t\t\tthrow new Error(\"Failed to set main content language.\", {\n\t\t\t\t\t\tcause: text,\n\t\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tasync fetchGitIntegrations(): Promise<z.infer<typeof GitIntegrationsSchema>> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\"integrations\", API_ENDPOINTS.GitService);\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 text = await res.text();\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to fetch integrations for repository ${repositoryName}`,\n\t\t\t\t{ cause: text },\n\t\t\t);\n\t\t}\n\n\t\tconst json = await res.json();\n\t\tconst { value, error } = decode(GitIntegrationsSchema, json);\n\n\t\tif (error) {\n\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t`Failed to decode integrations: ${error.errors.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\treturn value;\n\t}\n\n\tasync fetchGitIntegrationToken(args: {\n\t\tintegrationId: string;\n\t}): Promise<z.infer<typeof GitIntegrationTokenSchema>> {\n\t\tconst { integrationId } = args;\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\n\t\t\t`integrations/${integrationId}/token`,\n\t\t\tAPI_ENDPOINTS.GitService,\n\t\t);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\n\t\tconst res = await this._fetch({ url, method: \"POST\" });\n\n\t\tif (!res.ok) {\n\t\t\tconst text = await res.text();\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to fetch token for integration ${integrationId}`,\n\t\t\t\t{ cause: text },\n\t\t\t);\n\t\t}\n\n\t\tconst json = await res.json();\n\t\tconst { value, error } = decode(GitIntegrationTokenSchema, json);\n\n\t\tif (error) {\n\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t`Failed to decode integration token: ${error.errors.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\treturn value;\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":["z","BaseManager","API_ENDPOINTS","decode","t","PrismicRepository","PrismicRepositoryRole","PrismicRepositoryUserAgent","REPOSITORY_NAME_VALIDATION","assertPluginsInitialized","UnauthenticatedError","ChangeTypes","PushChangesLimitType","Environment","UnexpectedDataError","sortEnvironments","UnauthorizedError","OnboardingState","fold","PushChangesRawLimit","fetch","serializeCookies","SLICE_MACHINE_USER_AGENT"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,8BAA8B;AAAA,EACnC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;;AAwCP,MAAM,wBAAwBA,MAAAA,QAAE,OAAO;AAAA,EACtC,cAAcA,MAAAA,QAAE,MACfA,MAAAA,QAAE,mBAAmB,UAAU;AAAA,IAC9BA,MAAAA,QAAE,OAAO;AAAA,MACR,IAAIA,MAAAA,QAAE,OAAA;AAAA,MACN,QAAQA,MAAAA,QAAE,QAAQ,WAAW;AAAA,MAC7B,OAAOA,MAAAA,QAAE,OAAA;AAAA,MACT,cAAcA,MAAAA,QAAE,MACfA,MAAAA,QAAE,OAAO;AAAA,QACR,MAAMA,MAAAA,QAAE,OAAA;AAAA,QACR,UAAUA,MAAAA,QAAE,OAAA;AAAA,MAAM,CAClB,CAAC;AAAA,IAAA,CAEH;AAAA,IACDA,MAAAA,QAAE,OAAO;AAAA,MACR,IAAIA,MAAAA,QAAE,OAAA;AAAA,MACN,QAAQA,MAAAA,QAAE,QAAQ,QAAQ;AAAA,MAC1B,OAAOA,MAAAA,QAAE,OAAA,EAAS,SAAA;AAAA,MAClB,cAAcA,MAAAA,QAAE,MAAM,CAAA,CAAE;AAAA,IAAA,CACxB;AAAA,EAAA,CACD,CAAC;AAEH,CAAA;AAED,MAAM,4BAA4BA,MAAAA,QAAE,OAAO;AAAA,EAC1C,OAAOA,MAAAA,QAAE,OAAA;AACT,CAAA;AAEK,MAAO,iCAAiCC,YAAAA,YAAW;AAAA;AAAA;AAAA,EAIxD,MAAM,UAAO;AACZ,UAAM,MAAM,IAAI,IAAI,kBAAkBC,cAAAA,cAAc,WAAW;AAC/D,UAAM,MAAM,MAAM,KAAK,OAAO,EAAE,KAAK;AAErC,QAAI,IAAI,IAAI;A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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,CAAC;AAAA,UAChD,QAAQC,iBAAAA,iBAAiB,OAAO;AAAA,QAAA,IAEhC,CAAA;AAAA,QACH,cAAc,KAAK,aAAaC,yBAAAA;AAAAA,QAChC,GAAG;AAAA,MAAA;AAAA,IACH,CACD;AAAA,EACF;AACA;;"}
@@ -505,19 +505,17 @@ class PrismicRepositoryManager extends BaseManager {
505
505
  if (error) {
506
506
  throw new UnexpectedDataError(`Failed to decode integrations: ${error.errors.join(", ")}`);
507
507
  }
508
- if (value) {
509
- return value;
510
- }
511
- throw new Error("Failed to fetch integrations.");
508
+ return value;
512
509
  }
513
510
  async fetchGitIntegrationToken(args) {
511
+ const { integrationId } = args;
514
512
  const repositoryName = await this.project.getRepositoryName();
515
- const url = new URL(`integrations/${args.integrationId}/token`, API_ENDPOINTS.GitService);
513
+ const url = new URL(`integrations/${integrationId}/token`, API_ENDPOINTS.GitService);
516
514
  url.searchParams.set("repository", repositoryName);
517
515
  const res = await this._fetch({ url, method: "POST" });
518
516
  if (!res.ok) {
519
517
  const text = await res.text();
520
- throw new Error(`Failed to fetch token for integration ${args.integrationId}`, { cause: text });
518
+ throw new Error(`Failed to fetch token for integration ${integrationId}`, { cause: text });
521
519
  }
522
520
  const json = await res.json();
523
521
  const { value, error } = decode(GitIntegrationTokenSchema, json);
@@ -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\tPushBody,\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\nconst GitIntegrationsSchema = z.object({\n\tintegrations: z.array(\n\t\tz.discriminatedUnion(\"status\", [\n\t\t\tz.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tstatus: z.literal(\"connected\"),\n\t\t\t\towner: z.string(),\n\t\t\t\trepositories: z.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\tname: z.string(),\n\t\t\t\t\t\tfullName: z.string(),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tstatus: z.literal(\"broken\"),\n\t\t\t\towner: z.string().optional(),\n\t\t\t\trepositories: z.tuple([]),\n\t\t\t}),\n\t\t]),\n\t),\n});\n\nconst GitIntegrationTokenSchema = z.object({\n\ttoken: z.string(),\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\tvariationImageUrlMap: change.variationImageUrlMap,\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\tvariationImageUrlMap: change.variationImageUrlMap,\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: PushBody = {\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\tconst response = await this._fetch({\n\t\t\t\turl: new URL(\"./push\", API_ENDPOINTS.SliceMachineV1),\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\tswitch (res.status) {\n\t\t\t\tcase 400:\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\tthrow new UnauthorizedError();\n\t\t\t\tdefault:\n\t\t\t\t\tconst text = await res.text();\n\t\t\t\t\tthrow new Error(\"Failed to set main content language.\", {\n\t\t\t\t\t\tcause: text,\n\t\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tasync fetchGitIntegrations(): Promise<z.infer<typeof GitIntegrationsSchema>> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\"integrations\", API_ENDPOINTS.GitService);\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 text = await res.text();\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to fetch integrations for repository ${repositoryName}`,\n\t\t\t\t{ cause: text },\n\t\t\t);\n\t\t}\n\n\t\tconst json = await res.json();\n\t\tconst { value, error } = decode(GitIntegrationsSchema, json);\n\n\t\tif (error) {\n\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t`Failed to decode integrations: ${error.errors.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\tif (value) {\n\t\t\treturn value;\n\t\t}\n\n\t\tthrow new Error(\"Failed to fetch integrations.\");\n\t}\n\n\tasync fetchGitIntegrationToken(args: {\n\t\tintegrationId: string;\n\t}): Promise<z.infer<typeof GitIntegrationTokenSchema>> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\n\t\t\t`integrations/${args.integrationId}/token`,\n\t\t\tAPI_ENDPOINTS.GitService,\n\t\t);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\n\t\tconst res = await this._fetch({ url, method: \"POST\" });\n\n\t\tif (!res.ok) {\n\t\t\tconst text = await res.text();\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to fetch token for integration ${args.integrationId}`,\n\t\t\t\t{ cause: text },\n\t\t\t);\n\t\t}\n\n\t\tconst json = await res.json();\n\t\tconst { value, error } = decode(GitIntegrationTokenSchema, json);\n\n\t\tif (error) {\n\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t`Failed to decode integration token: ${error.errors.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\treturn value;\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;;AAwCP,MAAM,wBAAwB,EAAE,OAAO;AAAA,EACtC,cAAc,EAAE,MACf,EAAE,mBAAmB,UAAU;AAAA,IAC9B,EAAE,OAAO;AAAA,MACR,IAAI,EAAE,OAAA;AAAA,MACN,QAAQ,EAAE,QAAQ,WAAW;AAAA,MAC7B,OAAO,EAAE,OAAA;AAAA,MACT,cAAc,EAAE,MACf,EAAE,OAAO;AAAA,QACR,MAAM,EAAE,OAAA;AAAA,QACR,UAAU,EAAE,OAAA;AAAA,MAAM,CAClB,CAAC;AAAA,IAAA,CAEH;AAAA,IACD,EAAE,OAAO;AAAA,MACR,IAAI,EAAE,OAAA;AAAA,MACN,QAAQ,EAAE,QAAQ,QAAQ;AAAA,MAC1B,OAAO,EAAE,OAAA,EAAS,SAAA;AAAA,MAClB,cAAc,EAAE,MAAM,CAAA,CAAE;AAAA,IAAA,CACxB;AAAA,EAAA,CACD,CAAC;AAEH,CAAA;AAED,MAAM,4BAA4B,EAAE,OAAO;AAAA,EAC1C,OAAO,EAAE,OAAA;AACT,CAAA;AAEK,MAAO,iCAAiC,YAAW;AAAA;AAAA;AAAA,EAIxD,MAAM,UAAO;AACZ,UAAM,M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,OAAO;AACV,YAAM,IAAI,oBACT,uCAAuC,MAAM,OAAO,KAAK,IAAI,CAAC,EAAE;AAAA,IAElE;AAEA,WAAO;AAAA,EACR;AAAA,EAEQ,oBACP,gBACA,YACA,WAA+B;AAE/B,WAAO,KACN,MAAK;AACJ,YAAM,QAAqB;AAAA,QAC1B,QAAQ;AAAA,QACR,SAAS,kCAAkC,KAAK,UAC/C,cAAc,CACd;AAAA,MAAA;AAEF,YAAM;AAAA,IACP,GACA,CAAC,aAAiC;AACjC,YAAM,QAAQ,EAAE,GAAG,UAAU,MAAM,UAAA;AAEnC,aAAO;AAAA,IACR,CAAC,EACA,oBAAoB,OAAO,cAAc,CAAC;AAAA,EAC7C;AAAA,EAEQ,MAAM,OAAO,MAOpB;AACA,QAAI;AACJ,QAAI;AACH,gBAAU,MAAM,KAAK,KAAK,yBAAA;AAAA,IAC3B,SAAS,GAAG;AACX,UAAI,CAAC,KAAK,oBAAoB;AAC7B,cAAM;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,CAAC;AAAA,UAChD,QAAQ,iBAAiB,OAAO;AAAA,QAAA,IAEhC,CAAA;AAAA,QACH,cAAc,KAAK,aAAa;AAAA,QAChC,GAAG;AAAA,MAAA;AAAA,IACH,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\tPushBody,\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\nconst GitIntegrationsSchema = z.object({\n\tintegrations: z.array(\n\t\tz.discriminatedUnion(\"status\", [\n\t\t\tz.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tstatus: z.literal(\"connected\"),\n\t\t\t\towner: z.string(),\n\t\t\t\trepositories: z.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\tname: z.string(),\n\t\t\t\t\t\tfullName: z.string(),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tstatus: z.literal(\"broken\"),\n\t\t\t\towner: z.string().optional(),\n\t\t\t\trepositories: z.tuple([]),\n\t\t\t}),\n\t\t]),\n\t),\n});\n\nconst GitIntegrationTokenSchema = z.object({\n\ttoken: z.string(),\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\tvariationImageUrlMap: change.variationImageUrlMap,\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\tvariationImageUrlMap: change.variationImageUrlMap,\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: PushBody = {\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\tconst response = await this._fetch({\n\t\t\t\turl: new URL(\"./push\", API_ENDPOINTS.SliceMachineV1),\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\tswitch (res.status) {\n\t\t\t\tcase 400:\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\tthrow new UnauthorizedError();\n\t\t\t\tdefault:\n\t\t\t\t\tconst text = await res.text();\n\t\t\t\t\tthrow new Error(\"Failed to set main content language.\", {\n\t\t\t\t\t\tcause: text,\n\t\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tasync fetchGitIntegrations(): Promise<z.infer<typeof GitIntegrationsSchema>> {\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\"integrations\", API_ENDPOINTS.GitService);\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 text = await res.text();\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to fetch integrations for repository ${repositoryName}`,\n\t\t\t\t{ cause: text },\n\t\t\t);\n\t\t}\n\n\t\tconst json = await res.json();\n\t\tconst { value, error } = decode(GitIntegrationsSchema, json);\n\n\t\tif (error) {\n\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t`Failed to decode integrations: ${error.errors.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\treturn value;\n\t}\n\n\tasync fetchGitIntegrationToken(args: {\n\t\tintegrationId: string;\n\t}): Promise<z.infer<typeof GitIntegrationTokenSchema>> {\n\t\tconst { integrationId } = args;\n\t\tconst repositoryName = await this.project.getRepositoryName();\n\n\t\tconst url = new URL(\n\t\t\t`integrations/${integrationId}/token`,\n\t\t\tAPI_ENDPOINTS.GitService,\n\t\t);\n\t\turl.searchParams.set(\"repository\", repositoryName);\n\n\t\tconst res = await this._fetch({ url, method: \"POST\" });\n\n\t\tif (!res.ok) {\n\t\t\tconst text = await res.text();\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to fetch token for integration ${integrationId}`,\n\t\t\t\t{ cause: text },\n\t\t\t);\n\t\t}\n\n\t\tconst json = await res.json();\n\t\tconst { value, error } = decode(GitIntegrationTokenSchema, json);\n\n\t\tif (error) {\n\t\t\tthrow new UnexpectedDataError(\n\t\t\t\t`Failed to decode integration token: ${error.errors.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\treturn value;\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;;AAwCP,MAAM,wBAAwB,EAAE,OAAO;AAAA,EACtC,cAAc,EAAE,MACf,EAAE,mBAAmB,UAAU;AAAA,IAC9B,EAAE,OAAO;AAAA,MACR,IAAI,EAAE,OAAA;AAAA,MACN,QAAQ,EAAE,QAAQ,WAAW;AAAA,MAC7B,OAAO,EAAE,OAAA;AAAA,MACT,cAAc,EAAE,MACf,EAAE,OAAO;AAAA,QACR,MAAM,EAAE,OAAA;AAAA,QACR,UAAU,EAAE,OAAA;AAAA,MAAM,CAClB,CAAC;AAAA,IAAA,CAEH;AAAA,IACD,EAAE,OAAO;AAAA,MACR,IAAI,EAAE,OAAA;AAAA,MACN,QAAQ,EAAE,QAAQ,QAAQ;AAAA,MAC1B,OAAO,EAAE,OAAA,EAAS,SAAA;AAAA,MAClB,cAAc,EAAE,MAAM,CAAA,CAAE;AAAA,IAAA,CACxB;AAAA,EAAA,CACD,CAAC;AAEH,CAAA;AAED,MAAM,4BAA4B,EAAE,OAAO;AAAA,EAC1C,OAAO,EAAE,OAAA;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  "name": "@slicemachine/manager",
3
- "version": "0.26.5-alpha.jp-import-slices-3.2",
3
+ "version": "0.26.5-alpha.jp-import-slices-3.3",
4
4
  "description": "Manage all aspects of a Slice Machine project.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -71,7 +71,7 @@
71
71
  "@prismicio/mocks": "2.14.0",
72
72
  "@prismicio/types-internal": "3.11.2",
73
73
  "@segment/analytics-node": "^2.1.2",
74
- "@slicemachine/plugin-kit": "0.4.90-alpha.jp-import-slices-3.2",
74
+ "@slicemachine/plugin-kit": "0.4.90-alpha.jp-import-slices-3.3",
75
75
  "cookie": "^1.0.1",
76
76
  "cors": "^2.8.5",
77
77
  "execa": "^7.1.1",
@@ -49,7 +49,7 @@ export const API_ENDPOINTS: APIEndpoints = (() => {
49
49
  "https://api.internal.wroom.io/custom-type/",
50
50
  ),
51
51
  GitService: addTrailingSlash(
52
- process.env.git_service_endpoint ?? "https://git.internal.wroom.io/",
52
+ process.env.git_service_api ?? "https://api.internal.wroom.io/git/",
53
53
  ),
54
54
  };
55
55
 
@@ -100,7 +100,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
100
100
  RepositoryService: "https://api.internal.wroom.io/repository/",
101
101
  LocaleService: "https://api.internal.wroom.io/locale/",
102
102
  CustomTypeService: "https://api.internal.wroom.io/custom-type/",
103
- GitService: "https://git.internal.wroom.io/",
103
+ GitService: "https://api.internal.wroom.io/git/",
104
104
  };
105
105
  }
106
106
 
@@ -119,7 +119,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
119
119
  RepositoryService: `https://api.internal.${process.env.SM_ENV}-wroom.com/repository/`,
120
120
  LocaleService: `https://api.internal.${process.env.SM_ENV}-wroom.com/locale/`,
121
121
  CustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`,
122
- GitService: `https://git.internal.${process.env.SM_ENV}-wroom.com/`,
122
+ GitService: `https://api.internal.${process.env.SM_ENV}-wroom.com/git/`,
123
123
  };
124
124
  }
125
125
 
@@ -137,7 +137,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
137
137
  RepositoryService: "https://api.internal.prismic.io/repository/",
138
138
  LocaleService: "https://api.internal.prismic.io/locale/",
139
139
  CustomTypeService: "https://api.internal.prismic.io/custom-type/",
140
- GitService: "https://git.internal.prismic.io/",
140
+ GitService: "https://api.internal.prismic.io/git/",
141
141
  };
142
142
  }
143
143
  }
@@ -758,20 +758,17 @@ export class PrismicRepositoryManager extends BaseManager {
758
758
  );
759
759
  }
760
760
 
761
- if (value) {
762
- return value;
763
- }
764
-
765
- throw new Error("Failed to fetch integrations.");
761
+ return value;
766
762
  }
767
763
 
768
764
  async fetchGitIntegrationToken(args: {
769
765
  integrationId: string;
770
766
  }): Promise<z.infer<typeof GitIntegrationTokenSchema>> {
767
+ const { integrationId } = args;
771
768
  const repositoryName = await this.project.getRepositoryName();
772
769
 
773
770
  const url = new URL(
774
- `integrations/${args.integrationId}/token`,
771
+ `integrations/${integrationId}/token`,
775
772
  API_ENDPOINTS.GitService,
776
773
  );
777
774
  url.searchParams.set("repository", repositoryName);
@@ -781,7 +778,7 @@ export class PrismicRepositoryManager extends BaseManager {
781
778
  if (!res.ok) {
782
779
  const text = await res.text();
783
780
  throw new Error(
784
- `Failed to fetch token for integration ${args.integrationId}`,
781
+ `Failed to fetch token for integration ${integrationId}`,
785
782
  { cause: text },
786
783
  );
787
784
  }