@slicemachine/manager 0.24.15-alpha.jp-update-cr-links-base.1 → 0.24.15-alpha.jp-cr-ui.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/dist/_node_modules/@amplitude/analytics-core/_node_modules/tslib/tslib.es6.cjs.map +1 -1
  2. package/dist/_node_modules/@amplitude/analytics-core/_node_modules/tslib/tslib.es6.js.map +1 -1
  3. package/dist/_node_modules/@amplitude/analytics-core/lib/esm/plugins/destination.cjs.map +1 -1
  4. package/dist/_node_modules/@amplitude/analytics-core/lib/esm/plugins/destination.js.map +1 -1
  5. package/dist/_node_modules/@amplitude/analytics-core/lib/esm/utils/debug.cjs.map +1 -1
  6. package/dist/_node_modules/@amplitude/analytics-core/lib/esm/utils/debug.js.map +1 -1
  7. package/dist/_node_modules/@amplitude/analytics-core/lib/esm/utils/valid-properties.cjs.map +1 -1
  8. package/dist/_node_modules/@amplitude/analytics-core/lib/esm/utils/valid-properties.js.map +1 -1
  9. package/dist/_node_modules/@amplitude/analytics-node/_node_modules/tslib/tslib.es6.cjs.map +1 -1
  10. package/dist/_node_modules/@amplitude/analytics-node/_node_modules/tslib/tslib.es6.js.map +1 -1
  11. package/dist/_node_modules/@amplitude/analytics-node/lib/esm/transports/http.cjs.map +1 -1
  12. package/dist/_node_modules/@amplitude/analytics-node/lib/esm/transports/http.js.map +1 -1
  13. package/dist/_node_modules/@amplitude/experiment-core/dist/experiment-core.esm.cjs.map +1 -1
  14. package/dist/_node_modules/@amplitude/experiment-core/dist/experiment-core.esm.js.map +1 -1
  15. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/assignment/assignment-service.cjs.map +1 -1
  16. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/assignment/assignment-service.js.map +1 -1
  17. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/assignment/assignment.cjs.map +1 -1
  18. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/assignment/assignment.js.map +1 -1
  19. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/cookie.cjs.map +1 -1
  20. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/cookie.js.map +1 -1
  21. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/cache.cjs.map +1 -1
  22. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/cache.js.map +1 -1
  23. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.cjs.map +1 -1
  24. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.js.map +1 -1
  25. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/fetcher.cjs.map +1 -1
  26. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/fetcher.js.map +1 -1
  27. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/poller.cjs.map +1 -1
  28. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/poller.js.map +1 -1
  29. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/remote/client.cjs.map +1 -1
  30. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/remote/client.js.map +1 -1
  31. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/transport/http.cjs.map +1 -1
  32. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/transport/http.js.map +1 -1
  33. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/util/backoff.cjs.map +1 -1
  34. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/util/backoff.js.map +1 -1
  35. package/dist/_node_modules/@msgpack/msgpack/dist.es5_esm/Decoder.cjs.map +1 -1
  36. package/dist/_node_modules/@msgpack/msgpack/dist.es5_esm/Decoder.js.map +1 -1
  37. package/dist/_node_modules/cross-spawn/lib/enoent.cjs.map +1 -1
  38. package/dist/_node_modules/cross-spawn/lib/enoent.js.map +1 -1
  39. package/dist/_node_modules/cross-spawn/lib/parse.cjs.map +1 -1
  40. package/dist/_node_modules/cross-spawn/lib/parse.js.map +1 -1
  41. package/dist/_node_modules/cross-spawn/lib/util/escape.cjs.map +1 -1
  42. package/dist/_node_modules/cross-spawn/lib/util/escape.js.map +1 -1
  43. package/dist/_node_modules/cross-spawn/lib/util/readShebang.cjs.map +1 -1
  44. package/dist/_node_modules/cross-spawn/lib/util/readShebang.js.map +1 -1
  45. package/dist/_node_modules/cross-spawn/lib/util/resolveCommand.cjs.map +1 -1
  46. package/dist/_node_modules/cross-spawn/lib/util/resolveCommand.js.map +1 -1
  47. package/dist/_node_modules/data-uri-to-buffer/dist/index.cjs.map +1 -1
  48. package/dist/_node_modules/data-uri-to-buffer/dist/index.js.map +1 -1
  49. package/dist/_node_modules/execa/index.cjs +2 -2
  50. package/dist/_node_modules/execa/index.cjs.map +1 -1
  51. package/dist/_node_modules/execa/index.js +2 -2
  52. package/dist/_node_modules/execa/index.js.map +1 -1
  53. package/dist/_node_modules/execa/lib/command.cjs.map +1 -1
  54. package/dist/_node_modules/execa/lib/command.js.map +1 -1
  55. package/dist/_node_modules/execa/lib/error.cjs.map +1 -1
  56. package/dist/_node_modules/execa/lib/error.js.map +1 -1
  57. package/dist/_node_modules/execa/lib/kill.cjs.map +1 -1
  58. package/dist/_node_modules/execa/lib/kill.js.map +1 -1
  59. package/dist/_node_modules/execa/lib/promise.cjs +2 -2
  60. package/dist/_node_modules/execa/lib/promise.cjs.map +1 -1
  61. package/dist/_node_modules/execa/lib/promise.js +2 -2
  62. package/dist/_node_modules/execa/lib/promise.js.map +1 -1
  63. package/dist/_node_modules/execa/lib/stdio.cjs.map +1 -1
  64. package/dist/_node_modules/execa/lib/stdio.js.map +1 -1
  65. package/dist/_node_modules/execa/lib/stream.cjs.map +1 -1
  66. package/dist/_node_modules/execa/lib/stream.js.map +1 -1
  67. package/dist/_node_modules/execa/lib/verbose.cjs.map +1 -1
  68. package/dist/_node_modules/execa/lib/verbose.js.map +1 -1
  69. package/dist/_node_modules/fetch-blob/file.cjs.map +1 -1
  70. package/dist/_node_modules/fetch-blob/file.js.map +1 -1
  71. package/dist/_node_modules/fetch-blob/index.cjs.map +1 -1
  72. package/dist/_node_modules/fetch-blob/index.js.map +1 -1
  73. package/dist/_node_modules/fetch-blob/streams.cjs.map +1 -1
  74. package/dist/_node_modules/fetch-blob/streams.js.map +1 -1
  75. package/dist/_node_modules/file-type/core.cjs.map +1 -1
  76. package/dist/_node_modules/file-type/core.js.map +1 -1
  77. package/dist/_node_modules/formdata-polyfill/esm.min.cjs.map +1 -1
  78. package/dist/_node_modules/formdata-polyfill/esm.min.js.map +1 -1
  79. package/dist/_node_modules/get-port/index.cjs.map +1 -1
  80. package/dist/_node_modules/get-port/index.js.map +1 -1
  81. package/dist/_node_modules/get-stream/index.cjs.map +1 -1
  82. package/dist/_node_modules/get-stream/index.js.map +1 -1
  83. package/dist/_node_modules/human-signals/build/src/realtime.cjs.map +1 -1
  84. package/dist/_node_modules/human-signals/build/src/realtime.js.map +1 -1
  85. package/dist/_node_modules/isexe/index.cjs.map +1 -1
  86. package/dist/_node_modules/isexe/index.js.map +1 -1
  87. package/dist/_node_modules/mimic-fn/index.cjs.map +1 -1
  88. package/dist/_node_modules/mimic-fn/index.js.map +1 -1
  89. package/dist/_node_modules/node-domexception/index.cjs.map +1 -1
  90. package/dist/_node_modules/node-domexception/index.js.map +1 -1
  91. package/dist/_node_modules/node-fetch/src/body.cjs.map +1 -1
  92. package/dist/_node_modules/node-fetch/src/body.js.map +1 -1
  93. package/dist/_node_modules/node-fetch/src/headers.cjs.map +1 -1
  94. package/dist/_node_modules/node-fetch/src/headers.js.map +1 -1
  95. package/dist/_node_modules/node-fetch/src/index.cjs.map +1 -1
  96. package/dist/_node_modules/node-fetch/src/index.js.map +1 -1
  97. package/dist/_node_modules/node-fetch/src/request.cjs.map +1 -1
  98. package/dist/_node_modules/node-fetch/src/request.js.map +1 -1
  99. package/dist/_node_modules/node-fetch/src/utils/is.cjs.map +1 -1
  100. package/dist/_node_modules/node-fetch/src/utils/is.js.map +1 -1
  101. package/dist/_node_modules/node-fetch/src/utils/multipart-parser.cjs.map +1 -1
  102. package/dist/_node_modules/node-fetch/src/utils/multipart-parser.js.map +1 -1
  103. package/dist/_node_modules/node-fetch/src/utils/referrer.cjs.map +1 -1
  104. package/dist/_node_modules/node-fetch/src/utils/referrer.js.map +1 -1
  105. package/dist/_node_modules/npm-run-path/_node_modules/path-key/index.cjs.map +1 -0
  106. package/dist/_node_modules/npm-run-path/_node_modules/path-key/index.js.map +1 -0
  107. package/dist/_node_modules/{execa/_node_modules/npm-run-path → npm-run-path}/index.cjs +1 -1
  108. package/dist/_node_modules/npm-run-path/index.cjs.map +1 -0
  109. package/dist/_node_modules/{execa/_node_modules/npm-run-path → npm-run-path}/index.js +1 -1
  110. package/dist/_node_modules/npm-run-path/index.js.map +1 -0
  111. package/dist/_node_modules/{execa/_node_modules/onetime → onetime}/index.cjs +1 -1
  112. package/dist/_node_modules/onetime/index.cjs.map +1 -0
  113. package/dist/_node_modules/{execa/_node_modules/onetime → onetime}/index.js +1 -1
  114. package/dist/_node_modules/onetime/index.js.map +1 -0
  115. package/dist/_node_modules/p-limit/index.cjs.map +1 -1
  116. package/dist/_node_modules/p-limit/index.js.map +1 -1
  117. package/dist/_node_modules/r19/dist/handleRPCRequest.cjs.map +1 -1
  118. package/dist/_node_modules/r19/dist/handleRPCRequest.js.map +1 -1
  119. package/dist/_node_modules/shebang-command/index.cjs.map +1 -1
  120. package/dist/_node_modules/shebang-command/index.js.map +1 -1
  121. package/dist/_node_modules/signal-exit/index.cjs.map +1 -1
  122. package/dist/_node_modules/signal-exit/index.js.map +1 -1
  123. package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs.map +1 -1
  124. package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -1
  125. package/dist/_node_modules/which/which.cjs.map +1 -1
  126. package/dist/_node_modules/which/which.js.map +1 -1
  127. package/dist/_node_modules/zod/lib/index.cjs.map +1 -1
  128. package/dist/_node_modules/zod/lib/index.js.map +1 -1
  129. package/dist/_virtual/_commonjsHelpers.cjs +1 -4
  130. package/dist/_virtual/_commonjsHelpers.cjs.map +1 -1
  131. package/dist/_virtual/_commonjsHelpers.js +1 -4
  132. package/dist/_virtual/_commonjsHelpers.js.map +1 -1
  133. package/dist/auth/PrismicAuthManager.cjs.map +1 -1
  134. package/dist/auth/PrismicAuthManager.js.map +1 -1
  135. package/dist/auth/createPrismicAuthManagerMiddleware.cjs.map +1 -1
  136. package/dist/auth/createPrismicAuthManagerMiddleware.js.map +1 -1
  137. package/dist/constants/API_ENDPOINTS.cjs.map +1 -1
  138. package/dist/constants/API_ENDPOINTS.js.map +1 -1
  139. package/dist/constants/API_TOKENS.cjs.map +1 -1
  140. package/dist/constants/API_TOKENS.js.map +1 -1
  141. package/dist/errors.cjs.map +1 -1
  142. package/dist/errors.js.map +1 -1
  143. package/dist/getEnvironmentInfo.cjs.map +1 -1
  144. package/dist/getEnvironmentInfo.js.map +1 -1
  145. package/dist/lib/DecodeError.cjs.map +1 -1
  146. package/dist/lib/DecodeError.js.map +1 -1
  147. package/dist/lib/buildPrismicRepositoryAPIEndpoint.cjs.map +1 -1
  148. package/dist/lib/buildPrismicRepositoryAPIEndpoint.js.map +1 -1
  149. package/dist/lib/fetchGitHubReleaseBodyForRelease.cjs.map +1 -1
  150. package/dist/lib/fetchGitHubReleaseBodyForRelease.js.map +1 -1
  151. package/dist/lib/fetchNPMPackageVersions.cjs.map +1 -1
  152. package/dist/lib/fetchNPMPackageVersions.js.map +1 -1
  153. package/dist/lib/installDependencies.cjs.map +1 -1
  154. package/dist/lib/installDependencies.js.map +1 -1
  155. package/dist/lib/locateFileUpward.cjs.map +1 -1
  156. package/dist/lib/locateFileUpward.js.map +1 -1
  157. package/dist/lib/prismicrc.cjs.map +1 -1
  158. package/dist/lib/prismicrc.js.map +1 -1
  159. package/dist/managers/SliceMachineManager.cjs.map +1 -1
  160. package/dist/managers/SliceMachineManager.js.map +1 -1
  161. package/dist/managers/customTypes/CustomTypesManager.cjs +90 -54
  162. package/dist/managers/customTypes/CustomTypesManager.cjs.map +1 -1
  163. package/dist/managers/customTypes/CustomTypesManager.d.ts +17 -5
  164. package/dist/managers/customTypes/CustomTypesManager.js +90 -54
  165. package/dist/managers/customTypes/CustomTypesManager.js.map +1 -1
  166. package/dist/managers/git/GitManager.cjs.map +1 -1
  167. package/dist/managers/git/GitManager.js.map +1 -1
  168. package/dist/managers/git/buildGitRepoSpecifier.cjs.map +1 -1
  169. package/dist/managers/git/buildGitRepoSpecifier.js.map +1 -1
  170. package/dist/managers/prismicRepository/PrismicRepositoryManager.cjs.map +1 -1
  171. package/dist/managers/prismicRepository/PrismicRepositoryManager.js.map +1 -1
  172. package/dist/managers/project/ProjectManager.cjs.map +1 -1
  173. package/dist/managers/project/ProjectManager.js.map +1 -1
  174. package/dist/managers/screenshots/ScreenshotsManager.cjs.map +1 -1
  175. package/dist/managers/screenshots/ScreenshotsManager.js.map +1 -1
  176. package/dist/managers/sliceTemplateLibrary/SliceTemplateLibraryManager.cjs.map +1 -1
  177. package/dist/managers/sliceTemplateLibrary/SliceTemplateLibraryManager.js.map +1 -1
  178. package/dist/managers/slices/SlicesManager.cjs.map +1 -1
  179. package/dist/managers/slices/SlicesManager.js.map +1 -1
  180. package/dist/managers/telemetry/TelemetryManager.cjs.map +1 -1
  181. package/dist/managers/telemetry/TelemetryManager.js.map +1 -1
  182. package/dist/managers/versions/VersionsManager.cjs.map +1 -1
  183. package/dist/managers/versions/VersionsManager.js.map +1 -1
  184. package/package.json +3 -3
  185. package/src/managers/customTypes/CustomTypesManager.ts +140 -78
  186. package/dist/_node_modules/execa/_node_modules/npm-run-path/index.cjs.map +0 -1
  187. package/dist/_node_modules/execa/_node_modules/npm-run-path/index.js.map +0 -1
  188. package/dist/_node_modules/execa/_node_modules/onetime/index.cjs.map +0 -1
  189. package/dist/_node_modules/execa/_node_modules/onetime/index.js.map +0 -1
  190. package/dist/_node_modules/execa/_node_modules/path-key/index.cjs.map +0 -1
  191. package/dist/_node_modules/execa/_node_modules/path-key/index.js.map +0 -1
  192. /package/dist/_node_modules/{execa → npm-run-path}/_node_modules/path-key/index.cjs +0 -0
  193. /package/dist/_node_modules/{execa → npm-run-path}/_node_modules/path-key/index.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"installDependencies.cjs","sources":["../../../src/lib/installDependencies.ts"],"sourcesContent":["import { parseNi } from \"@antfu/ni\";\nimport {\n\tExecaChildProcess,\n\texecaCommand,\n\tOptions as ExacaOptions,\n} from \"execa\";\n\nimport { PackageManager } from \"../types\";\n\nconst EXTRA_INSTALL_FLAGS: Record<PackageManager, string[]> = {\n\tnpm: [\"--color=always\", \"--loglevel=info\"], // Default: `--color=true --loglevel=notice`.\n\tpnpm: [], // Default: `--color=auto --loglevel=info`.\n\tyarn: [], // TODO: Add the correct options.\n\t\"yarn@berry\": [], // TODO: Add the correct options.\n\t\"pnpm@6\": [], // // TODO: Add the correct options.\n\tbun: [], // TODO: Add the correct options.\n};\n\ntype InstallDependenciesArgs = {\n\tpackageManager: PackageManager;\n\tdependencies: Record<string, string>;\n\tdev?: boolean;\n\texeca?: ExacaOptions;\n};\n\ntype InstallDependenciesReturnType = {\n\texecaProcess: ExecaChildProcess;\n};\n\nexport const installDependencies = async (\n\targs: InstallDependenciesArgs,\n): Promise<InstallDependenciesReturnType> => {\n\tconst commandArgs = Object.entries(args.dependencies).map(\n\t\t([pkg, range]) => `${pkg}@${range}`,\n\t);\n\n\tif (commandArgs.length && args.dev) {\n\t\tcommandArgs.unshift(\"-D\");\n\t}\n\n\tcommandArgs.push(...EXTRA_INSTALL_FLAGS[args.packageManager]);\n\n\tconst command = await parseNi(args.packageManager, commandArgs);\n\n\tif (!command) {\n\t\tthrow new Error(\n\t\t\t\"Failed to begin dependency installation (could not parse command)\",\n\t\t\t{\n\t\t\t\tcause: {\n\t\t\t\t\tpackageManager: args.packageManager,\n\t\t\t\t\tdependencies: args.dependencies,\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t}\n\n\tconst execaProcess = execaCommand(command, {\n\t\tencoding: \"utf-8\",\n\t\t...args.execa,\n\t});\n\n\treturn {\n\t\texecaProcess,\n\t};\n};\n"],"names":["parseNi","execaCommand"],"mappings":";;;;AASA,MAAM,sBAAwD;AAAA,EAC7D,KAAK,CAAC,kBAAkB,iBAAiB;AAAA;AAAA,EACzC,MAAM,CAAE;AAAA;AAAA,EACR,MAAM,CAAE;AAAA;AAAA,EACR,cAAc,CAAE;AAAA;AAAA,EAChB,UAAU,CAAE;AAAA;AAAA,EACZ,KAAK,CAAE;AAAA;;AAcK,MAAA,sBAAsB,OAClC,SAC2C;AAC3C,QAAM,cAAc,OAAO,QAAQ,KAAK,YAAY,EAAE,IACrD,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG,OAAO,OAAO;AAGhC,MAAA,YAAY,UAAU,KAAK,KAAK;AACnC,gBAAY,QAAQ,IAAI;AAAA,EACzB;AAEA,cAAY,KAAK,GAAG,oBAAoB,KAAK,cAAc,CAAC;AAE5D,QAAM,UAAU,MAAMA,GAAQ,QAAA,KAAK,gBAAgB,WAAW;AAE9D,MAAI,CAAC,SAAS;AACP,UAAA,IAAI,MACT,qEACA;AAAA,MACC,OAAO;AAAA,QACN,gBAAgB,KAAK;AAAA,QACrB,cAAc,KAAK;AAAA,MACnB;AAAA,IAAA,CACD;AAAA,EAEH;AAEM,QAAA,eAAeC,mBAAa,SAAS;AAAA,IAC1C,UAAU;AAAA,IACV,GAAG,KAAK;AAAA,EAAA,CACR;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;;"}
1
+ {"version":3,"file":"installDependencies.cjs","sources":["../../../src/lib/installDependencies.ts"],"sourcesContent":["import { parseNi } from \"@antfu/ni\";\nimport {\n\tExecaChildProcess,\n\texecaCommand,\n\tOptions as ExacaOptions,\n} from \"execa\";\n\nimport { PackageManager } from \"../types\";\n\nconst EXTRA_INSTALL_FLAGS: Record<PackageManager, string[]> = {\n\tnpm: [\"--color=always\", \"--loglevel=info\"], // Default: `--color=true --loglevel=notice`.\n\tpnpm: [], // Default: `--color=auto --loglevel=info`.\n\tyarn: [], // TODO: Add the correct options.\n\t\"yarn@berry\": [], // TODO: Add the correct options.\n\t\"pnpm@6\": [], // // TODO: Add the correct options.\n\tbun: [], // TODO: Add the correct options.\n};\n\ntype InstallDependenciesArgs = {\n\tpackageManager: PackageManager;\n\tdependencies: Record<string, string>;\n\tdev?: boolean;\n\texeca?: ExacaOptions;\n};\n\ntype InstallDependenciesReturnType = {\n\texecaProcess: ExecaChildProcess;\n};\n\nexport const installDependencies = async (\n\targs: InstallDependenciesArgs,\n): Promise<InstallDependenciesReturnType> => {\n\tconst commandArgs = Object.entries(args.dependencies).map(\n\t\t([pkg, range]) => `${pkg}@${range}`,\n\t);\n\n\tif (commandArgs.length && args.dev) {\n\t\tcommandArgs.unshift(\"-D\");\n\t}\n\n\tcommandArgs.push(...EXTRA_INSTALL_FLAGS[args.packageManager]);\n\n\tconst command = await parseNi(args.packageManager, commandArgs);\n\n\tif (!command) {\n\t\tthrow new Error(\n\t\t\t\"Failed to begin dependency installation (could not parse command)\",\n\t\t\t{\n\t\t\t\tcause: {\n\t\t\t\t\tpackageManager: args.packageManager,\n\t\t\t\t\tdependencies: args.dependencies,\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t}\n\n\tconst execaProcess = execaCommand(command, {\n\t\tencoding: \"utf-8\",\n\t\t...args.execa,\n\t});\n\n\treturn {\n\t\texecaProcess,\n\t};\n};\n"],"names":["parseNi","execaCommand"],"mappings":";;;;AASA,MAAM,sBAAwD;AAAA,EAC7D,KAAK,CAAC,kBAAkB,iBAAiB;AAAA;AAAA,EACzC,MAAM,CAAE;AAAA;AAAA,EACR,MAAM,CAAE;AAAA;AAAA,EACR,cAAc,CAAE;AAAA;AAAA,EAChB,UAAU,CAAE;AAAA;AAAA,EACZ,KAAK,CAAE;AAAA;;AAcK,MAAA,sBAAsB,OAClC,SAC2C;AAC3C,QAAM,cAAc,OAAO,QAAQ,KAAK,YAAY,EAAE,IACrD,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE;AAGhC,MAAA,YAAY,UAAU,KAAK,KAAK;AACnC,gBAAY,QAAQ,IAAI;AAAA,EACzB;AAEA,cAAY,KAAK,GAAG,oBAAoB,KAAK,cAAc,CAAC;AAE5D,QAAM,UAAU,MAAMA,GAAQ,QAAA,KAAK,gBAAgB,WAAW;AAE9D,MAAI,CAAC,SAAS;AACP,UAAA,IAAI,MACT,qEACA;AAAA,MACC,OAAO;AAAA,QACN,gBAAgB,KAAK;AAAA,QACrB,cAAc,KAAK;AAAA,MACnB;AAAA,IAAA,CACD;AAAA,EAEH;AAEM,QAAA,eAAeC,mBAAa,SAAS;AAAA,IAC1C,UAAU;AAAA,IACV,GAAG,KAAK;AAAA,EAAA,CACR;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"installDependencies.js","sources":["../../../src/lib/installDependencies.ts"],"sourcesContent":["import { parseNi } from \"@antfu/ni\";\nimport {\n\tExecaChildProcess,\n\texecaCommand,\n\tOptions as ExacaOptions,\n} from \"execa\";\n\nimport { PackageManager } from \"../types\";\n\nconst EXTRA_INSTALL_FLAGS: Record<PackageManager, string[]> = {\n\tnpm: [\"--color=always\", \"--loglevel=info\"], // Default: `--color=true --loglevel=notice`.\n\tpnpm: [], // Default: `--color=auto --loglevel=info`.\n\tyarn: [], // TODO: Add the correct options.\n\t\"yarn@berry\": [], // TODO: Add the correct options.\n\t\"pnpm@6\": [], // // TODO: Add the correct options.\n\tbun: [], // TODO: Add the correct options.\n};\n\ntype InstallDependenciesArgs = {\n\tpackageManager: PackageManager;\n\tdependencies: Record<string, string>;\n\tdev?: boolean;\n\texeca?: ExacaOptions;\n};\n\ntype InstallDependenciesReturnType = {\n\texecaProcess: ExecaChildProcess;\n};\n\nexport const installDependencies = async (\n\targs: InstallDependenciesArgs,\n): Promise<InstallDependenciesReturnType> => {\n\tconst commandArgs = Object.entries(args.dependencies).map(\n\t\t([pkg, range]) => `${pkg}@${range}`,\n\t);\n\n\tif (commandArgs.length && args.dev) {\n\t\tcommandArgs.unshift(\"-D\");\n\t}\n\n\tcommandArgs.push(...EXTRA_INSTALL_FLAGS[args.packageManager]);\n\n\tconst command = await parseNi(args.packageManager, commandArgs);\n\n\tif (!command) {\n\t\tthrow new Error(\n\t\t\t\"Failed to begin dependency installation (could not parse command)\",\n\t\t\t{\n\t\t\t\tcause: {\n\t\t\t\t\tpackageManager: args.packageManager,\n\t\t\t\t\tdependencies: args.dependencies,\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t}\n\n\tconst execaProcess = execaCommand(command, {\n\t\tencoding: \"utf-8\",\n\t\t...args.execa,\n\t});\n\n\treturn {\n\t\texecaProcess,\n\t};\n};\n"],"names":[],"mappings":";;AASA,MAAM,sBAAwD;AAAA,EAC7D,KAAK,CAAC,kBAAkB,iBAAiB;AAAA;AAAA,EACzC,MAAM,CAAE;AAAA;AAAA,EACR,MAAM,CAAE;AAAA;AAAA,EACR,cAAc,CAAE;AAAA;AAAA,EAChB,UAAU,CAAE;AAAA;AAAA,EACZ,KAAK,CAAE;AAAA;;AAcK,MAAA,sBAAsB,OAClC,SAC2C;AAC3C,QAAM,cAAc,OAAO,QAAQ,KAAK,YAAY,EAAE,IACrD,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG,OAAO,OAAO;AAGhC,MAAA,YAAY,UAAU,KAAK,KAAK;AACnC,gBAAY,QAAQ,IAAI;AAAA,EACzB;AAEA,cAAY,KAAK,GAAG,oBAAoB,KAAK,cAAc,CAAC;AAE5D,QAAM,UAAU,MAAM,QAAQ,KAAK,gBAAgB,WAAW;AAE9D,MAAI,CAAC,SAAS;AACP,UAAA,IAAI,MACT,qEACA;AAAA,MACC,OAAO;AAAA,QACN,gBAAgB,KAAK;AAAA,QACrB,cAAc,KAAK;AAAA,MACnB;AAAA,IAAA,CACD;AAAA,EAEH;AAEM,QAAA,eAAe,aAAa,SAAS;AAAA,IAC1C,UAAU;AAAA,IACV,GAAG,KAAK;AAAA,EAAA,CACR;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"installDependencies.js","sources":["../../../src/lib/installDependencies.ts"],"sourcesContent":["import { parseNi } from \"@antfu/ni\";\nimport {\n\tExecaChildProcess,\n\texecaCommand,\n\tOptions as ExacaOptions,\n} from \"execa\";\n\nimport { PackageManager } from \"../types\";\n\nconst EXTRA_INSTALL_FLAGS: Record<PackageManager, string[]> = {\n\tnpm: [\"--color=always\", \"--loglevel=info\"], // Default: `--color=true --loglevel=notice`.\n\tpnpm: [], // Default: `--color=auto --loglevel=info`.\n\tyarn: [], // TODO: Add the correct options.\n\t\"yarn@berry\": [], // TODO: Add the correct options.\n\t\"pnpm@6\": [], // // TODO: Add the correct options.\n\tbun: [], // TODO: Add the correct options.\n};\n\ntype InstallDependenciesArgs = {\n\tpackageManager: PackageManager;\n\tdependencies: Record<string, string>;\n\tdev?: boolean;\n\texeca?: ExacaOptions;\n};\n\ntype InstallDependenciesReturnType = {\n\texecaProcess: ExecaChildProcess;\n};\n\nexport const installDependencies = async (\n\targs: InstallDependenciesArgs,\n): Promise<InstallDependenciesReturnType> => {\n\tconst commandArgs = Object.entries(args.dependencies).map(\n\t\t([pkg, range]) => `${pkg}@${range}`,\n\t);\n\n\tif (commandArgs.length && args.dev) {\n\t\tcommandArgs.unshift(\"-D\");\n\t}\n\n\tcommandArgs.push(...EXTRA_INSTALL_FLAGS[args.packageManager]);\n\n\tconst command = await parseNi(args.packageManager, commandArgs);\n\n\tif (!command) {\n\t\tthrow new Error(\n\t\t\t\"Failed to begin dependency installation (could not parse command)\",\n\t\t\t{\n\t\t\t\tcause: {\n\t\t\t\t\tpackageManager: args.packageManager,\n\t\t\t\t\tdependencies: args.dependencies,\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t}\n\n\tconst execaProcess = execaCommand(command, {\n\t\tencoding: \"utf-8\",\n\t\t...args.execa,\n\t});\n\n\treturn {\n\t\texecaProcess,\n\t};\n};\n"],"names":[],"mappings":";;AASA,MAAM,sBAAwD;AAAA,EAC7D,KAAK,CAAC,kBAAkB,iBAAiB;AAAA;AAAA,EACzC,MAAM,CAAE;AAAA;AAAA,EACR,MAAM,CAAE;AAAA;AAAA,EACR,cAAc,CAAE;AAAA;AAAA,EAChB,UAAU,CAAE;AAAA;AAAA,EACZ,KAAK,CAAE;AAAA;;AAcK,MAAA,sBAAsB,OAClC,SAC2C;AAC3C,QAAM,cAAc,OAAO,QAAQ,KAAK,YAAY,EAAE,IACrD,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE;AAGhC,MAAA,YAAY,UAAU,KAAK,KAAK;AACnC,gBAAY,QAAQ,IAAI;AAAA,EACzB;AAEA,cAAY,KAAK,GAAG,oBAAoB,KAAK,cAAc,CAAC;AAE5D,QAAM,UAAU,MAAM,QAAQ,KAAK,gBAAgB,WAAW;AAE9D,MAAI,CAAC,SAAS;AACP,UAAA,IAAI,MACT,qEACA;AAAA,MACC,OAAO;AAAA,QACN,gBAAgB,KAAK;AAAA,QACrB,cAAc,KAAK;AAAA,MACnB;AAAA,IAAA,CACD;AAAA,EAEH;AAEM,QAAA,eAAe,aAAa,SAAS;AAAA,IAC1C,UAAU;AAAA,IACV,GAAG,KAAK;AAAA,EAAA,CACR;AAEM,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"locateFileUpward.cjs","sources":["../../../src/lib/locateFileUpward.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs/promises\";\n\nimport { castArray } from \"./castArray\";\n\ntype LocateFileUpwardConfig = {\n\tstartDir?: string;\n\tstopDir?: string;\n\t/**\n\t * @internal\n\t */\n\t_originalStartDir?: string;\n};\n\nexport const locateFileUpward = async (\n\tfilePathOrPaths: string | readonly string[],\n\t{\n\t\tstartDir = process.cwd(),\n\t\tstopDir = path.resolve(startDir, \"/\"),\n\t\t_originalStartDir,\n\t}: LocateFileUpwardConfig = {},\n): Promise<string> => {\n\tconst originalStartDir = _originalStartDir ?? startDir;\n\n\tconst filePaths = castArray(filePathOrPaths);\n\n\tfor (const filePath of filePaths) {\n\t\tconst resolvedFilePath = path.resolve(startDir, filePath);\n\t\ttry {\n\t\t\tawait fs.access(resolvedFilePath);\n\n\t\t\treturn resolvedFilePath;\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tif (startDir === stopDir) {\n\t\tconst formattedFilePaths = filePaths\n\t\t\t.map((filePath) => \"`\" + filePath + \"`\")\n\t\t\t.join(\" or \");\n\n\t\tthrow new Error(\n\t\t\t`Could not locate ${formattedFilePaths} between \\`${originalStartDir}\\` and \\`${stopDir}\\`.`,\n\t\t);\n\t}\n\n\treturn locateFileUpward(filePathOrPaths, {\n\t\tstartDir: path.resolve(startDir, \"..\"),\n\t\tstopDir,\n\t\t_originalStartDir: originalStartDir,\n\t});\n};\n"],"names":["path","castArray","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAcO,MAAM,mBAAmB,OAC/B,iBACA,EACC,WAAW,QAAQ,IAAG,GACtB,UAAUA,gBAAK,QAAQ,UAAU,GAAG,GACpC,kBAC2B,IAAA,CAAA,MACR;AACpB,QAAM,mBAAmB,qBAAqB;AAExC,QAAA,YAAYC,oBAAU,eAAe;AAE3C,aAAW,YAAY,WAAW;AACjC,UAAM,mBAAmBD,gBAAK,QAAQ,UAAU,QAAQ;AACpD,QAAA;AACG,YAAAE,cAAG,OAAO,gBAAgB;AAEzB,aAAA;AAAA,IAAA,QACN;AACD;AAAA,IACD;AAAA,EACD;AAEA,MAAI,aAAa,SAAS;AACnB,UAAA,qBAAqB,UACzB,IAAI,CAAC,aAAa,MAAM,WAAW,GAAG,EACtC,KAAK,MAAM;AAEb,UAAM,IAAI,MACT,oBAAoB,gCAAgC,4BAA4B,YAAY;AAAA,EAE9F;AAEA,SAAO,iBAAiB,iBAAiB;AAAA,IACxC,UAAUF,gBAAK,QAAQ,UAAU,IAAI;AAAA,IACrC;AAAA,IACA,mBAAmB;AAAA,EAAA,CACnB;AACF;;"}
1
+ {"version":3,"file":"locateFileUpward.cjs","sources":["../../../src/lib/locateFileUpward.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs/promises\";\n\nimport { castArray } from \"./castArray\";\n\ntype LocateFileUpwardConfig = {\n\tstartDir?: string;\n\tstopDir?: string;\n\t/**\n\t * @internal\n\t */\n\t_originalStartDir?: string;\n};\n\nexport const locateFileUpward = async (\n\tfilePathOrPaths: string | readonly string[],\n\t{\n\t\tstartDir = process.cwd(),\n\t\tstopDir = path.resolve(startDir, \"/\"),\n\t\t_originalStartDir,\n\t}: LocateFileUpwardConfig = {},\n): Promise<string> => {\n\tconst originalStartDir = _originalStartDir ?? startDir;\n\n\tconst filePaths = castArray(filePathOrPaths);\n\n\tfor (const filePath of filePaths) {\n\t\tconst resolvedFilePath = path.resolve(startDir, filePath);\n\t\ttry {\n\t\t\tawait fs.access(resolvedFilePath);\n\n\t\t\treturn resolvedFilePath;\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tif (startDir === stopDir) {\n\t\tconst formattedFilePaths = filePaths\n\t\t\t.map((filePath) => \"`\" + filePath + \"`\")\n\t\t\t.join(\" or \");\n\n\t\tthrow new Error(\n\t\t\t`Could not locate ${formattedFilePaths} between \\`${originalStartDir}\\` and \\`${stopDir}\\`.`,\n\t\t);\n\t}\n\n\treturn locateFileUpward(filePathOrPaths, {\n\t\tstartDir: path.resolve(startDir, \"..\"),\n\t\tstopDir,\n\t\t_originalStartDir: originalStartDir,\n\t});\n};\n"],"names":["path","castArray","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAcO,MAAM,mBAAmB,OAC/B,iBACA,EACC,WAAW,QAAQ,IAAG,GACtB,UAAUA,gBAAK,QAAQ,UAAU,GAAG,GACpC,kBAC2B,IAAA,CAAA,MACR;AACpB,QAAM,mBAAmB,qBAAqB;AAExC,QAAA,YAAYC,oBAAU,eAAe;AAE3C,aAAW,YAAY,WAAW;AACjC,UAAM,mBAAmBD,gBAAK,QAAQ,UAAU,QAAQ;AACpD,QAAA;AACG,YAAAE,cAAG,OAAO,gBAAgB;AAEzB,aAAA;AAAA,IAAA,QACA;AACP;AAAA,IACD;AAAA,EACD;AAEA,MAAI,aAAa,SAAS;AACnB,UAAA,qBAAqB,UACzB,IAAI,CAAC,aAAa,MAAM,WAAW,GAAG,EACtC,KAAK,MAAM;AAEP,UAAA,IAAI,MACT,oBAAoB,kBAAkB,cAAc,gBAAgB,YAAY,OAAO,KAAK;AAAA,EAE9F;AAEA,SAAO,iBAAiB,iBAAiB;AAAA,IACxC,UAAUF,gBAAK,QAAQ,UAAU,IAAI;AAAA,IACrC;AAAA,IACA,mBAAmB;AAAA,EAAA,CACnB;AACF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"locateFileUpward.js","sources":["../../../src/lib/locateFileUpward.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs/promises\";\n\nimport { castArray } from \"./castArray\";\n\ntype LocateFileUpwardConfig = {\n\tstartDir?: string;\n\tstopDir?: string;\n\t/**\n\t * @internal\n\t */\n\t_originalStartDir?: string;\n};\n\nexport const locateFileUpward = async (\n\tfilePathOrPaths: string | readonly string[],\n\t{\n\t\tstartDir = process.cwd(),\n\t\tstopDir = path.resolve(startDir, \"/\"),\n\t\t_originalStartDir,\n\t}: LocateFileUpwardConfig = {},\n): Promise<string> => {\n\tconst originalStartDir = _originalStartDir ?? startDir;\n\n\tconst filePaths = castArray(filePathOrPaths);\n\n\tfor (const filePath of filePaths) {\n\t\tconst resolvedFilePath = path.resolve(startDir, filePath);\n\t\ttry {\n\t\t\tawait fs.access(resolvedFilePath);\n\n\t\t\treturn resolvedFilePath;\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tif (startDir === stopDir) {\n\t\tconst formattedFilePaths = filePaths\n\t\t\t.map((filePath) => \"`\" + filePath + \"`\")\n\t\t\t.join(\" or \");\n\n\t\tthrow new Error(\n\t\t\t`Could not locate ${formattedFilePaths} between \\`${originalStartDir}\\` and \\`${stopDir}\\`.`,\n\t\t);\n\t}\n\n\treturn locateFileUpward(filePathOrPaths, {\n\t\tstartDir: path.resolve(startDir, \"..\"),\n\t\tstopDir,\n\t\t_originalStartDir: originalStartDir,\n\t});\n};\n"],"names":[],"mappings":";;;AAcO,MAAM,mBAAmB,OAC/B,iBACA,EACC,WAAW,QAAQ,IAAG,GACtB,UAAU,KAAK,QAAQ,UAAU,GAAG,GACpC,kBAC2B,IAAA,CAAA,MACR;AACpB,QAAM,mBAAmB,qBAAqB;AAExC,QAAA,YAAY,UAAU,eAAe;AAE3C,aAAW,YAAY,WAAW;AACjC,UAAM,mBAAmB,KAAK,QAAQ,UAAU,QAAQ;AACpD,QAAA;AACG,YAAA,GAAG,OAAO,gBAAgB;AAEzB,aAAA;AAAA,IAAA,QACN;AACD;AAAA,IACD;AAAA,EACD;AAEA,MAAI,aAAa,SAAS;AACnB,UAAA,qBAAqB,UACzB,IAAI,CAAC,aAAa,MAAM,WAAW,GAAG,EACtC,KAAK,MAAM;AAEb,UAAM,IAAI,MACT,oBAAoB,gCAAgC,4BAA4B,YAAY;AAAA,EAE9F;AAEA,SAAO,iBAAiB,iBAAiB;AAAA,IACxC,UAAU,KAAK,QAAQ,UAAU,IAAI;AAAA,IACrC;AAAA,IACA,mBAAmB;AAAA,EAAA,CACnB;AACF;"}
1
+ {"version":3,"file":"locateFileUpward.js","sources":["../../../src/lib/locateFileUpward.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs/promises\";\n\nimport { castArray } from \"./castArray\";\n\ntype LocateFileUpwardConfig = {\n\tstartDir?: string;\n\tstopDir?: string;\n\t/**\n\t * @internal\n\t */\n\t_originalStartDir?: string;\n};\n\nexport const locateFileUpward = async (\n\tfilePathOrPaths: string | readonly string[],\n\t{\n\t\tstartDir = process.cwd(),\n\t\tstopDir = path.resolve(startDir, \"/\"),\n\t\t_originalStartDir,\n\t}: LocateFileUpwardConfig = {},\n): Promise<string> => {\n\tconst originalStartDir = _originalStartDir ?? startDir;\n\n\tconst filePaths = castArray(filePathOrPaths);\n\n\tfor (const filePath of filePaths) {\n\t\tconst resolvedFilePath = path.resolve(startDir, filePath);\n\t\ttry {\n\t\t\tawait fs.access(resolvedFilePath);\n\n\t\t\treturn resolvedFilePath;\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tif (startDir === stopDir) {\n\t\tconst formattedFilePaths = filePaths\n\t\t\t.map((filePath) => \"`\" + filePath + \"`\")\n\t\t\t.join(\" or \");\n\n\t\tthrow new Error(\n\t\t\t`Could not locate ${formattedFilePaths} between \\`${originalStartDir}\\` and \\`${stopDir}\\`.`,\n\t\t);\n\t}\n\n\treturn locateFileUpward(filePathOrPaths, {\n\t\tstartDir: path.resolve(startDir, \"..\"),\n\t\tstopDir,\n\t\t_originalStartDir: originalStartDir,\n\t});\n};\n"],"names":[],"mappings":";;;AAcO,MAAM,mBAAmB,OAC/B,iBACA,EACC,WAAW,QAAQ,IAAG,GACtB,UAAU,KAAK,QAAQ,UAAU,GAAG,GACpC,kBAC2B,IAAA,CAAA,MACR;AACpB,QAAM,mBAAmB,qBAAqB;AAExC,QAAA,YAAY,UAAU,eAAe;AAE3C,aAAW,YAAY,WAAW;AACjC,UAAM,mBAAmB,KAAK,QAAQ,UAAU,QAAQ;AACpD,QAAA;AACG,YAAA,GAAG,OAAO,gBAAgB;AAEzB,aAAA;AAAA,IAAA,QACA;AACP;AAAA,IACD;AAAA,EACD;AAEA,MAAI,aAAa,SAAS;AACnB,UAAA,qBAAqB,UACzB,IAAI,CAAC,aAAa,MAAM,WAAW,GAAG,EACtC,KAAK,MAAM;AAEP,UAAA,IAAI,MACT,oBAAoB,kBAAkB,cAAc,gBAAgB,YAAY,OAAO,KAAK;AAAA,EAE9F;AAEA,SAAO,iBAAiB,iBAAiB;AAAA,IACxC,UAAU,KAAK,QAAQ,UAAU,IAAI;AAAA,IACrC;AAAA,IACA,mBAAmB;AAAA,EAAA,CACnB;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"prismicrc.cjs","sources":["../../../src/lib/prismicrc.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as t from \"io-ts\";\nimport * as rc9 from \"rc9\";\n\nimport { decode } from \"./decode\";\n\nconst PRISMICRC = \".prismicrc\";\n\nconst Prismicrc = t.partial({\n\ttelemetry: t.boolean,\n});\ntype Prismicrc = t.TypeOf<typeof Prismicrc>;\n\nexport const readRawPrismicrc = (dir?: string): Prismicrc => {\n\tconst rawPrismicrc = dir\n\t\t? rc9.read({ dir, name: PRISMICRC })\n\t\t: rc9.readUser(PRISMICRC);\n\n\tconst { value: prismicrc, error } = decode(Prismicrc, rawPrismicrc);\n\n\tif (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to parse ${\n\t\t\t\tdir ? path.resolve(dir, PRISMICRC) : `~/${PRISMICRC}`\n\t\t\t}: ${error.errors.join(\", \")}`,\n\t\t);\n\t}\n\n\treturn prismicrc;\n};\n\nexport const readPrismicrc = (dir: string): Prismicrc => {\n\tconst userPrismicrc = readRawPrismicrc();\n\tconst projectPrismicrc = readRawPrismicrc(dir);\n\n\treturn {\n\t\t...userPrismicrc,\n\t\t...projectPrismicrc,\n\t};\n};\n\nexport const writePrismicrc = (config: Prismicrc, dir?: string): void => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\tdir\n\t\t? rc9.write(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.writeUser(validatedConfig, PRISMICRC);\n};\n\nexport const updatePrismicrc = (config: Prismicrc, dir?: string): Prismicrc => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\treturn dir\n\t\t? rc9.update(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.updateUser(validatedConfig, PRISMICRC);\n};\n"],"names":["t","rc9","decode","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,YAAY;AAElB,MAAM,YAAYA,aAAE,QAAQ;AAAA,EAC3B,WAAWA,aAAE;AACb,CAAA;AAGY,MAAA,mBAAmB,CAAC,QAA2B;AAC3D,QAAM,eAAe,MAClBC,eAAI,KAAK,EAAE,KAAK,MAAM,UAAW,CAAA,IACjCA,eAAI,SAAS,SAAS;AAEzB,QAAM,EAAE,OAAO,WAAW,MAAU,IAAAC,cAAO,WAAW,YAAY;AAElE,MAAI,OAAO;AACV,UAAM,IAAI,MACT,mBACC,MAAMC,gBAAK,QAAQ,KAAK,SAAS,IAAI,KAAK,gBACtC,MAAM,OAAO,KAAK,IAAI,GAAG;AAAA,EAEhC;AAEO,SAAA;AACR;AAEa,MAAA,gBAAgB,CAAC,QAA0B;AACvD,QAAM,gBAAgB;AAChB,QAAA,mBAAmB,iBAAiB,GAAG;AAEtC,SAAA;AAAA,IACN,GAAG;AAAA,IACH,GAAG;AAAA,EAAA;AAEL;;;"}
1
+ {"version":3,"file":"prismicrc.cjs","sources":["../../../src/lib/prismicrc.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as t from \"io-ts\";\nimport * as rc9 from \"rc9\";\n\nimport { decode } from \"./decode\";\n\nconst PRISMICRC = \".prismicrc\";\n\nconst Prismicrc = t.partial({\n\ttelemetry: t.boolean,\n});\ntype Prismicrc = t.TypeOf<typeof Prismicrc>;\n\nexport const readRawPrismicrc = (dir?: string): Prismicrc => {\n\tconst rawPrismicrc = dir\n\t\t? rc9.read({ dir, name: PRISMICRC })\n\t\t: rc9.readUser(PRISMICRC);\n\n\tconst { value: prismicrc, error } = decode(Prismicrc, rawPrismicrc);\n\n\tif (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to parse ${\n\t\t\t\tdir ? path.resolve(dir, PRISMICRC) : `~/${PRISMICRC}`\n\t\t\t}: ${error.errors.join(\", \")}`,\n\t\t);\n\t}\n\n\treturn prismicrc;\n};\n\nexport const readPrismicrc = (dir: string): Prismicrc => {\n\tconst userPrismicrc = readRawPrismicrc();\n\tconst projectPrismicrc = readRawPrismicrc(dir);\n\n\treturn {\n\t\t...userPrismicrc,\n\t\t...projectPrismicrc,\n\t};\n};\n\nexport const writePrismicrc = (config: Prismicrc, dir?: string): void => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\tdir\n\t\t? rc9.write(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.writeUser(validatedConfig, PRISMICRC);\n};\n\nexport const updatePrismicrc = (config: Prismicrc, dir?: string): Prismicrc => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\treturn dir\n\t\t? rc9.update(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.updateUser(validatedConfig, PRISMICRC);\n};\n"],"names":["t","rc9","decode","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,YAAY;AAElB,MAAM,YAAYA,aAAE,QAAQ;AAAA,EAC3B,WAAWA,aAAE;AACb,CAAA;AAGY,MAAA,mBAAmB,CAAC,QAA2B;AAC3D,QAAM,eAAe,MAClBC,eAAI,KAAK,EAAE,KAAK,MAAM,UAAW,CAAA,IACjCA,eAAI,SAAS,SAAS;AAEzB,QAAM,EAAE,OAAO,WAAW,MAAU,IAAAC,cAAO,WAAW,YAAY;AAElE,MAAI,OAAO;AACV,UAAM,IAAI,MACT,mBACC,MAAMC,gBAAK,QAAQ,KAAK,SAAS,IAAI,KAAK,SAAS,EACpD,KAAK,MAAM,OAAO,KAAK,IAAI,CAAC,EAAE;AAAA,EAEhC;AAEO,SAAA;AACR;AAEa,MAAA,gBAAgB,CAAC,QAA0B;AACvD,QAAM,gBAAgB;AAChB,QAAA,mBAAmB,iBAAiB,GAAG;AAEtC,SAAA;AAAA,IACN,GAAG;AAAA,IACH,GAAG;AAAA,EAAA;AAEL;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"prismicrc.js","sources":["../../../src/lib/prismicrc.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as t from \"io-ts\";\nimport * as rc9 from \"rc9\";\n\nimport { decode } from \"./decode\";\n\nconst PRISMICRC = \".prismicrc\";\n\nconst Prismicrc = t.partial({\n\ttelemetry: t.boolean,\n});\ntype Prismicrc = t.TypeOf<typeof Prismicrc>;\n\nexport const readRawPrismicrc = (dir?: string): Prismicrc => {\n\tconst rawPrismicrc = dir\n\t\t? rc9.read({ dir, name: PRISMICRC })\n\t\t: rc9.readUser(PRISMICRC);\n\n\tconst { value: prismicrc, error } = decode(Prismicrc, rawPrismicrc);\n\n\tif (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to parse ${\n\t\t\t\tdir ? path.resolve(dir, PRISMICRC) : `~/${PRISMICRC}`\n\t\t\t}: ${error.errors.join(\", \")}`,\n\t\t);\n\t}\n\n\treturn prismicrc;\n};\n\nexport const readPrismicrc = (dir: string): Prismicrc => {\n\tconst userPrismicrc = readRawPrismicrc();\n\tconst projectPrismicrc = readRawPrismicrc(dir);\n\n\treturn {\n\t\t...userPrismicrc,\n\t\t...projectPrismicrc,\n\t};\n};\n\nexport const writePrismicrc = (config: Prismicrc, dir?: string): void => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\tdir\n\t\t? rc9.write(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.writeUser(validatedConfig, PRISMICRC);\n};\n\nexport const updatePrismicrc = (config: Prismicrc, dir?: string): Prismicrc => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\treturn dir\n\t\t? rc9.update(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.updateUser(validatedConfig, PRISMICRC);\n};\n"],"names":[],"mappings":";;;;AAMA,MAAM,YAAY;AAElB,MAAM,YAAY,EAAE,QAAQ;AAAA,EAC3B,WAAW,EAAE;AACb,CAAA;AAGY,MAAA,mBAAmB,CAAC,QAA2B;AAC3D,QAAM,eAAe,MAClB,IAAI,KAAK,EAAE,KAAK,MAAM,UAAW,CAAA,IACjC,IAAI,SAAS,SAAS;AAEzB,QAAM,EAAE,OAAO,WAAW,MAAU,IAAA,OAAO,WAAW,YAAY;AAElE,MAAI,OAAO;AACV,UAAM,IAAI,MACT,mBACC,MAAM,KAAK,QAAQ,KAAK,SAAS,IAAI,KAAK,gBACtC,MAAM,OAAO,KAAK,IAAI,GAAG;AAAA,EAEhC;AAEO,SAAA;AACR;AAEa,MAAA,gBAAgB,CAAC,QAA0B;AACvD,QAAM,gBAAgB;AAChB,QAAA,mBAAmB,iBAAiB,GAAG;AAEtC,SAAA;AAAA,IACN,GAAG;AAAA,IACH,GAAG;AAAA,EAAA;AAEL;"}
1
+ {"version":3,"file":"prismicrc.js","sources":["../../../src/lib/prismicrc.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as t from \"io-ts\";\nimport * as rc9 from \"rc9\";\n\nimport { decode } from \"./decode\";\n\nconst PRISMICRC = \".prismicrc\";\n\nconst Prismicrc = t.partial({\n\ttelemetry: t.boolean,\n});\ntype Prismicrc = t.TypeOf<typeof Prismicrc>;\n\nexport const readRawPrismicrc = (dir?: string): Prismicrc => {\n\tconst rawPrismicrc = dir\n\t\t? rc9.read({ dir, name: PRISMICRC })\n\t\t: rc9.readUser(PRISMICRC);\n\n\tconst { value: prismicrc, error } = decode(Prismicrc, rawPrismicrc);\n\n\tif (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to parse ${\n\t\t\t\tdir ? path.resolve(dir, PRISMICRC) : `~/${PRISMICRC}`\n\t\t\t}: ${error.errors.join(\", \")}`,\n\t\t);\n\t}\n\n\treturn prismicrc;\n};\n\nexport const readPrismicrc = (dir: string): Prismicrc => {\n\tconst userPrismicrc = readRawPrismicrc();\n\tconst projectPrismicrc = readRawPrismicrc(dir);\n\n\treturn {\n\t\t...userPrismicrc,\n\t\t...projectPrismicrc,\n\t};\n};\n\nexport const writePrismicrc = (config: Prismicrc, dir?: string): void => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\tdir\n\t\t? rc9.write(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.writeUser(validatedConfig, PRISMICRC);\n};\n\nexport const updatePrismicrc = (config: Prismicrc, dir?: string): Prismicrc => {\n\tconst { value: validatedConfig, error } = decode(Prismicrc, config);\n\n\tif (error) {\n\t\tthrow new Error(`Failed to validate config: ${error.errors.join(\", \")}`);\n\t}\n\n\treturn dir\n\t\t? rc9.update(validatedConfig, { dir, name: PRISMICRC })\n\t\t: rc9.updateUser(validatedConfig, PRISMICRC);\n};\n"],"names":[],"mappings":";;;;AAMA,MAAM,YAAY;AAElB,MAAM,YAAY,EAAE,QAAQ;AAAA,EAC3B,WAAW,EAAE;AACb,CAAA;AAGY,MAAA,mBAAmB,CAAC,QAA2B;AAC3D,QAAM,eAAe,MAClB,IAAI,KAAK,EAAE,KAAK,MAAM,UAAW,CAAA,IACjC,IAAI,SAAS,SAAS;AAEzB,QAAM,EAAE,OAAO,WAAW,MAAU,IAAA,OAAO,WAAW,YAAY;AAElE,MAAI,OAAO;AACV,UAAM,IAAI,MACT,mBACC,MAAM,KAAK,QAAQ,KAAK,SAAS,IAAI,KAAK,SAAS,EACpD,KAAK,MAAM,OAAO,KAAK,IAAI,CAAC,EAAE;AAAA,EAEhC;AAEO,SAAA;AACR;AAEa,MAAA,gBAAgB,CAAC,QAA0B;AACvD,QAAM,gBAAgB;AAChB,QAAA,mBAAmB,iBAAiB,GAAG;AAEtC,SAAA;AAAA,IACN,GAAG;AAAA,IACH,GAAG;AAAA,EAAA;AAEL;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SliceMachineManager.cjs","sources":["../../../src/managers/SliceMachineManager.ts"],"sourcesContent":["import {\n\tSharedSlice,\n\tCustomType,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport { SharedSliceContent } from \"@prismicio/types-internal/lib/content\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tSliceMachinePlugin,\n\tSliceMachinePluginRunner,\n} from \"@slicemachine/plugin-kit\";\n\nimport { createContentDigest } from \"../lib/createContentDigest\";\n\nimport { PackageManager, SliceMachineConfig } from \"../types\";\nimport {\n\tPrismicAuthManager,\n\tPrismicUserProfile,\n} from \"../auth/PrismicAuthManager\";\nimport { createPrismicAuthManager } from \"../auth/createPrismicAuthManager\";\n\nimport { API_ENDPOINTS, APIEndpoints } from \"../constants/API_ENDPOINTS\";\n\nimport { UserManager } from \"./user/UserManager\";\nimport { PrismicRepositoryManager } from \"./prismicRepository/PrismicRepositoryManager\";\n\nimport { PluginsManager } from \"./plugins/PluginsManager\";\n\nimport { ProjectManager } from \"./project/ProjectManager\";\nimport { CustomTypesManager } from \"./customTypes/CustomTypesManager\";\nimport { SlicesManager } from \"./slices/SlicesManager\";\nimport { SnippetsManager } from \"./snippets/SnippetsManager\";\nimport { ScreenshotsManager } from \"./screenshots/ScreenshotsManager\";\nimport { SimulatorManager } from \"./simulator/SimulatorManager\";\n\nimport { VersionsManager } from \"./versions/VersionsManager\";\n\nimport { TelemetryManager } from \"./telemetry/TelemetryManager\";\nimport { buildPrismicRepositoryAPIEndpoint } from \"../lib/buildPrismicRepositoryAPIEndpoint\";\nimport { DocumentationManager } from \"./documentation/DocumentationManager\";\nimport { SliceTemplateLibraryManager } from \"./sliceTemplateLibrary/SliceTemplateLibraryManager\";\nimport { GitManager } from \"./git/GitManager\";\n\ntype SliceMachineManagerGetStateReturnType = {\n\tenv: {\n\t\tshortId?: string;\n\t\tintercomHash?: string;\n\t\tmanifest: {\n\t\t\tapiEndpoint: string;\n\t\t\tlocalSliceSimulatorURL?: string;\n\t\t};\n\t\trepo: string;\n\t\tpackageManager: PackageManager;\n\t\tendpoints: APIEndpoints;\n\t};\n\tlibraries: {\n\t\tname: string;\n\t\tpath: string;\n\t\tisLocal: boolean;\n\t\tcomponents: {\n\t\t\tfrom: string;\n\t\t\thref: string;\n\t\t\tpathToSlice: string;\n\t\t\tfileName: string | null;\n\t\t\textension: string | null;\n\t\t\tmodel: SharedSlice;\n\t\t\tscreenshots: Record<\n\t\t\t\tstring,\n\t\t\t\t{\n\t\t\t\t\thash: string;\n\t\t\t\t\tdata: Buffer;\n\t\t\t\t}\n\t\t\t>;\n\t\t\tmocks?: SharedSliceContent[];\n\t\t}[];\n\t\tmeta: {\n\t\t\tname?: string;\n\t\t\tversion?: string;\n\t\t\tisNodeModule: boolean;\n\t\t\tisDownloaded: boolean;\n\t\t\tisManual: boolean;\n\t\t};\n\t}[];\n\tcustomTypes: CustomType[];\n\tremoteCustomTypes: CustomType[];\n\tremoteSlices: SharedSlice[];\n\tclientError?: {\n\t\tname: string;\n\t\tmessage: string;\n\t\tstatus: number;\n\t\treason: string;\n\t};\n};\n\ntype SliceMachineManagerConstructorArgs = {\n\tcwd?: string;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\nexport class SliceMachineManager {\n\tprivate _sliceMachinePluginRunner: SliceMachinePluginRunner | undefined =\n\t\tundefined;\n\tprivate _prismicAuthManager: PrismicAuthManager;\n\n\tcwd: string;\n\n\tcustomTypes: CustomTypesManager;\n\tplugins: PluginsManager;\n\tprismicRepository: PrismicRepositoryManager;\n\tproject: ProjectManager;\n\tscreenshots: ScreenshotsManager;\n\tsimulator: SimulatorManager;\n\tslices: SlicesManager;\n\tsnippets: SnippetsManager;\n\tdocumentation: DocumentationManager;\n\tsliceTemplateLibrary: SliceTemplateLibraryManager;\n\ttelemetry: TelemetryManager;\n\tuser: UserManager;\n\tversions: VersionsManager;\n\tgit: GitManager;\n\n\tconstructor(args?: SliceMachineManagerConstructorArgs) {\n\t\t// _prismicAuthManager must be set at least before UserManager\n\t\t// is instantiated. It depends on the PrismicAuthManager for\n\t\t// authentication-related methods.\n\t\tthis._prismicAuthManager = createPrismicAuthManager();\n\n\t\tthis.user = new UserManager(this);\n\t\tthis.prismicRepository = new PrismicRepositoryManager(this);\n\n\t\tthis.plugins = new PluginsManager(this, {\n\t\t\tnativePlugins: args?.nativePlugins,\n\t\t});\n\n\t\tthis.project = new ProjectManager(this);\n\t\tthis.customTypes = new CustomTypesManager(this);\n\t\tthis.slices = new SlicesManager(this);\n\t\tthis.snippets = new SnippetsManager(this);\n\t\tthis.screenshots = new ScreenshotsManager(this);\n\t\tthis.simulator = new SimulatorManager(this);\n\t\tthis.documentation = new DocumentationManager(this);\n\t\tthis.sliceTemplateLibrary = new SliceTemplateLibraryManager(this);\n\n\t\tthis.versions = new VersionsManager(this);\n\n\t\tthis.telemetry = new TelemetryManager(this);\n\n\t\tthis.git = new GitManager(this);\n\n\t\tthis.cwd = args?.cwd ?? process.cwd();\n\t}\n\n\t// The `_sliceMachinePluginRunner` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat SliceMachinePluginRunner\n\t// as a child manager.\n\tgetSliceMachinePluginRunner(): SliceMachinePluginRunner | undefined {\n\t\treturn this._sliceMachinePluginRunner;\n\t}\n\n\t// The `_prismicAuthManager` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat PrismicAuthManager as a\n\t// child manager.\n\tgetPrismicAuthManager(): PrismicAuthManager {\n\t\treturn this._prismicAuthManager;\n\t}\n\n\tgetAPIEndpoints(): APIEndpoints {\n\t\treturn API_ENDPOINTS;\n\t}\n\n\t// TODO: Remove this global-state method. It is expensive and a\n\t// potential source of bugs due to data inconsistency. SM UI relies on\n\t// it heavily, so removal will require significant effort.\n\tasync getState(): Promise<SliceMachineManagerGetStateReturnType> {\n\t\tconst [\n\t\t\t{ sliceMachineConfig, libraries },\n\t\t\t{ profile, remoteCustomTypes, remoteSlices, authError },\n\t\t\tcustomTypes,\n\t\t\tpackageManager,\n\t\t] = await Promise.all([\n\t\t\tthis.project.getSliceMachineConfig().then(async (sliceMachineConfig) => {\n\t\t\t\tconst libraries = await this._getLibraries(sliceMachineConfig);\n\n\t\t\t\treturn { sliceMachineConfig, libraries };\n\t\t\t}),\n\t\t\tthis._getProfile().then(async (profile) => {\n\t\t\t\tlet authError;\n\t\t\t\tif (profile) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst [remoteCustomTypes, remoteSlices] = await Promise.all([\n\t\t\t\t\t\t\tthis.customTypes.fetchRemoteCustomTypes(),\n\t\t\t\t\t\t\tthis.slices.fetchRemoteSlices(),\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tprofile,\n\t\t\t\t\t\t\tremoteCustomTypes,\n\t\t\t\t\t\t\tremoteSlices,\n\t\t\t\t\t\t\tauthError,\n\t\t\t\t\t\t};\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 401,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\terror instanceof prismicCustomTypesClient.UnauthorizedError\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 403,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tprofile,\n\t\t\t\t\tremoteCustomTypes: [],\n\t\t\t\t\tremoteSlices: [],\n\t\t\t\t\tauthError,\n\t\t\t\t};\n\t\t\t}),\n\t\t\tthis._getCustomTypes(),\n\t\t\tthis.project.detectPackageManager(),\n\t\t]);\n\n\t\t// SM UI detects if a user is logged out by looking at\n\t\t// `clientError`. Here, we simulate what the old core does by\n\t\t// returning an `ErrorWithStatus`-like object if the user does\n\t\t// not have access to the repository or is not logged in.\n\t\tconst clientError: SliceMachineManagerGetStateReturnType[\"clientError\"] =\n\t\t\tauthError ||\n\t\t\t(profile\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\tstatus: 401, // Needed to trigger the unauthorized flow.\n\t\t\t\t });\n\n\t\treturn {\n\t\t\tenv: {\n\t\t\t\tmanifest: {\n\t\t\t\t\tapiEndpoint:\n\t\t\t\t\t\tsliceMachineConfig.apiEndpoint ||\n\t\t\t\t\t\tbuildPrismicRepositoryAPIEndpoint(\n\t\t\t\t\t\t\tsliceMachineConfig.repositoryName,\n\t\t\t\t\t\t),\n\t\t\t\t\tlocalSliceSimulatorURL: sliceMachineConfig.localSliceSimulatorURL,\n\t\t\t\t},\n\t\t\t\tpackageManager,\n\t\t\t\trepo: sliceMachineConfig.repositoryName,\n\t\t\t\tintercomHash: profile?.intercomHash,\n\t\t\t\tshortId: profile?.shortId,\n\t\t\t\tendpoints: this.getAPIEndpoints(),\n\t\t\t},\n\t\t\tlibraries,\n\t\t\tcustomTypes,\n\t\t\tremoteCustomTypes,\n\t\t\tremoteSlices,\n\t\t\tclientError,\n\t\t};\n\t}\n\n\tprivate async _getProfile(): Promise<PrismicUserProfile | undefined> {\n\t\tlet profile: PrismicUserProfile | undefined;\n\n\t\tconst isLoggedIn = await this.user.checkIsLoggedIn();\n\n\t\tif (isLoggedIn) {\n\t\t\tprofile = await this.user.getProfile();\n\t\t\tawait this.user.refreshAuthenticationToken();\n\t\t}\n\n\t\treturn profile;\n\t}\n\n\tprivate async _getLibraries(\n\t\tsliceMachineConfig: SliceMachineConfig,\n\t): Promise<SliceMachineManagerGetStateReturnType[\"libraries\"]> {\n\t\tconst libraries: SliceMachineManagerGetStateReturnType[\"libraries\"] = [];\n\n\t\tif (sliceMachineConfig.libraries) {\n\t\t\tawait Promise.all(\n\t\t\t\tsliceMachineConfig.libraries.map(async (libraryID) => {\n\t\t\t\t\tconst { sliceIDs } = await this.slices.readSliceLibrary({\n\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (sliceIDs) {\n\t\t\t\t\t\tconst components: SliceMachineManagerGetStateReturnType[\"libraries\"][number][\"components\"] =\n\t\t\t\t\t\t\t[];\n\n\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\tsliceIDs.map(async (sliceID) => {\n\t\t\t\t\t\t\t\tconst [{ model }, { mocks }] = await Promise.all([\n\t\t\t\t\t\t\t\t\tthis.slices.readSlice({ libraryID, sliceID }),\n\t\t\t\t\t\t\t\t\tthis.slices.readSliceMocks({ libraryID, sliceID }),\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\tconst screenshots: (typeof components)[number][\"screenshots\"] =\n\t\t\t\t\t\t\t\t\t\t{};\n\t\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\t\tmodel.variations.map(async (variation) => {\n\t\t\t\t\t\t\t\t\t\t\tconst screenshot = await this.slices.readSliceScreenshot({\n\t\t\t\t\t\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t\t\t\t\t\t\tsliceID,\n\t\t\t\t\t\t\t\t\t\t\t\tvariationID: variation.id,\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tif (screenshot.data) {\n\t\t\t\t\t\t\t\t\t\t\t\tscreenshots[variation.id] = {\n\t\t\t\t\t\t\t\t\t\t\t\t\thash: createContentDigest(screenshot.data),\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: screenshot.data,\n\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\tcomponents.push({\n\t\t\t\t\t\t\t\t\t\tfrom: libraryID,\n\t\t\t\t\t\t\t\t\t\thref: libraryID.replace(/\\//g, \"--\"),\n\t\t\t\t\t\t\t\t\t\tpathToSlice: \"pathToSlice\",\n\t\t\t\t\t\t\t\t\t\tfileName: \"fileName\",\n\t\t\t\t\t\t\t\t\t\textension: \"extension\",\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t\tscreenshots,\n\t\t\t\t\t\t\t\t\t\tmocks,\n\t\t\t\t\t\t\t\t\t});\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\n\t\t\t\t\t\tlibraries.push({\n\t\t\t\t\t\t\tname: libraryID,\n\t\t\t\t\t\t\tpath: libraryID,\n\t\t\t\t\t\t\tisLocal: true, // TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\tcomponents,\n\t\t\t\t\t\t\tmeta: {\n\t\t\t\t\t\t\t\t// TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\t\tisNodeModule: false,\n\t\t\t\t\t\t\t\tisDownloaded: false,\n\t\t\t\t\t\t\t\tisManual: true,\n\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\t\t}\n\n\t\t// Preserve library order from config file\n\t\treturn libraries.sort((library1, library2) => {\n\t\t\tconst libraryIndex1 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library1.name) || 0;\n\t\t\tconst libraryIndex2 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library2.name) || 0;\n\n\t\t\treturn Math.sign(libraryIndex1 - libraryIndex2);\n\t\t});\n\t}\n\n\tprivate async _getCustomTypes(): Promise<\n\t\tSliceMachineManagerGetStateReturnType[\"customTypes\"]\n\t> {\n\t\tconst customTypes: SliceMachineManagerGetStateReturnType[\"customTypes\"] =\n\t\t\t[];\n\n\t\tconst { ids: customTypeIDs } =\n\t\t\tawait this.customTypes.readCustomTypeLibrary();\n\n\t\tif (customTypeIDs) {\n\t\t\tawait Promise.all(\n\t\t\t\tcustomTypeIDs.map(async (customTypeID) => {\n\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\tid: customTypeID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (model) {\n\t\t\t\t\t\tcustomTypes.push(model);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn customTypes;\n\t}\n}\n"],"names":["createPrismicAuthManager","UserManager","PrismicRepositoryManager","PluginsManager","ProjectManager","CustomTypesManager","SlicesManager","SnippetsManager","ScreenshotsManager","SimulatorManager","DocumentationManager","SliceTemplateLibraryManager","VersionsManager","TelemetryManager","GitManager","API_ENDPOINTS","sliceMachineConfig","libraries","profile","authError","remoteCustomTypes","remoteSlices","prismicCustomTypesClient","buildPrismicRepositoryAPIEndpoint","createContentDigest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AAAA,QACvB;AAAA,MACA,CAAA,CAAC;AAAA,IAEJ;AAEO,WAAA;AAAA,EACR;AACA;;"}
1
+ {"version":3,"file":"SliceMachineManager.cjs","sources":["../../../src/managers/SliceMachineManager.ts"],"sourcesContent":["import {\n\tSharedSlice,\n\tCustomType,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport { SharedSliceContent } from \"@prismicio/types-internal/lib/content\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tSliceMachinePlugin,\n\tSliceMachinePluginRunner,\n} from \"@slicemachine/plugin-kit\";\n\nimport { createContentDigest } from \"../lib/createContentDigest\";\n\nimport { PackageManager, SliceMachineConfig } from \"../types\";\nimport {\n\tPrismicAuthManager,\n\tPrismicUserProfile,\n} from \"../auth/PrismicAuthManager\";\nimport { createPrismicAuthManager } from \"../auth/createPrismicAuthManager\";\n\nimport { API_ENDPOINTS, APIEndpoints } from \"../constants/API_ENDPOINTS\";\n\nimport { UserManager } from \"./user/UserManager\";\nimport { PrismicRepositoryManager } from \"./prismicRepository/PrismicRepositoryManager\";\n\nimport { PluginsManager } from \"./plugins/PluginsManager\";\n\nimport { ProjectManager } from \"./project/ProjectManager\";\nimport { CustomTypesManager } from \"./customTypes/CustomTypesManager\";\nimport { SlicesManager } from \"./slices/SlicesManager\";\nimport { SnippetsManager } from \"./snippets/SnippetsManager\";\nimport { ScreenshotsManager } from \"./screenshots/ScreenshotsManager\";\nimport { SimulatorManager } from \"./simulator/SimulatorManager\";\n\nimport { VersionsManager } from \"./versions/VersionsManager\";\n\nimport { TelemetryManager } from \"./telemetry/TelemetryManager\";\nimport { buildPrismicRepositoryAPIEndpoint } from \"../lib/buildPrismicRepositoryAPIEndpoint\";\nimport { DocumentationManager } from \"./documentation/DocumentationManager\";\nimport { SliceTemplateLibraryManager } from \"./sliceTemplateLibrary/SliceTemplateLibraryManager\";\nimport { GitManager } from \"./git/GitManager\";\n\ntype SliceMachineManagerGetStateReturnType = {\n\tenv: {\n\t\tshortId?: string;\n\t\tintercomHash?: string;\n\t\tmanifest: {\n\t\t\tapiEndpoint: string;\n\t\t\tlocalSliceSimulatorURL?: string;\n\t\t};\n\t\trepo: string;\n\t\tpackageManager: PackageManager;\n\t\tendpoints: APIEndpoints;\n\t};\n\tlibraries: {\n\t\tname: string;\n\t\tpath: string;\n\t\tisLocal: boolean;\n\t\tcomponents: {\n\t\t\tfrom: string;\n\t\t\thref: string;\n\t\t\tpathToSlice: string;\n\t\t\tfileName: string | null;\n\t\t\textension: string | null;\n\t\t\tmodel: SharedSlice;\n\t\t\tscreenshots: Record<\n\t\t\t\tstring,\n\t\t\t\t{\n\t\t\t\t\thash: string;\n\t\t\t\t\tdata: Buffer;\n\t\t\t\t}\n\t\t\t>;\n\t\t\tmocks?: SharedSliceContent[];\n\t\t}[];\n\t\tmeta: {\n\t\t\tname?: string;\n\t\t\tversion?: string;\n\t\t\tisNodeModule: boolean;\n\t\t\tisDownloaded: boolean;\n\t\t\tisManual: boolean;\n\t\t};\n\t}[];\n\tcustomTypes: CustomType[];\n\tremoteCustomTypes: CustomType[];\n\tremoteSlices: SharedSlice[];\n\tclientError?: {\n\t\tname: string;\n\t\tmessage: string;\n\t\tstatus: number;\n\t\treason: string;\n\t};\n};\n\ntype SliceMachineManagerConstructorArgs = {\n\tcwd?: string;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\nexport class SliceMachineManager {\n\tprivate _sliceMachinePluginRunner: SliceMachinePluginRunner | undefined =\n\t\tundefined;\n\tprivate _prismicAuthManager: PrismicAuthManager;\n\n\tcwd: string;\n\n\tcustomTypes: CustomTypesManager;\n\tplugins: PluginsManager;\n\tprismicRepository: PrismicRepositoryManager;\n\tproject: ProjectManager;\n\tscreenshots: ScreenshotsManager;\n\tsimulator: SimulatorManager;\n\tslices: SlicesManager;\n\tsnippets: SnippetsManager;\n\tdocumentation: DocumentationManager;\n\tsliceTemplateLibrary: SliceTemplateLibraryManager;\n\ttelemetry: TelemetryManager;\n\tuser: UserManager;\n\tversions: VersionsManager;\n\tgit: GitManager;\n\n\tconstructor(args?: SliceMachineManagerConstructorArgs) {\n\t\t// _prismicAuthManager must be set at least before UserManager\n\t\t// is instantiated. It depends on the PrismicAuthManager for\n\t\t// authentication-related methods.\n\t\tthis._prismicAuthManager = createPrismicAuthManager();\n\n\t\tthis.user = new UserManager(this);\n\t\tthis.prismicRepository = new PrismicRepositoryManager(this);\n\n\t\tthis.plugins = new PluginsManager(this, {\n\t\t\tnativePlugins: args?.nativePlugins,\n\t\t});\n\n\t\tthis.project = new ProjectManager(this);\n\t\tthis.customTypes = new CustomTypesManager(this);\n\t\tthis.slices = new SlicesManager(this);\n\t\tthis.snippets = new SnippetsManager(this);\n\t\tthis.screenshots = new ScreenshotsManager(this);\n\t\tthis.simulator = new SimulatorManager(this);\n\t\tthis.documentation = new DocumentationManager(this);\n\t\tthis.sliceTemplateLibrary = new SliceTemplateLibraryManager(this);\n\n\t\tthis.versions = new VersionsManager(this);\n\n\t\tthis.telemetry = new TelemetryManager(this);\n\n\t\tthis.git = new GitManager(this);\n\n\t\tthis.cwd = args?.cwd ?? process.cwd();\n\t}\n\n\t// The `_sliceMachinePluginRunner` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat SliceMachinePluginRunner\n\t// as a child manager.\n\tgetSliceMachinePluginRunner(): SliceMachinePluginRunner | undefined {\n\t\treturn this._sliceMachinePluginRunner;\n\t}\n\n\t// The `_prismicAuthManager` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat PrismicAuthManager as a\n\t// child manager.\n\tgetPrismicAuthManager(): PrismicAuthManager {\n\t\treturn this._prismicAuthManager;\n\t}\n\n\tgetAPIEndpoints(): APIEndpoints {\n\t\treturn API_ENDPOINTS;\n\t}\n\n\t// TODO: Remove this global-state method. It is expensive and a\n\t// potential source of bugs due to data inconsistency. SM UI relies on\n\t// it heavily, so removal will require significant effort.\n\tasync getState(): Promise<SliceMachineManagerGetStateReturnType> {\n\t\tconst [\n\t\t\t{ sliceMachineConfig, libraries },\n\t\t\t{ profile, remoteCustomTypes, remoteSlices, authError },\n\t\t\tcustomTypes,\n\t\t\tpackageManager,\n\t\t] = await Promise.all([\n\t\t\tthis.project.getSliceMachineConfig().then(async (sliceMachineConfig) => {\n\t\t\t\tconst libraries = await this._getLibraries(sliceMachineConfig);\n\n\t\t\t\treturn { sliceMachineConfig, libraries };\n\t\t\t}),\n\t\t\tthis._getProfile().then(async (profile) => {\n\t\t\t\tlet authError;\n\t\t\t\tif (profile) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst [remoteCustomTypes, remoteSlices] = await Promise.all([\n\t\t\t\t\t\t\tthis.customTypes.fetchRemoteCustomTypes(),\n\t\t\t\t\t\t\tthis.slices.fetchRemoteSlices(),\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tprofile,\n\t\t\t\t\t\t\tremoteCustomTypes,\n\t\t\t\t\t\t\tremoteSlices,\n\t\t\t\t\t\t\tauthError,\n\t\t\t\t\t\t};\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 401,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\terror instanceof prismicCustomTypesClient.UnauthorizedError\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 403,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tprofile,\n\t\t\t\t\tremoteCustomTypes: [],\n\t\t\t\t\tremoteSlices: [],\n\t\t\t\t\tauthError,\n\t\t\t\t};\n\t\t\t}),\n\t\t\tthis._getCustomTypes(),\n\t\t\tthis.project.detectPackageManager(),\n\t\t]);\n\n\t\t// SM UI detects if a user is logged out by looking at\n\t\t// `clientError`. Here, we simulate what the old core does by\n\t\t// returning an `ErrorWithStatus`-like object if the user does\n\t\t// not have access to the repository or is not logged in.\n\t\tconst clientError: SliceMachineManagerGetStateReturnType[\"clientError\"] =\n\t\t\tauthError ||\n\t\t\t(profile\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\tstatus: 401, // Needed to trigger the unauthorized flow.\n\t\t\t\t });\n\n\t\treturn {\n\t\t\tenv: {\n\t\t\t\tmanifest: {\n\t\t\t\t\tapiEndpoint:\n\t\t\t\t\t\tsliceMachineConfig.apiEndpoint ||\n\t\t\t\t\t\tbuildPrismicRepositoryAPIEndpoint(\n\t\t\t\t\t\t\tsliceMachineConfig.repositoryName,\n\t\t\t\t\t\t),\n\t\t\t\t\tlocalSliceSimulatorURL: sliceMachineConfig.localSliceSimulatorURL,\n\t\t\t\t},\n\t\t\t\tpackageManager,\n\t\t\t\trepo: sliceMachineConfig.repositoryName,\n\t\t\t\tintercomHash: profile?.intercomHash,\n\t\t\t\tshortId: profile?.shortId,\n\t\t\t\tendpoints: this.getAPIEndpoints(),\n\t\t\t},\n\t\t\tlibraries,\n\t\t\tcustomTypes,\n\t\t\tremoteCustomTypes,\n\t\t\tremoteSlices,\n\t\t\tclientError,\n\t\t};\n\t}\n\n\tprivate async _getProfile(): Promise<PrismicUserProfile | undefined> {\n\t\tlet profile: PrismicUserProfile | undefined;\n\n\t\tconst isLoggedIn = await this.user.checkIsLoggedIn();\n\n\t\tif (isLoggedIn) {\n\t\t\tprofile = await this.user.getProfile();\n\t\t\tawait this.user.refreshAuthenticationToken();\n\t\t}\n\n\t\treturn profile;\n\t}\n\n\tprivate async _getLibraries(\n\t\tsliceMachineConfig: SliceMachineConfig,\n\t): Promise<SliceMachineManagerGetStateReturnType[\"libraries\"]> {\n\t\tconst libraries: SliceMachineManagerGetStateReturnType[\"libraries\"] = [];\n\n\t\tif (sliceMachineConfig.libraries) {\n\t\t\tawait Promise.all(\n\t\t\t\tsliceMachineConfig.libraries.map(async (libraryID) => {\n\t\t\t\t\tconst { sliceIDs } = await this.slices.readSliceLibrary({\n\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (sliceIDs) {\n\t\t\t\t\t\tconst components: SliceMachineManagerGetStateReturnType[\"libraries\"][number][\"components\"] =\n\t\t\t\t\t\t\t[];\n\n\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\tsliceIDs.map(async (sliceID) => {\n\t\t\t\t\t\t\t\tconst [{ model }, { mocks }] = await Promise.all([\n\t\t\t\t\t\t\t\t\tthis.slices.readSlice({ libraryID, sliceID }),\n\t\t\t\t\t\t\t\t\tthis.slices.readSliceMocks({ libraryID, sliceID }),\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\tconst screenshots: (typeof components)[number][\"screenshots\"] =\n\t\t\t\t\t\t\t\t\t\t{};\n\t\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\t\tmodel.variations.map(async (variation) => {\n\t\t\t\t\t\t\t\t\t\t\tconst screenshot = await this.slices.readSliceScreenshot({\n\t\t\t\t\t\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t\t\t\t\t\t\tsliceID,\n\t\t\t\t\t\t\t\t\t\t\t\tvariationID: variation.id,\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tif (screenshot.data) {\n\t\t\t\t\t\t\t\t\t\t\t\tscreenshots[variation.id] = {\n\t\t\t\t\t\t\t\t\t\t\t\t\thash: createContentDigest(screenshot.data),\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: screenshot.data,\n\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\tcomponents.push({\n\t\t\t\t\t\t\t\t\t\tfrom: libraryID,\n\t\t\t\t\t\t\t\t\t\thref: libraryID.replace(/\\//g, \"--\"),\n\t\t\t\t\t\t\t\t\t\tpathToSlice: \"pathToSlice\",\n\t\t\t\t\t\t\t\t\t\tfileName: \"fileName\",\n\t\t\t\t\t\t\t\t\t\textension: \"extension\",\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t\tscreenshots,\n\t\t\t\t\t\t\t\t\t\tmocks,\n\t\t\t\t\t\t\t\t\t});\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\n\t\t\t\t\t\tlibraries.push({\n\t\t\t\t\t\t\tname: libraryID,\n\t\t\t\t\t\t\tpath: libraryID,\n\t\t\t\t\t\t\tisLocal: true, // TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\tcomponents,\n\t\t\t\t\t\t\tmeta: {\n\t\t\t\t\t\t\t\t// TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\t\tisNodeModule: false,\n\t\t\t\t\t\t\t\tisDownloaded: false,\n\t\t\t\t\t\t\t\tisManual: true,\n\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\t\t}\n\n\t\t// Preserve library order from config file\n\t\treturn libraries.sort((library1, library2) => {\n\t\t\tconst libraryIndex1 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library1.name) || 0;\n\t\t\tconst libraryIndex2 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library2.name) || 0;\n\n\t\t\treturn Math.sign(libraryIndex1 - libraryIndex2);\n\t\t});\n\t}\n\n\tprivate async _getCustomTypes(): Promise<\n\t\tSliceMachineManagerGetStateReturnType[\"customTypes\"]\n\t> {\n\t\tconst customTypes: SliceMachineManagerGetStateReturnType[\"customTypes\"] =\n\t\t\t[];\n\n\t\tconst { ids: customTypeIDs } =\n\t\t\tawait this.customTypes.readCustomTypeLibrary();\n\n\t\tif (customTypeIDs) {\n\t\t\tawait Promise.all(\n\t\t\t\tcustomTypeIDs.map(async (customTypeID) => {\n\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\tid: customTypeID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (model) {\n\t\t\t\t\t\tcustomTypes.push(model);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn customTypes;\n\t}\n}\n"],"names":["createPrismicAuthManager","UserManager","PrismicRepositoryManager","PluginsManager","ProjectManager","CustomTypesManager","SlicesManager","SnippetsManager","ScreenshotsManager","SimulatorManager","DocumentationManager","SliceTemplateLibraryManager","VersionsManager","TelemetryManager","GitManager","API_ENDPOINTS","sliceMachineConfig","libraries","profile","authError","remoteCustomTypes","remoteSlices","prismicCustomTypesClient","buildPrismicRepositoryAPIEndpoint","createContentDigest"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkGa,oBAAmB;AAAA,EAsB/B,YAAY,MAAyC;AArB7C;AAEA;AAER;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMC,SAAK,sBA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AAAA,gBAEnB;AAAA,cACA,CAAA,CAAC;AAGH,yBAAW,KAAK;AAAA,gBACf,MAAM;AAAA,gBACN,MAAM,UAAU,QAAQ,OAAO,IAAI;AAAA,gBACnC,aAAa;AAAA,gBACb,UAAU;AAAA,gBACV,WAAW;AAAA,gBACX;AAAA,gBACA;AAAA,gBACA;AAAA,cAAA,CACA;AAAA,YACF;AAAA,UACA,CAAA,CAAC;AAGH,oBAAU,KAAK;AAAA,YACd,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS;AAAA;AAAA,YACT;AAAA,YACA,MAAM;AAAA;AAAA,cAEL,cAAc;AAAA,cACd,cAAc;AAAA,cACd,UAAU;AAAA,YACV;AAAA,UAAA,CACD;AAAA,QACF;AAAA,MACA,CAAA,CAAC;AAAA,IAEJ;AAGA,WAAO,UAAU,KAAK,CAAC,UAAU,aAAY;;AAC5C,YAAM,kBACL,wBAAmB,cAAnB,mBAA8B,QAAQ,SAAS,UAAS;AACzD,YAAM,kBACL,wBAAmB,cAAnB,mBAA8B,QAAQ,SAAS,UAAS;AAElD,aAAA,KAAK,KAAK,gBAAgB,aAAa;AAAA,IAAA,CAC9C;AAAA,EACF;AAAA,EAEQ,MAAM,kBAAe;AAG5B,UAAM,cACL,CAAA;AAED,UAAM,EAAE,KAAK,kBACZ,MAAM,KAAK,YAAY;AAExB,QAAI,eAAe;AAClB,YAAM,QAAQ,IACb,cAAc,IAAI,OAAO,iBAAgB;AACxC,cAAM,EAAE,MAAK,IAAK,MAAM,KAAK,YAAY,eAAe;AAAA,UACvD,IAAI;AAAA,QAAA,CACJ;AAED,YAAI,OAAO;AACV,sBAAY,KAAK,KAAK;AAAA,QACvB;AAAA,MACA,CAAA,CAAC;AAAA,IAEJ;AAEO,WAAA;AAAA,EACR;AACA;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SliceMachineManager.js","sources":["../../../src/managers/SliceMachineManager.ts"],"sourcesContent":["import {\n\tSharedSlice,\n\tCustomType,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport { SharedSliceContent } from \"@prismicio/types-internal/lib/content\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tSliceMachinePlugin,\n\tSliceMachinePluginRunner,\n} from \"@slicemachine/plugin-kit\";\n\nimport { createContentDigest } from \"../lib/createContentDigest\";\n\nimport { PackageManager, SliceMachineConfig } from \"../types\";\nimport {\n\tPrismicAuthManager,\n\tPrismicUserProfile,\n} from \"../auth/PrismicAuthManager\";\nimport { createPrismicAuthManager } from \"../auth/createPrismicAuthManager\";\n\nimport { API_ENDPOINTS, APIEndpoints } from \"../constants/API_ENDPOINTS\";\n\nimport { UserManager } from \"./user/UserManager\";\nimport { PrismicRepositoryManager } from \"./prismicRepository/PrismicRepositoryManager\";\n\nimport { PluginsManager } from \"./plugins/PluginsManager\";\n\nimport { ProjectManager } from \"./project/ProjectManager\";\nimport { CustomTypesManager } from \"./customTypes/CustomTypesManager\";\nimport { SlicesManager } from \"./slices/SlicesManager\";\nimport { SnippetsManager } from \"./snippets/SnippetsManager\";\nimport { ScreenshotsManager } from \"./screenshots/ScreenshotsManager\";\nimport { SimulatorManager } from \"./simulator/SimulatorManager\";\n\nimport { VersionsManager } from \"./versions/VersionsManager\";\n\nimport { TelemetryManager } from \"./telemetry/TelemetryManager\";\nimport { buildPrismicRepositoryAPIEndpoint } from \"../lib/buildPrismicRepositoryAPIEndpoint\";\nimport { DocumentationManager } from \"./documentation/DocumentationManager\";\nimport { SliceTemplateLibraryManager } from \"./sliceTemplateLibrary/SliceTemplateLibraryManager\";\nimport { GitManager } from \"./git/GitManager\";\n\ntype SliceMachineManagerGetStateReturnType = {\n\tenv: {\n\t\tshortId?: string;\n\t\tintercomHash?: string;\n\t\tmanifest: {\n\t\t\tapiEndpoint: string;\n\t\t\tlocalSliceSimulatorURL?: string;\n\t\t};\n\t\trepo: string;\n\t\tpackageManager: PackageManager;\n\t\tendpoints: APIEndpoints;\n\t};\n\tlibraries: {\n\t\tname: string;\n\t\tpath: string;\n\t\tisLocal: boolean;\n\t\tcomponents: {\n\t\t\tfrom: string;\n\t\t\thref: string;\n\t\t\tpathToSlice: string;\n\t\t\tfileName: string | null;\n\t\t\textension: string | null;\n\t\t\tmodel: SharedSlice;\n\t\t\tscreenshots: Record<\n\t\t\t\tstring,\n\t\t\t\t{\n\t\t\t\t\thash: string;\n\t\t\t\t\tdata: Buffer;\n\t\t\t\t}\n\t\t\t>;\n\t\t\tmocks?: SharedSliceContent[];\n\t\t}[];\n\t\tmeta: {\n\t\t\tname?: string;\n\t\t\tversion?: string;\n\t\t\tisNodeModule: boolean;\n\t\t\tisDownloaded: boolean;\n\t\t\tisManual: boolean;\n\t\t};\n\t}[];\n\tcustomTypes: CustomType[];\n\tremoteCustomTypes: CustomType[];\n\tremoteSlices: SharedSlice[];\n\tclientError?: {\n\t\tname: string;\n\t\tmessage: string;\n\t\tstatus: number;\n\t\treason: string;\n\t};\n};\n\ntype SliceMachineManagerConstructorArgs = {\n\tcwd?: string;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\nexport class SliceMachineManager {\n\tprivate _sliceMachinePluginRunner: SliceMachinePluginRunner | undefined =\n\t\tundefined;\n\tprivate _prismicAuthManager: PrismicAuthManager;\n\n\tcwd: string;\n\n\tcustomTypes: CustomTypesManager;\n\tplugins: PluginsManager;\n\tprismicRepository: PrismicRepositoryManager;\n\tproject: ProjectManager;\n\tscreenshots: ScreenshotsManager;\n\tsimulator: SimulatorManager;\n\tslices: SlicesManager;\n\tsnippets: SnippetsManager;\n\tdocumentation: DocumentationManager;\n\tsliceTemplateLibrary: SliceTemplateLibraryManager;\n\ttelemetry: TelemetryManager;\n\tuser: UserManager;\n\tversions: VersionsManager;\n\tgit: GitManager;\n\n\tconstructor(args?: SliceMachineManagerConstructorArgs) {\n\t\t// _prismicAuthManager must be set at least before UserManager\n\t\t// is instantiated. It depends on the PrismicAuthManager for\n\t\t// authentication-related methods.\n\t\tthis._prismicAuthManager = createPrismicAuthManager();\n\n\t\tthis.user = new UserManager(this);\n\t\tthis.prismicRepository = new PrismicRepositoryManager(this);\n\n\t\tthis.plugins = new PluginsManager(this, {\n\t\t\tnativePlugins: args?.nativePlugins,\n\t\t});\n\n\t\tthis.project = new ProjectManager(this);\n\t\tthis.customTypes = new CustomTypesManager(this);\n\t\tthis.slices = new SlicesManager(this);\n\t\tthis.snippets = new SnippetsManager(this);\n\t\tthis.screenshots = new ScreenshotsManager(this);\n\t\tthis.simulator = new SimulatorManager(this);\n\t\tthis.documentation = new DocumentationManager(this);\n\t\tthis.sliceTemplateLibrary = new SliceTemplateLibraryManager(this);\n\n\t\tthis.versions = new VersionsManager(this);\n\n\t\tthis.telemetry = new TelemetryManager(this);\n\n\t\tthis.git = new GitManager(this);\n\n\t\tthis.cwd = args?.cwd ?? process.cwd();\n\t}\n\n\t// The `_sliceMachinePluginRunner` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat SliceMachinePluginRunner\n\t// as a child manager.\n\tgetSliceMachinePluginRunner(): SliceMachinePluginRunner | undefined {\n\t\treturn this._sliceMachinePluginRunner;\n\t}\n\n\t// The `_prismicAuthManager` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat PrismicAuthManager as a\n\t// child manager.\n\tgetPrismicAuthManager(): PrismicAuthManager {\n\t\treturn this._prismicAuthManager;\n\t}\n\n\tgetAPIEndpoints(): APIEndpoints {\n\t\treturn API_ENDPOINTS;\n\t}\n\n\t// TODO: Remove this global-state method. It is expensive and a\n\t// potential source of bugs due to data inconsistency. SM UI relies on\n\t// it heavily, so removal will require significant effort.\n\tasync getState(): Promise<SliceMachineManagerGetStateReturnType> {\n\t\tconst [\n\t\t\t{ sliceMachineConfig, libraries },\n\t\t\t{ profile, remoteCustomTypes, remoteSlices, authError },\n\t\t\tcustomTypes,\n\t\t\tpackageManager,\n\t\t] = await Promise.all([\n\t\t\tthis.project.getSliceMachineConfig().then(async (sliceMachineConfig) => {\n\t\t\t\tconst libraries = await this._getLibraries(sliceMachineConfig);\n\n\t\t\t\treturn { sliceMachineConfig, libraries };\n\t\t\t}),\n\t\t\tthis._getProfile().then(async (profile) => {\n\t\t\t\tlet authError;\n\t\t\t\tif (profile) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst [remoteCustomTypes, remoteSlices] = await Promise.all([\n\t\t\t\t\t\t\tthis.customTypes.fetchRemoteCustomTypes(),\n\t\t\t\t\t\t\tthis.slices.fetchRemoteSlices(),\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tprofile,\n\t\t\t\t\t\t\tremoteCustomTypes,\n\t\t\t\t\t\t\tremoteSlices,\n\t\t\t\t\t\t\tauthError,\n\t\t\t\t\t\t};\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 401,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\terror instanceof prismicCustomTypesClient.UnauthorizedError\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 403,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tprofile,\n\t\t\t\t\tremoteCustomTypes: [],\n\t\t\t\t\tremoteSlices: [],\n\t\t\t\t\tauthError,\n\t\t\t\t};\n\t\t\t}),\n\t\t\tthis._getCustomTypes(),\n\t\t\tthis.project.detectPackageManager(),\n\t\t]);\n\n\t\t// SM UI detects if a user is logged out by looking at\n\t\t// `clientError`. Here, we simulate what the old core does by\n\t\t// returning an `ErrorWithStatus`-like object if the user does\n\t\t// not have access to the repository or is not logged in.\n\t\tconst clientError: SliceMachineManagerGetStateReturnType[\"clientError\"] =\n\t\t\tauthError ||\n\t\t\t(profile\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\tstatus: 401, // Needed to trigger the unauthorized flow.\n\t\t\t\t });\n\n\t\treturn {\n\t\t\tenv: {\n\t\t\t\tmanifest: {\n\t\t\t\t\tapiEndpoint:\n\t\t\t\t\t\tsliceMachineConfig.apiEndpoint ||\n\t\t\t\t\t\tbuildPrismicRepositoryAPIEndpoint(\n\t\t\t\t\t\t\tsliceMachineConfig.repositoryName,\n\t\t\t\t\t\t),\n\t\t\t\t\tlocalSliceSimulatorURL: sliceMachineConfig.localSliceSimulatorURL,\n\t\t\t\t},\n\t\t\t\tpackageManager,\n\t\t\t\trepo: sliceMachineConfig.repositoryName,\n\t\t\t\tintercomHash: profile?.intercomHash,\n\t\t\t\tshortId: profile?.shortId,\n\t\t\t\tendpoints: this.getAPIEndpoints(),\n\t\t\t},\n\t\t\tlibraries,\n\t\t\tcustomTypes,\n\t\t\tremoteCustomTypes,\n\t\t\tremoteSlices,\n\t\t\tclientError,\n\t\t};\n\t}\n\n\tprivate async _getProfile(): Promise<PrismicUserProfile | undefined> {\n\t\tlet profile: PrismicUserProfile | undefined;\n\n\t\tconst isLoggedIn = await this.user.checkIsLoggedIn();\n\n\t\tif (isLoggedIn) {\n\t\t\tprofile = await this.user.getProfile();\n\t\t\tawait this.user.refreshAuthenticationToken();\n\t\t}\n\n\t\treturn profile;\n\t}\n\n\tprivate async _getLibraries(\n\t\tsliceMachineConfig: SliceMachineConfig,\n\t): Promise<SliceMachineManagerGetStateReturnType[\"libraries\"]> {\n\t\tconst libraries: SliceMachineManagerGetStateReturnType[\"libraries\"] = [];\n\n\t\tif (sliceMachineConfig.libraries) {\n\t\t\tawait Promise.all(\n\t\t\t\tsliceMachineConfig.libraries.map(async (libraryID) => {\n\t\t\t\t\tconst { sliceIDs } = await this.slices.readSliceLibrary({\n\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (sliceIDs) {\n\t\t\t\t\t\tconst components: SliceMachineManagerGetStateReturnType[\"libraries\"][number][\"components\"] =\n\t\t\t\t\t\t\t[];\n\n\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\tsliceIDs.map(async (sliceID) => {\n\t\t\t\t\t\t\t\tconst [{ model }, { mocks }] = await Promise.all([\n\t\t\t\t\t\t\t\t\tthis.slices.readSlice({ libraryID, sliceID }),\n\t\t\t\t\t\t\t\t\tthis.slices.readSliceMocks({ libraryID, sliceID }),\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\tconst screenshots: (typeof components)[number][\"screenshots\"] =\n\t\t\t\t\t\t\t\t\t\t{};\n\t\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\t\tmodel.variations.map(async (variation) => {\n\t\t\t\t\t\t\t\t\t\t\tconst screenshot = await this.slices.readSliceScreenshot({\n\t\t\t\t\t\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t\t\t\t\t\t\tsliceID,\n\t\t\t\t\t\t\t\t\t\t\t\tvariationID: variation.id,\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tif (screenshot.data) {\n\t\t\t\t\t\t\t\t\t\t\t\tscreenshots[variation.id] = {\n\t\t\t\t\t\t\t\t\t\t\t\t\thash: createContentDigest(screenshot.data),\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: screenshot.data,\n\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\tcomponents.push({\n\t\t\t\t\t\t\t\t\t\tfrom: libraryID,\n\t\t\t\t\t\t\t\t\t\thref: libraryID.replace(/\\//g, \"--\"),\n\t\t\t\t\t\t\t\t\t\tpathToSlice: \"pathToSlice\",\n\t\t\t\t\t\t\t\t\t\tfileName: \"fileName\",\n\t\t\t\t\t\t\t\t\t\textension: \"extension\",\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t\tscreenshots,\n\t\t\t\t\t\t\t\t\t\tmocks,\n\t\t\t\t\t\t\t\t\t});\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\n\t\t\t\t\t\tlibraries.push({\n\t\t\t\t\t\t\tname: libraryID,\n\t\t\t\t\t\t\tpath: libraryID,\n\t\t\t\t\t\t\tisLocal: true, // TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\tcomponents,\n\t\t\t\t\t\t\tmeta: {\n\t\t\t\t\t\t\t\t// TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\t\tisNodeModule: false,\n\t\t\t\t\t\t\t\tisDownloaded: false,\n\t\t\t\t\t\t\t\tisManual: true,\n\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\t\t}\n\n\t\t// Preserve library order from config file\n\t\treturn libraries.sort((library1, library2) => {\n\t\t\tconst libraryIndex1 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library1.name) || 0;\n\t\t\tconst libraryIndex2 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library2.name) || 0;\n\n\t\t\treturn Math.sign(libraryIndex1 - libraryIndex2);\n\t\t});\n\t}\n\n\tprivate async _getCustomTypes(): Promise<\n\t\tSliceMachineManagerGetStateReturnType[\"customTypes\"]\n\t> {\n\t\tconst customTypes: SliceMachineManagerGetStateReturnType[\"customTypes\"] =\n\t\t\t[];\n\n\t\tconst { ids: customTypeIDs } =\n\t\t\tawait this.customTypes.readCustomTypeLibrary();\n\n\t\tif (customTypeIDs) {\n\t\t\tawait Promise.all(\n\t\t\t\tcustomTypeIDs.map(async (customTypeID) => {\n\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\tid: customTypeID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (model) {\n\t\t\t\t\t\tcustomTypes.push(model);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn customTypes;\n\t}\n}\n"],"names":["sliceMachineConfig","libraries","profile","authError","remoteCustomTypes","remoteSlices"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;MAkGa,oBAAmB;AAAA,EAsB/B,YAAY,MAAyC;AArB7C;AAEA;AAER;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMC,SAAK,sBAAsB;AAEtB,SAAA,OAAO,IAAI,YAAY,IAAI;AAC3B,SAAA,oBAAoB,IAAI,yBAAyB,IAAI;AAErD,SAAA,UAAU,IAAI,eAAe,MAAM;AAAA,MACvC,eAAe,6BAAM;AAAA,IAAA,CACrB;AAEI,SAAA,UAAU,IAAI,eAAe,IAAI;AACjC,SAAA,cAAc,IAAI,mBAAmB,IAAI;AACzC,SAAA,SAAS,IAAI,cAAc,IAAI;AAC/B,SAAA,WAAW,IAAI,gBAAgB,IAAI;AACnC,SAAA,cAAc,IAAI,mBAAmB,IAAI;AACzC,SAAA,YAAY,IAAI,iBAAiB,IAAI;AACrC,SAAA,gBAAgB,IAAI,qBAAqB,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AnB,mBAA8B,QAAQ,SAAS,UAAS;AACzD,YAAM,kBACL,wBAAmB,cAAnB,mBAA8B,QAAQ,SAAS,UAAS;AAElD,aAAA,KAAK,KAAK,gBAAgB,aAAa;AAAA,IAAA,CAC9C;AAAA,EACF;AAAA,EAEQ,MAAM,kBAAe;AAG5B,UAAM,cACL,CAAA;AAED,UAAM,EAAE,KAAK,kBACZ,MAAM,KAAK,YAAY;AAExB,QAAI,eAAe;AAClB,YAAM,QAAQ,IACb,cAAc,IAAI,OAAO,iBAAgB;AACxC,cAAM,EAAE,MAAK,IAAK,MAAM,KAAK,YAAY,eAAe;AAAA,UACvD,IAAI;AAAA,QAAA,CACJ;AAED,YAAI,OAAO;AACV,sBAAY,KAAK,KAAK;AAAA,QACvB;AAAA,MACA,CAAA,CAAC;AAAA,IAEJ;AAEO,WAAA;AAAA,EACR;AACA;"}
1
+ {"version":3,"file":"SliceMachineManager.js","sources":["../../../src/managers/SliceMachineManager.ts"],"sourcesContent":["import {\n\tSharedSlice,\n\tCustomType,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport { SharedSliceContent } from \"@prismicio/types-internal/lib/content\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tSliceMachinePlugin,\n\tSliceMachinePluginRunner,\n} from \"@slicemachine/plugin-kit\";\n\nimport { createContentDigest } from \"../lib/createContentDigest\";\n\nimport { PackageManager, SliceMachineConfig } from \"../types\";\nimport {\n\tPrismicAuthManager,\n\tPrismicUserProfile,\n} from \"../auth/PrismicAuthManager\";\nimport { createPrismicAuthManager } from \"../auth/createPrismicAuthManager\";\n\nimport { API_ENDPOINTS, APIEndpoints } from \"../constants/API_ENDPOINTS\";\n\nimport { UserManager } from \"./user/UserManager\";\nimport { PrismicRepositoryManager } from \"./prismicRepository/PrismicRepositoryManager\";\n\nimport { PluginsManager } from \"./plugins/PluginsManager\";\n\nimport { ProjectManager } from \"./project/ProjectManager\";\nimport { CustomTypesManager } from \"./customTypes/CustomTypesManager\";\nimport { SlicesManager } from \"./slices/SlicesManager\";\nimport { SnippetsManager } from \"./snippets/SnippetsManager\";\nimport { ScreenshotsManager } from \"./screenshots/ScreenshotsManager\";\nimport { SimulatorManager } from \"./simulator/SimulatorManager\";\n\nimport { VersionsManager } from \"./versions/VersionsManager\";\n\nimport { TelemetryManager } from \"./telemetry/TelemetryManager\";\nimport { buildPrismicRepositoryAPIEndpoint } from \"../lib/buildPrismicRepositoryAPIEndpoint\";\nimport { DocumentationManager } from \"./documentation/DocumentationManager\";\nimport { SliceTemplateLibraryManager } from \"./sliceTemplateLibrary/SliceTemplateLibraryManager\";\nimport { GitManager } from \"./git/GitManager\";\n\ntype SliceMachineManagerGetStateReturnType = {\n\tenv: {\n\t\tshortId?: string;\n\t\tintercomHash?: string;\n\t\tmanifest: {\n\t\t\tapiEndpoint: string;\n\t\t\tlocalSliceSimulatorURL?: string;\n\t\t};\n\t\trepo: string;\n\t\tpackageManager: PackageManager;\n\t\tendpoints: APIEndpoints;\n\t};\n\tlibraries: {\n\t\tname: string;\n\t\tpath: string;\n\t\tisLocal: boolean;\n\t\tcomponents: {\n\t\t\tfrom: string;\n\t\t\thref: string;\n\t\t\tpathToSlice: string;\n\t\t\tfileName: string | null;\n\t\t\textension: string | null;\n\t\t\tmodel: SharedSlice;\n\t\t\tscreenshots: Record<\n\t\t\t\tstring,\n\t\t\t\t{\n\t\t\t\t\thash: string;\n\t\t\t\t\tdata: Buffer;\n\t\t\t\t}\n\t\t\t>;\n\t\t\tmocks?: SharedSliceContent[];\n\t\t}[];\n\t\tmeta: {\n\t\t\tname?: string;\n\t\t\tversion?: string;\n\t\t\tisNodeModule: boolean;\n\t\t\tisDownloaded: boolean;\n\t\t\tisManual: boolean;\n\t\t};\n\t}[];\n\tcustomTypes: CustomType[];\n\tremoteCustomTypes: CustomType[];\n\tremoteSlices: SharedSlice[];\n\tclientError?: {\n\t\tname: string;\n\t\tmessage: string;\n\t\tstatus: number;\n\t\treason: string;\n\t};\n};\n\ntype SliceMachineManagerConstructorArgs = {\n\tcwd?: string;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\nexport class SliceMachineManager {\n\tprivate _sliceMachinePluginRunner: SliceMachinePluginRunner | undefined =\n\t\tundefined;\n\tprivate _prismicAuthManager: PrismicAuthManager;\n\n\tcwd: string;\n\n\tcustomTypes: CustomTypesManager;\n\tplugins: PluginsManager;\n\tprismicRepository: PrismicRepositoryManager;\n\tproject: ProjectManager;\n\tscreenshots: ScreenshotsManager;\n\tsimulator: SimulatorManager;\n\tslices: SlicesManager;\n\tsnippets: SnippetsManager;\n\tdocumentation: DocumentationManager;\n\tsliceTemplateLibrary: SliceTemplateLibraryManager;\n\ttelemetry: TelemetryManager;\n\tuser: UserManager;\n\tversions: VersionsManager;\n\tgit: GitManager;\n\n\tconstructor(args?: SliceMachineManagerConstructorArgs) {\n\t\t// _prismicAuthManager must be set at least before UserManager\n\t\t// is instantiated. It depends on the PrismicAuthManager for\n\t\t// authentication-related methods.\n\t\tthis._prismicAuthManager = createPrismicAuthManager();\n\n\t\tthis.user = new UserManager(this);\n\t\tthis.prismicRepository = new PrismicRepositoryManager(this);\n\n\t\tthis.plugins = new PluginsManager(this, {\n\t\t\tnativePlugins: args?.nativePlugins,\n\t\t});\n\n\t\tthis.project = new ProjectManager(this);\n\t\tthis.customTypes = new CustomTypesManager(this);\n\t\tthis.slices = new SlicesManager(this);\n\t\tthis.snippets = new SnippetsManager(this);\n\t\tthis.screenshots = new ScreenshotsManager(this);\n\t\tthis.simulator = new SimulatorManager(this);\n\t\tthis.documentation = new DocumentationManager(this);\n\t\tthis.sliceTemplateLibrary = new SliceTemplateLibraryManager(this);\n\n\t\tthis.versions = new VersionsManager(this);\n\n\t\tthis.telemetry = new TelemetryManager(this);\n\n\t\tthis.git = new GitManager(this);\n\n\t\tthis.cwd = args?.cwd ?? process.cwd();\n\t}\n\n\t// The `_sliceMachinePluginRunner` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat SliceMachinePluginRunner\n\t// as a child manager.\n\tgetSliceMachinePluginRunner(): SliceMachinePluginRunner | undefined {\n\t\treturn this._sliceMachinePluginRunner;\n\t}\n\n\t// The `_prismicAuthManager` property is hidden behind a function to\n\t// discourage access. Using a function deliberatly breaks the pattern\n\t// of other child managers that are accessible as properties, like\n\t// `project`, `plugins`, etc. We do not treat PrismicAuthManager as a\n\t// child manager.\n\tgetPrismicAuthManager(): PrismicAuthManager {\n\t\treturn this._prismicAuthManager;\n\t}\n\n\tgetAPIEndpoints(): APIEndpoints {\n\t\treturn API_ENDPOINTS;\n\t}\n\n\t// TODO: Remove this global-state method. It is expensive and a\n\t// potential source of bugs due to data inconsistency. SM UI relies on\n\t// it heavily, so removal will require significant effort.\n\tasync getState(): Promise<SliceMachineManagerGetStateReturnType> {\n\t\tconst [\n\t\t\t{ sliceMachineConfig, libraries },\n\t\t\t{ profile, remoteCustomTypes, remoteSlices, authError },\n\t\t\tcustomTypes,\n\t\t\tpackageManager,\n\t\t] = await Promise.all([\n\t\t\tthis.project.getSliceMachineConfig().then(async (sliceMachineConfig) => {\n\t\t\t\tconst libraries = await this._getLibraries(sliceMachineConfig);\n\n\t\t\t\treturn { sliceMachineConfig, libraries };\n\t\t\t}),\n\t\t\tthis._getProfile().then(async (profile) => {\n\t\t\t\tlet authError;\n\t\t\t\tif (profile) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst [remoteCustomTypes, remoteSlices] = await Promise.all([\n\t\t\t\t\t\t\tthis.customTypes.fetchRemoteCustomTypes(),\n\t\t\t\t\t\t\tthis.slices.fetchRemoteSlices(),\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tprofile,\n\t\t\t\t\t\t\tremoteCustomTypes,\n\t\t\t\t\t\t\tremoteSlices,\n\t\t\t\t\t\t\tauthError,\n\t\t\t\t\t\t};\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 401,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\terror instanceof prismicCustomTypesClient.UnauthorizedError\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tauthError = {\n\t\t\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\t\t\tstatus: 403,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tprofile,\n\t\t\t\t\tremoteCustomTypes: [],\n\t\t\t\t\tremoteSlices: [],\n\t\t\t\t\tauthError,\n\t\t\t\t};\n\t\t\t}),\n\t\t\tthis._getCustomTypes(),\n\t\t\tthis.project.detectPackageManager(),\n\t\t]);\n\n\t\t// SM UI detects if a user is logged out by looking at\n\t\t// `clientError`. Here, we simulate what the old core does by\n\t\t// returning an `ErrorWithStatus`-like object if the user does\n\t\t// not have access to the repository or is not logged in.\n\t\tconst clientError: SliceMachineManagerGetStateReturnType[\"clientError\"] =\n\t\t\tauthError ||\n\t\t\t(profile\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\tname: \"__stub__\",\n\t\t\t\t\t\tmessage: \"__stub__\",\n\t\t\t\t\t\treason: \"__stub__\",\n\t\t\t\t\t\tstatus: 401, // Needed to trigger the unauthorized flow.\n\t\t\t\t });\n\n\t\treturn {\n\t\t\tenv: {\n\t\t\t\tmanifest: {\n\t\t\t\t\tapiEndpoint:\n\t\t\t\t\t\tsliceMachineConfig.apiEndpoint ||\n\t\t\t\t\t\tbuildPrismicRepositoryAPIEndpoint(\n\t\t\t\t\t\t\tsliceMachineConfig.repositoryName,\n\t\t\t\t\t\t),\n\t\t\t\t\tlocalSliceSimulatorURL: sliceMachineConfig.localSliceSimulatorURL,\n\t\t\t\t},\n\t\t\t\tpackageManager,\n\t\t\t\trepo: sliceMachineConfig.repositoryName,\n\t\t\t\tintercomHash: profile?.intercomHash,\n\t\t\t\tshortId: profile?.shortId,\n\t\t\t\tendpoints: this.getAPIEndpoints(),\n\t\t\t},\n\t\t\tlibraries,\n\t\t\tcustomTypes,\n\t\t\tremoteCustomTypes,\n\t\t\tremoteSlices,\n\t\t\tclientError,\n\t\t};\n\t}\n\n\tprivate async _getProfile(): Promise<PrismicUserProfile | undefined> {\n\t\tlet profile: PrismicUserProfile | undefined;\n\n\t\tconst isLoggedIn = await this.user.checkIsLoggedIn();\n\n\t\tif (isLoggedIn) {\n\t\t\tprofile = await this.user.getProfile();\n\t\t\tawait this.user.refreshAuthenticationToken();\n\t\t}\n\n\t\treturn profile;\n\t}\n\n\tprivate async _getLibraries(\n\t\tsliceMachineConfig: SliceMachineConfig,\n\t): Promise<SliceMachineManagerGetStateReturnType[\"libraries\"]> {\n\t\tconst libraries: SliceMachineManagerGetStateReturnType[\"libraries\"] = [];\n\n\t\tif (sliceMachineConfig.libraries) {\n\t\t\tawait Promise.all(\n\t\t\t\tsliceMachineConfig.libraries.map(async (libraryID) => {\n\t\t\t\t\tconst { sliceIDs } = await this.slices.readSliceLibrary({\n\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (sliceIDs) {\n\t\t\t\t\t\tconst components: SliceMachineManagerGetStateReturnType[\"libraries\"][number][\"components\"] =\n\t\t\t\t\t\t\t[];\n\n\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\tsliceIDs.map(async (sliceID) => {\n\t\t\t\t\t\t\t\tconst [{ model }, { mocks }] = await Promise.all([\n\t\t\t\t\t\t\t\t\tthis.slices.readSlice({ libraryID, sliceID }),\n\t\t\t\t\t\t\t\t\tthis.slices.readSliceMocks({ libraryID, sliceID }),\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\tconst screenshots: (typeof components)[number][\"screenshots\"] =\n\t\t\t\t\t\t\t\t\t\t{};\n\t\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\t\tmodel.variations.map(async (variation) => {\n\t\t\t\t\t\t\t\t\t\t\tconst screenshot = await this.slices.readSliceScreenshot({\n\t\t\t\t\t\t\t\t\t\t\t\tlibraryID,\n\t\t\t\t\t\t\t\t\t\t\t\tsliceID,\n\t\t\t\t\t\t\t\t\t\t\t\tvariationID: variation.id,\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tif (screenshot.data) {\n\t\t\t\t\t\t\t\t\t\t\t\tscreenshots[variation.id] = {\n\t\t\t\t\t\t\t\t\t\t\t\t\thash: createContentDigest(screenshot.data),\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata: screenshot.data,\n\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\tcomponents.push({\n\t\t\t\t\t\t\t\t\t\tfrom: libraryID,\n\t\t\t\t\t\t\t\t\t\thref: libraryID.replace(/\\//g, \"--\"),\n\t\t\t\t\t\t\t\t\t\tpathToSlice: \"pathToSlice\",\n\t\t\t\t\t\t\t\t\t\tfileName: \"fileName\",\n\t\t\t\t\t\t\t\t\t\textension: \"extension\",\n\t\t\t\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\t\t\t\tscreenshots,\n\t\t\t\t\t\t\t\t\t\tmocks,\n\t\t\t\t\t\t\t\t\t});\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\n\t\t\t\t\t\tlibraries.push({\n\t\t\t\t\t\t\tname: libraryID,\n\t\t\t\t\t\t\tpath: libraryID,\n\t\t\t\t\t\t\tisLocal: true, // TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\tcomponents,\n\t\t\t\t\t\t\tmeta: {\n\t\t\t\t\t\t\t\t// TODO: Do we still support node_modules-based libraries?\n\t\t\t\t\t\t\t\tisNodeModule: false,\n\t\t\t\t\t\t\t\tisDownloaded: false,\n\t\t\t\t\t\t\t\tisManual: true,\n\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\t\t}\n\n\t\t// Preserve library order from config file\n\t\treturn libraries.sort((library1, library2) => {\n\t\t\tconst libraryIndex1 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library1.name) || 0;\n\t\t\tconst libraryIndex2 =\n\t\t\t\tsliceMachineConfig.libraries?.indexOf(library2.name) || 0;\n\n\t\t\treturn Math.sign(libraryIndex1 - libraryIndex2);\n\t\t});\n\t}\n\n\tprivate async _getCustomTypes(): Promise<\n\t\tSliceMachineManagerGetStateReturnType[\"customTypes\"]\n\t> {\n\t\tconst customTypes: SliceMachineManagerGetStateReturnType[\"customTypes\"] =\n\t\t\t[];\n\n\t\tconst { ids: customTypeIDs } =\n\t\t\tawait this.customTypes.readCustomTypeLibrary();\n\n\t\tif (customTypeIDs) {\n\t\t\tawait Promise.all(\n\t\t\t\tcustomTypeIDs.map(async (customTypeID) => {\n\t\t\t\t\tconst { model } = await this.customTypes.readCustomType({\n\t\t\t\t\t\tid: customTypeID,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (model) {\n\t\t\t\t\t\tcustomTypes.push(model);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn customTypes;\n\t}\n}\n"],"names":["sliceM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.BaseManager {
87
87
  */
88
88
  async updateContentRelationships(args) {
89
89
  assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
90
- const { model, updateMeta } = args;
91
- if (updateMeta == null ? void 0 : updateMeta.fieldIdChanged) {
92
- let { previousPath, newPath } = updateMeta.fieldIdChanged;
93
- if (previousPath.join(".") !== newPath.join(".")) {
94
- previousPath = [model.id, ...previousPath];
95
- newPath = [model.id, ...newPath];
96
- const crUpdates = [];
97
- const customTypes = await this.readAllCustomTypes();
98
- updateCustomTypeContentRelationships({
99
- models: customTypes.models,
100
- onUpdate: (model2) => {
90
+ const { model } = args;
91
+ let { newPath, previousPath } = args;
92
+ if (previousPath.join(".") !== newPath.join(".")) {
93
+ previousPath = [model.id, ...previousPath];
94
+ newPath = [model.id, ...newPath];
95
+ const crUpdates = [];
96
+ const customTypes = await this.readAllCustomTypes();
97
+ updateCustomTypeContentRelationships({
98
+ models: customTypes.models,
99
+ onUpdate: ({ previousModel, model: updatedModel }) => {
100
+ var _a;
101
+ assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
102
+ crUpdates.push({
103
+ updatePromise: (_a = this.sliceMachinePluginRunner) == null ? void 0 : _a.callHook("custom-type:update", { model: updatedModel }),
104
+ rollback: () => {
105
+ var _a2;
106
+ (_a2 = this.sliceMachinePluginRunner) == null ? void 0 : _a2.callHook("custom-type:update", {
107
+ model: previousModel
108
+ });
109
+ }
110
+ });
111
+ },
112
+ previousPath,
113
+ newPath
114
+ });
115
+ const { libraries } = await this.slices.readAllSliceLibraries();
116
+ for (const library of libraries) {
117
+ const slices = await this.slices.readAllSlicesForLibrary({
118
+ libraryID: library.libraryID
119
+ });
120
+ updateSharedSliceContentRelationships({
121
+ models: slices.models,
122
+ onUpdate: ({ previousModel, model: updatedModel }) => {
101
123
  var _a;
102
- pushIfDefined(crUpdates, (_a = this.sliceMachinePluginRunner) == null ? void 0 : _a.callHook("custom-type:update", {
103
- model: model2
104
- }));
124
+ assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
125
+ crUpdates.push({
126
+ updatePromise: (_a = this.sliceMachinePluginRunner) == null ? void 0 : _a.callHook("slice:update", { libraryID: library.libraryID, model: updatedModel }),
127
+ rollback: () => {
128
+ var _a2;
129
+ (_a2 = this.sliceMachinePluginRunner) == null ? void 0 : _a2.callHook("slice:update", {
130
+ libraryID: library.libraryID,
131
+ model: previousModel
132
+ });
133
+ }
134
+ });
105
135
  },
106
136
  previousPath,
107
137
  newPath
108
138
  });
109
- const { libraries } = await this.slices.readAllSliceLibraries();
110
- for (const library of libraries) {
111
- const slices = await this.slices.readAllSlicesForLibrary({
112
- libraryID: library.libraryID
113
- });
114
- updateSharedSliceContentRelationships({
115
- models: slices.models,
116
- onUpdate: (model2) => {
117
- var _a;
118
- pushIfDefined(crUpdates, (_a = this.sliceMachinePluginRunner) == null ? void 0 : _a.callHook("slice:update", {
119
- libraryID: library.libraryID,
120
- model: model2
121
- }));
122
- },
123
- previousPath,
124
- newPath
125
- });
126
- }
127
- const crUpdatesResult = await Promise.all(crUpdates);
128
- if (crUpdatesResult.some((result) => result.errors.length > 0)) {
129
- return {
130
- errors: crUpdatesResult.flatMap((result) => result.errors)
131
- };
132
- }
139
+ }
140
+ const crUpdatesResult = await Promise.all(crUpdates.map((update) => update.updatePromise));
141
+ if (crUpdatesResult.some((result) => result.errors.length > 0)) {
142
+ return {
143
+ errors: crUpdatesResult.flatMap((result) => result.errors),
144
+ rollback: async () => {
145
+ await Promise.all(crUpdates.map((update) => update.rollback()));
146
+ }
147
+ };
133
148
  }
134
149
  }
135
150
  return { errors: [] };
136
151
  }
137
152
  async updateCustomType(args) {
138
- var _a;
153
+ var _a, _b;
139
154
  assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
140
- const hookResult = await this.sliceMachinePluginRunner.callHook("custom-type:update", args);
141
- if ((_a = args.updateMeta) == null ? void 0 : _a.fieldIdChanged) {
142
- await this.updateContentRelationships(args);
155
+ const { model } = args;
156
+ const { fieldIdChanged } = args.updateMeta ?? {};
157
+ let previousCustomType;
158
+ if (fieldIdChanged) {
159
+ const customTypeRead = await this.readCustomType({ id: model.id });
160
+ if (customTypeRead.errors.length > 0) {
161
+ return { errors: customTypeRead.errors };
162
+ }
163
+ if (!customTypeRead.model) {
164
+ throw new Error(`readCustomType succeeded reading custom type ${model.id} but model is undefined.`);
165
+ }
166
+ previousCustomType = customTypeRead.model;
167
+ }
168
+ const customTypeUpdateResult = await this.sliceMachinePluginRunner.callHook("custom-type:update", { model });
169
+ if (customTypeUpdateResult.errors.length > 0) {
170
+ return { errors: customTypeUpdateResult.errors };
143
171
  }
144
- return { errors: hookResult.errors };
172
+ if (previousCustomType && fieldIdChanged) {
173
+ const crUpdateResult = await this.updateContentRelationships({
174
+ ...fieldIdChanged,
175
+ model: previousCustomType
176
+ });
177
+ if (crUpdateResult.errors.length > 0) {
178
+ await ((_a = this.sliceMachinePluginRunner) == null ? void 0 : _a.callHook("custom-type:update", {
179
+ model: previousCustomType
180
+ }));
181
+ await ((_b = crUpdateResult.rollback) == null ? void 0 : _b.call(crUpdateResult));
182
+ return { errors: crUpdateResult.errors };
183
+ }
184
+ }
185
+ return { errors: [] };
145
186
  }
146
187
  async renameCustomType(args) {
147
188
  assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
@@ -354,7 +395,7 @@ function updateFieldContentRelationships(args) {
354
395
  function updateCustomTypeContentRelationships(args) {
355
396
  const { models, previousPath, newPath, onUpdate } = args;
356
397
  for (const { model: customType } of models) {
357
- const updatedCustomTypeModel = customtypes.traverseCustomType({
398
+ const updatedCustomType = customtypes.traverseCustomType({
358
399
  customType,
359
400
  onField: ({ field }) => {
360
401
  return updateFieldContentRelationships({
@@ -364,15 +405,15 @@ function updateCustomTypeContentRelationships(args) {
364
405
  });
365
406
  }
366
407
  });
367
- if (!isEqualModel(customType, updatedCustomTypeModel)) {
368
- onUpdate(updatedCustomTypeModel);
408
+ if (!isEqualModel(customType, updatedCustomType)) {
409
+ onUpdate({ model: updatedCustomType, previousModel: customType });
369
410
  }
370
411
  }
371
412
  }
372
413
  function updateSharedSliceContentRelationships(args) {
373
414
  const { models, previousPath, newPath, onUpdate } = args;
374
415
  for (const { model: slice } of models) {
375
- const updatedSliceModel = customtypes.traverseSharedSlice({
416
+ const updateSlice = customtypes.traverseSharedSlice({
376
417
  path: ["."],
377
418
  slice,
378
419
  onField: ({ field }) => {
@@ -383,8 +424,8 @@ function updateSharedSliceContentRelationships(args) {
383
424
  });
384
425
  }
385
426
  });
386
- if (!isEqualModel(slice, updatedSliceModel)) {
387
- onUpdate(updatedSliceModel);
427
+ if (!isEqualModel(slice, updateSlice)) {
428
+ onUpdate({ model: updateSlice, previousModel: slice });
388
429
  }
389
430
  }
390
431
  }
@@ -397,11 +438,6 @@ function shallowCloneIfObject(value) {
397
438
  }
398
439
  return value;
399
440
  }
400
- function pushIfDefined(array, value) {
401
- if (value) {
402
- array.push(value);
403
- }
404
- }
405
441
  exports.CustomTypesManager = CustomTypesManager;
406
442
  exports.updateCustomTypeContentRelationships = updateCustomTypeContentRelationships;
407
443
  exports.updateSharedSliceContentRelationships = updateSharedSliceContentRelationships;