@slicemachine/manager 0.24.15-beta.8 → 0.24.15-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_node_modules/@amplitude/analytics-core/_node_modules/tslib/tslib.es6.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-core/_node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-core/lib/esm/plugins/destination.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-core/lib/esm/plugins/destination.js.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-core/lib/esm/utils/debug.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-core/lib/esm/utils/debug.js.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-core/lib/esm/utils/valid-properties.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-core/lib/esm/utils/valid-properties.js.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-node/_node_modules/tslib/tslib.es6.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-node/_node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-node/lib/esm/transports/http.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/analytics-node/lib/esm/transports/http.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-core/dist/experiment-core.esm.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-core/dist/experiment-core.esm.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/assignment/assignment-service.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/assignment/assignment-service.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/assignment/assignment.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/assignment/assignment.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/cookie.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/cookie.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/cache.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/cache.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.cjs +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.js +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/fetcher.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/fetcher.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/poller.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/poller.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/remote/client.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/remote/client.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/transport/http.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/transport/http.js.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/util/backoff.cjs.map +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/util/backoff.js.map +1 -1
- package/dist/_node_modules/@msgpack/msgpack/dist.es5_esm/Decoder.cjs.map +1 -1
- package/dist/_node_modules/@msgpack/msgpack/dist.es5_esm/Decoder.js.map +1 -1
- package/dist/_node_modules/cross-spawn/index.cjs +1 -1
- package/dist/_node_modules/cross-spawn/index.js +1 -1
- package/dist/_node_modules/cross-spawn/lib/enoent.cjs.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/enoent.js.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/parse.cjs.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/parse.js.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/util/escape.cjs.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/util/escape.js.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/util/readShebang.cjs.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/util/readShebang.js.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/util/resolveCommand.cjs.map +1 -1
- package/dist/_node_modules/cross-spawn/lib/util/resolveCommand.js.map +1 -1
- package/dist/_node_modules/data-uri-to-buffer/dist/index.cjs.map +1 -1
- package/dist/_node_modules/data-uri-to-buffer/dist/index.js.map +1 -1
- package/dist/_node_modules/execa/_node_modules/onetime/index.cjs.map +1 -1
- package/dist/_node_modules/execa/_node_modules/onetime/index.js.map +1 -1
- package/dist/_node_modules/execa/index.cjs.map +1 -1
- package/dist/_node_modules/execa/index.js.map +1 -1
- package/dist/_node_modules/execa/lib/command.cjs.map +1 -1
- package/dist/_node_modules/execa/lib/command.js.map +1 -1
- package/dist/_node_modules/execa/lib/error.cjs.map +1 -1
- package/dist/_node_modules/execa/lib/error.js.map +1 -1
- package/dist/_node_modules/execa/lib/kill.cjs.map +1 -1
- package/dist/_node_modules/execa/lib/kill.js.map +1 -1
- package/dist/_node_modules/execa/lib/promise.cjs +2 -2
- package/dist/_node_modules/execa/lib/promise.cjs.map +1 -1
- package/dist/_node_modules/execa/lib/promise.js +2 -2
- package/dist/_node_modules/execa/lib/promise.js.map +1 -1
- package/dist/_node_modules/execa/lib/stdio.cjs.map +1 -1
- package/dist/_node_modules/execa/lib/stdio.js.map +1 -1
- package/dist/_node_modules/execa/lib/stream.cjs.map +1 -1
- package/dist/_node_modules/execa/lib/stream.js.map +1 -1
- package/dist/_node_modules/execa/lib/verbose.cjs.map +1 -1
- package/dist/_node_modules/execa/lib/verbose.js.map +1 -1
- package/dist/_node_modules/fetch-blob/file.cjs.map +1 -1
- package/dist/_node_modules/fetch-blob/file.js.map +1 -1
- package/dist/_node_modules/fetch-blob/index.cjs.map +1 -1
- package/dist/_node_modules/fetch-blob/index.js.map +1 -1
- package/dist/_node_modules/fetch-blob/streams.cjs.map +1 -1
- package/dist/_node_modules/fetch-blob/streams.js.map +1 -1
- package/dist/_node_modules/file-type/core.cjs.map +1 -1
- package/dist/_node_modules/file-type/core.js.map +1 -1
- package/dist/_node_modules/formdata-polyfill/esm.min.cjs.map +1 -1
- package/dist/_node_modules/formdata-polyfill/esm.min.js.map +1 -1
- package/dist/_node_modules/get-port/index.cjs.map +1 -1
- package/dist/_node_modules/get-port/index.js.map +1 -1
- package/dist/_node_modules/get-stream/index.cjs.map +1 -1
- package/dist/_node_modules/get-stream/index.js.map +1 -1
- package/dist/_node_modules/human-signals/build/src/realtime.cjs.map +1 -1
- package/dist/_node_modules/human-signals/build/src/realtime.js.map +1 -1
- package/dist/_node_modules/isexe/index.cjs.map +1 -1
- package/dist/_node_modules/isexe/index.js.map +1 -1
- package/dist/_node_modules/mimic-fn/index.cjs.map +1 -1
- package/dist/_node_modules/mimic-fn/index.js.map +1 -1
- package/dist/_node_modules/node-domexception/index.cjs.map +1 -1
- package/dist/_node_modules/node-domexception/index.js.map +1 -1
- package/dist/_node_modules/node-fetch/src/body.cjs.map +1 -1
- package/dist/_node_modules/node-fetch/src/body.js.map +1 -1
- package/dist/_node_modules/node-fetch/src/headers.cjs.map +1 -1
- package/dist/_node_modules/node-fetch/src/headers.js.map +1 -1
- package/dist/_node_modules/node-fetch/src/index.cjs.map +1 -1
- package/dist/_node_modules/node-fetch/src/index.js.map +1 -1
- package/dist/_node_modules/node-fetch/src/request.cjs.map +1 -1
- package/dist/_node_modules/node-fetch/src/request.js.map +1 -1
- package/dist/_node_modules/node-fetch/src/utils/is.cjs.map +1 -1
- package/dist/_node_modules/node-fetch/src/utils/is.js.map +1 -1
- package/dist/_node_modules/node-fetch/src/utils/multipart-parser.cjs.map +1 -1
- package/dist/_node_modules/node-fetch/src/utils/multipart-parser.js.map +1 -1
- package/dist/_node_modules/node-fetch/src/utils/referrer.cjs.map +1 -1
- package/dist/_node_modules/node-fetch/src/utils/referrer.js.map +1 -1
- package/dist/_node_modules/p-limit/index.cjs.map +1 -1
- package/dist/_node_modules/p-limit/index.js.map +1 -1
- package/dist/_node_modules/r19/dist/handleRPCRequest.cjs.map +1 -1
- package/dist/_node_modules/r19/dist/handleRPCRequest.js.map +1 -1
- package/dist/_node_modules/shebang-command/index.cjs.map +1 -1
- package/dist/_node_modules/shebang-command/index.js.map +1 -1
- package/dist/_node_modules/signal-exit/index.cjs.map +1 -1
- package/dist/_node_modules/signal-exit/index.js.map +1 -1
- package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs.map +1 -1
- package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -1
- package/dist/_node_modules/which/which.cjs.map +1 -1
- package/dist/_node_modules/which/which.js.map +1 -1
- package/dist/_node_modules/zod/lib/index.cjs.map +1 -1
- package/dist/_node_modules/zod/lib/index.js.map +1 -1
- package/dist/_virtual/_commonjsHelpers.cjs +1 -4
- package/dist/_virtual/_commonjsHelpers.cjs.map +1 -1
- package/dist/_virtual/_commonjsHelpers.js +1 -4
- package/dist/_virtual/_commonjsHelpers.js.map +1 -1
- package/dist/_virtual/index2.cjs +3 -4
- package/dist/_virtual/index2.cjs.map +1 -1
- package/dist/_virtual/index2.js +2 -4
- package/dist/_virtual/index2.js.map +1 -1
- package/dist/_virtual/index3.cjs +4 -3
- package/dist/_virtual/index3.cjs.map +1 -1
- package/dist/_virtual/index3.js +4 -2
- package/dist/_virtual/index3.js.map +1 -1
- package/dist/auth/PrismicAuthManager.cjs.map +1 -1
- package/dist/auth/PrismicAuthManager.js.map +1 -1
- package/dist/auth/createPrismicAuthManagerMiddleware.cjs.map +1 -1
- package/dist/auth/createPrismicAuthManagerMiddleware.js.map +1 -1
- package/dist/constants/API_ENDPOINTS.cjs.map +1 -1
- package/dist/constants/API_ENDPOINTS.js.map +1 -1
- package/dist/constants/API_TOKENS.cjs.map +1 -1
- package/dist/constants/API_TOKENS.js.map +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/getEnvironmentInfo.cjs.map +1 -1
- package/dist/getEnvironmentInfo.js.map +1 -1
- package/dist/lib/DecodeError.cjs.map +1 -1
- package/dist/lib/DecodeError.js.map +1 -1
- package/dist/lib/buildPrismicRepositoryAPIEndpoint.cjs.map +1 -1
- package/dist/lib/buildPrismicRepositoryAPIEndpoint.js.map +1 -1
- package/dist/lib/fetchGitHubReleaseBodyForRelease.cjs.map +1 -1
- package/dist/lib/fetchGitHubReleaseBodyForRelease.js.map +1 -1
- package/dist/lib/fetchNPMPackageVersions.cjs.map +1 -1
- package/dist/lib/fetchNPMPackageVersions.js.map +1 -1
- package/dist/lib/installDependencies.cjs.map +1 -1
- package/dist/lib/installDependencies.js.map +1 -1
- package/dist/lib/locateFileUpward.cjs.map +1 -1
- package/dist/lib/locateFileUpward.js.map +1 -1
- package/dist/lib/prismicrc.cjs.map +1 -1
- package/dist/lib/prismicrc.js.map +1 -1
- package/dist/managers/SliceMachineManager.cjs.map +1 -1
- package/dist/managers/SliceMachineManager.js.map +1 -1
- package/dist/managers/customTypes/CustomTypesManager.cjs.map +1 -1
- package/dist/managers/customTypes/CustomTypesManager.js.map +1 -1
- package/dist/managers/git/GitManager.cjs.map +1 -1
- package/dist/managers/git/GitManager.js.map +1 -1
- package/dist/managers/git/buildGitRepoSpecifier.cjs.map +1 -1
- package/dist/managers/git/buildGitRepoSpecifier.js.map +1 -1
- package/dist/managers/prismicRepository/PrismicRepositoryManager.cjs.map +1 -1
- package/dist/managers/prismicRepository/PrismicRepositoryManager.js.map +1 -1
- package/dist/managers/project/ProjectManager.cjs.map +1 -1
- package/dist/managers/project/ProjectManager.js.map +1 -1
- package/dist/managers/screenshots/ScreenshotsManager.cjs.map +1 -1
- package/dist/managers/screenshots/ScreenshotsManager.js.map +1 -1
- package/dist/managers/sliceTemplateLibrary/SliceTemplateLibraryManager.cjs.map +1 -1
- package/dist/managers/sliceTemplateLibrary/SliceTemplateLibraryManager.js.map +1 -1
- package/dist/managers/slices/SlicesManager.cjs.map +1 -1
- package/dist/managers/slices/SlicesManager.js.map +1 -1
- package/dist/managers/telemetry/TelemetryManager.cjs.map +1 -1
- package/dist/managers/telemetry/TelemetryManager.js.map +1 -1
- package/dist/managers/versions/VersionsManager.cjs.map +1 -1
- package/dist/managers/versions/VersionsManager.js.map +1 -1
- package/package.json +3 -3
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fetchGitHubReleaseBodyForRelease.js","sources":["../../../src/lib/fetchGitHubReleaseBodyForRelease.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport fetch from \"./fetch\";\nimport pLimit from \"p-limit\";\n\nimport { decode } from \"./decode\";\n\nconst GITHUB_JSON_ACCEPT_HEADER = \"application/vnd.github+json\";\n\n/**\n * A minimally defined codec for GitHub release metadata.\n *\n * @see https://docs.github.com/en/rest/releases/releases#get-a-release-by-tag-name\n */\nconst GitHubReleaseMetadata = t.type({\n\tname: t.string,\n\tbody: t.union([t.null, t.string]),\n});\nexport type GitHubReleaseMetadata = t.TypeOf<typeof GitHubReleaseMetadata>;\n\ntype FetchAllGitHubReleasesArgs = {\n\trepositoryOwner: string;\n\trepositoryName: string;\n};\n\nconst fetchAllGitHubReleases = async (\n\targs: FetchAllGitHubReleasesArgs,\n): Promise<GitHubReleaseMetadata[]> => {\n\tconst res = await fetch(\n\t\t`https://api.github.com/repos/${args.repositoryOwner}/${args.repositoryName}/releases`,\n\t\t{\n\t\t\theaders: {\n\t\t\t\tAccept: GITHUB_JSON_ACCEPT_HEADER,\n\t\t\t},\n\t\t},\n\t);\n\n\tif (res.ok) {\n\t\tconst json = await res.json();\n\n\t\tconst { value, error } = decode(t.array(GitHubReleaseMetadata), json);\n\n\t\tif (error) {\n\t\t\tthrow new Error(`Invalid GitHub Release response.`, { cause: error });\n\t\t}\n\n\t\treturn value;\n\t} else {\n\t\tconst text = await res.text();\n\t\tthrow new Error(`Invalid GitHub Release response.`, {\n\t\t\tcause: text,\n\t\t});\n\t}\n};\n\ntype FetchGitHubReleaseByVersionArgs = {\n\trepositoryOwner: string;\n\trepositoryName: string;\n\tpackageName?: string;\n\tversion: string;\n};\n\nconst fetchGitHubReleaseByVersion = async (\n\targs: FetchGitHubReleaseByVersionArgs,\n): Promise<GitHubReleaseMetadata | undefined> => {\n\tlet url: string;\n\n\tif (args.packageName) {\n\t\turl = `https://api.github.com/repos/${args.repositoryOwner}/${args.repositoryName}/releases/tags/${args.packageName}@${args.version}`;\n\t} else {\n\t\turl = `https://api.github.com/repos/${args.repositoryOwner}/${args.repositoryName}/releases/tags/${args.version}`;\n\t}\n\n\tconst res = await fetch(url, {\n\t\theaders: {\n\t\t\tAccept: GITHUB_JSON_ACCEPT_HEADER,\n\t\t},\n\t});\n\n\tif (res.ok) {\n\t\tconst json = await res.json();\n\n\t\tconst { value, error } = decode(GitHubReleaseMetadata, json);\n\n\t\tif (error) {\n\t\t\tthrow new Error(`Invalid GitHub Release response.`, { cause: error });\n\t\t}\n\n\t\treturn value;\n\t}\n};\n\ntype FetchGitHubReleaseBodyForReleaseArgs = {\n\trepositoryOwner: string;\n\trepositoryName: string;\n\tpackageName?: string;\n\tversion: string;\n\tcache?: Record<string, GitHubReleaseMetadata | undefined>;\n};\n\nconst _fetchGitHubReleaseBodyForRelease = async (\n\targs: FetchGitHubReleaseBodyForReleaseArgs,\n): Promise<string | undefined> => {\n\tconst cache = args.cache || {};\n\n\tif (Object.keys(cache).length < 1) {\n\t\tconst releases = await fetchAllGitHubReleases({\n\t\t\trepositoryOwner: args.repositoryOwner,\n\t\t\trepositoryName: args.repositoryName,\n\t\t});\n\n\t\tfor (const release of releases) {\n\t\t\tcache[release.name] = release;\n\t\t}\n\t}\n\n\tif (args.version in cache) {\n\t\tconst release = cache[args.version];\n\n\t\treturn release?.body ?? undefined;\n\t} else {\n\t\ttry {\n\t\t\tconst version = await fetchGitHubReleaseByVersion({\n\t\t\t\trepositoryOwner: args.repositoryOwner,\n\t\t\t\trepositoryName: args.repositoryName,\n\t\t\t\tpackageName: args.packageName,\n\t\t\t\tversion: args.version,\n\t\t\t});\n\n\t\t\tcache[args.version] = version;\n\n\t\t\treturn version?.body ?? undefined;\n\t\t} catch {\n\t\t\tcache[args.version] = undefined;\n\n\t\t\treturn undefined;\n\t\t}\n\t}\n};\n\nconst limit = pLimit(1);\n\nexport const fetchGitHubReleaseBodyForRelease = async (\n\t...args: Parameters<typeof _fetchGitHubReleaseBodyForRelease>\n): ReturnType<typeof _fetchGitHubReleaseBodyForRelease> => {\n\treturn await limit(() => _fetchGitHubReleaseBodyForRelease(...args));\n};\n"],"names":[],"mappings":";;;;AAMA,MAAM,4BAA4B;AAOlC,MAAM,wBAAwB,EAAE,KAAK;AAAA,EACpC,MAAM,EAAE;AAAA,EACR,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC;AAChC,CAAA;AAQD,MAAM,yBAAyB,OAC9B,SACqC;
|
1
|
+
{"version":3,"file":"fetchGitHubReleaseBodyForRelease.js","sources":["../../../src/lib/fetchGitHubReleaseBodyForRelease.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport fetch from \"./fetch\";\nimport pLimit from \"p-limit\";\n\nimport { decode } from \"./decode\";\n\nconst GITHUB_JSON_ACCEPT_HEADER = \"application/vnd.github+json\";\n\n/**\n * A minimally defined codec for GitHub release metadata.\n *\n * @see https://docs.github.com/en/rest/releases/releases#get-a-release-by-tag-name\n */\nconst GitHubReleaseMetadata = t.type({\n\tname: t.string,\n\tbody: t.union([t.null, t.string]),\n});\nexport type GitHubReleaseMetadata = t.TypeOf<typeof GitHubReleaseMetadata>;\n\ntype FetchAllGitHubReleasesArgs = {\n\trepositoryOwner: string;\n\trepositoryName: string;\n};\n\nconst fetchAllGitHubReleases = async (\n\targs: FetchAllGitHubReleasesArgs,\n): Promise<GitHubReleaseMetadata[]> => {\n\tconst res = await fetch(\n\t\t`https://api.github.com/repos/${args.repositoryOwner}/${args.repositoryName}/releases`,\n\t\t{\n\t\t\theaders: {\n\t\t\t\tAccept: GITHUB_JSON_ACCEPT_HEADER,\n\t\t\t},\n\t\t},\n\t);\n\n\tif (res.ok) {\n\t\tconst json = await res.json();\n\n\t\tconst { value, error } = decode(t.array(GitHubReleaseMetadata), json);\n\n\t\tif (error) {\n\t\t\tthrow new Error(`Invalid GitHub Release response.`, { cause: error });\n\t\t}\n\n\t\treturn value;\n\t} else {\n\t\tconst text = await res.text();\n\t\tthrow new Error(`Invalid GitHub Release response.`, {\n\t\t\tcause: text,\n\t\t});\n\t}\n};\n\ntype FetchGitHubReleaseByVersionArgs = {\n\trepositoryOwner: string;\n\trepositoryName: string;\n\tpackageName?: string;\n\tversion: string;\n};\n\nconst fetchGitHubReleaseByVersion = async (\n\targs: FetchGitHubReleaseByVersionArgs,\n): Promise<GitHubReleaseMetadata | undefined> => {\n\tlet url: string;\n\n\tif (args.packageName) {\n\t\turl = `https://api.github.com/repos/${args.repositoryOwner}/${args.repositoryName}/releases/tags/${args.packageName}@${args.version}`;\n\t} else {\n\t\turl = `https://api.github.com/repos/${args.repositoryOwner}/${args.repositoryName}/releases/tags/${args.version}`;\n\t}\n\n\tconst res = await fetch(url, {\n\t\theaders: {\n\t\t\tAccept: GITHUB_JSON_ACCEPT_HEADER,\n\t\t},\n\t});\n\n\tif (res.ok) {\n\t\tconst json = await res.json();\n\n\t\tconst { value, error } = decode(GitHubReleaseMetadata, json);\n\n\t\tif (error) {\n\t\t\tthrow new Error(`Invalid GitHub Release response.`, { cause: error });\n\t\t}\n\n\t\treturn value;\n\t}\n};\n\ntype FetchGitHubReleaseBodyForReleaseArgs = {\n\trepositoryOwner: string;\n\trepositoryName: string;\n\tpackageName?: string;\n\tversion: string;\n\tcache?: Record<string, GitHubReleaseMetadata | undefined>;\n};\n\nconst _fetchGitHubReleaseBodyForRelease = async (\n\targs: FetchGitHubReleaseBodyForReleaseArgs,\n): Promise<string | undefined> => {\n\tconst cache = args.cache || {};\n\n\tif (Object.keys(cache).length < 1) {\n\t\tconst releases = await fetchAllGitHubReleases({\n\t\t\trepositoryOwner: args.repositoryOwner,\n\t\t\trepositoryName: args.repositoryName,\n\t\t});\n\n\t\tfor (const release of releases) {\n\t\t\tcache[release.name] = release;\n\t\t}\n\t}\n\n\tif (args.version in cache) {\n\t\tconst release = cache[args.version];\n\n\t\treturn release?.body ?? undefined;\n\t} else {\n\t\ttry {\n\t\t\tconst version = await fetchGitHubReleaseByVersion({\n\t\t\t\trepositoryOwner: args.repositoryOwner,\n\t\t\t\trepositoryName: args.repositoryName,\n\t\t\t\tpackageName: args.packageName,\n\t\t\t\tversion: args.version,\n\t\t\t});\n\n\t\t\tcache[args.version] = version;\n\n\t\t\treturn version?.body ?? undefined;\n\t\t} catch {\n\t\t\tcache[args.version] = undefined;\n\n\t\t\treturn undefined;\n\t\t}\n\t}\n};\n\nconst limit = pLimit(1);\n\nexport const fetchGitHubReleaseBodyForRelease = async (\n\t...args: Parameters<typeof _fetchGitHubReleaseBodyForRelease>\n): ReturnType<typeof _fetchGitHubReleaseBodyForRelease> => {\n\treturn await limit(() => _fetchGitHubReleaseBodyForRelease(...args));\n};\n"],"names":[],"mappings":";;;;AAMA,MAAM,4BAA4B;AAOlC,MAAM,wBAAwB,EAAE,KAAK;AAAA,EACpC,MAAM,EAAE;AAAA,EACR,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC;AAChC,CAAA;AAQD,MAAM,yBAAyB,OAC9B,SACqC;AAC/B,QAAA,MAAM,MAAM,MACjB,gCAAgC,KAAK,eAAe,IAAI,KAAK,cAAc,aAC3E;AAAA,IACC,SAAS;AAAA,MACR,QAAQ;AAAA,IACR;AAAA,EAAA,CACD;AAGF,MAAI,IAAI,IAAI;AACL,UAAA,OAAO,MAAM,IAAI;AAEjB,UAAA,EAAE,OAAO,MAAK,IA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AAAA,EAAA,OAClB;AACF,QAAA;AACG,YAAA,UAAU,MAAM,4BAA4B;AAAA,QACjD,iBAAiB,KAAK;AAAA,QACtB,gBAAgB,KAAK;AAAA,QACrB,aAAa,KAAK;AAAA,QAClB,SAAS,KAAK;AAAA,MAAA,CACd;AAEK,YAAA,KAAK,OAAO,IAAI;AAEtB,cAAO,mCAAS,SAAQ;AAAA,IAAA,QACjB;AACD,YAAA,KAAK,OAAO,IAAI;AAEf,aAAA;AAAA,IACR;AAAA,EACD;AACD;AAEA,MAAM,QAAQ,OAAO,CAAC;AAET,MAAA,mCAAmC,UAC5C,SACsD;AACzD,SAAO,MAAM,MAAM,MAAM,kCAAkC,GAAG,IAAI,CAAC;AACpE;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fetchNPMPackageVersions.cjs","sources":["../../../src/lib/fetchNPMPackageVersions.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport fetch from \"./fetch\";\n\nimport { decode } from \"./decode\";\n\n/**\n * The Accept header value used when only metadata required for package\n * installation is needed. The response includes all versions and some of their\n * metadata.\n *\n * @see https://github.com/npm/registry/blob/cfe04736f34db9274a780184d1cdb2fb3e4ead2a/docs/responses/package-metadata.md#package-metadata\n */\nconst NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER =\n\t\"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*\";\n\n/**\n * A minimally defined codec for NPM registry package metadata. Only data needed\n * for version detection is defined.\n */\nconst NPMRegistryPackageMetadataCodec = t.type({\n\tversions: t.UnknownRecord,\n});\n\ntype FetchNPMPackageVersionsArgs = {\n\tpackageName: string;\n};\n\nexport const fetchNPMPackageVersions = async (\n\targs: FetchNPMPackageVersionsArgs,\n): Promise<string[]> => {\n\tconst res = await fetch(`https://registry.npmjs.org/${args.packageName}`, {\n\t\theaders: {\n\t\t\tAccept: NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER,\n\t\t},\n\t});\n\n\tconst json = await res.json();\n\n\tconst { value, error } = decode(NPMRegistryPackageMetadataCodec, json);\n\n\tif (error) {\n\t\tthrow new Error(`Invalid NPM registry response.`, { cause: error });\n\t}\n\n\treturn Object.keys(value.versions);\n};\n"],"names":["t","fetch","decode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,kDACL;AAMD,MAAM,kCAAkCA,aAAE,KAAK;AAAA,EAC9C,UAAUA,aAAE;AACZ,CAAA;AAMY,MAAA,0BAA0B,OACtC,SACsB;AACtB,QAAM,MAAM,MAAMC,cAAM,8BAA8B,KAAK,
|
1
|
+
{"version":3,"file":"fetchNPMPackageVersions.cjs","sources":["../../../src/lib/fetchNPMPackageVersions.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport fetch from \"./fetch\";\n\nimport { decode } from \"./decode\";\n\n/**\n * The Accept header value used when only metadata required for package\n * installation is needed. The response includes all versions and some of their\n * metadata.\n *\n * @see https://github.com/npm/registry/blob/cfe04736f34db9274a780184d1cdb2fb3e4ead2a/docs/responses/package-metadata.md#package-metadata\n */\nconst NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER =\n\t\"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*\";\n\n/**\n * A minimally defined codec for NPM registry package metadata. Only data needed\n * for version detection is defined.\n */\nconst NPMRegistryPackageMetadataCodec = t.type({\n\tversions: t.UnknownRecord,\n});\n\ntype FetchNPMPackageVersionsArgs = {\n\tpackageName: string;\n};\n\nexport const fetchNPMPackageVersions = async (\n\targs: FetchNPMPackageVersionsArgs,\n): Promise<string[]> => {\n\tconst res = await fetch(`https://registry.npmjs.org/${args.packageName}`, {\n\t\theaders: {\n\t\t\tAccept: NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER,\n\t\t},\n\t});\n\n\tconst json = await res.json();\n\n\tconst { value, error } = decode(NPMRegistryPackageMetadataCodec, json);\n\n\tif (error) {\n\t\tthrow new Error(`Invalid NPM registry response.`, { cause: error });\n\t}\n\n\treturn Object.keys(value.versions);\n};\n"],"names":["t","fetch","decode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,kDACL;AAMD,MAAM,kCAAkCA,aAAE,KAAK;AAAA,EAC9C,UAAUA,aAAE;AACZ,CAAA;AAMY,MAAA,0BAA0B,OACtC,SACsB;AACtB,QAAM,MAAM,MAAMC,cAAM,8BAA8B,KAAK,WAAW,IAAI;AAAA,IACzE,SAAS;AAAA,MACR,QAAQ;AAAA,IACR;AAAA,EAAA,CACD;AAEK,QAAA,OAAO,MAAM,IAAI;AAEvB,QAAM,EAAE,OAAO,MAAA,IAAUC,OAAAA,OAAO,iCAAiC,IAAI;AAErE,MAAI,OAAO;AACV,UAAM,IAAI,MAAM,kCAAkC,EAAE,OAAO,OAAO;AAAA,EACnE;AAEO,SAAA,OAAO,KAAK,MAAM,QAAQ;AAClC;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fetchNPMPackageVersions.js","sources":["../../../src/lib/fetchNPMPackageVersions.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport fetch from \"./fetch\";\n\nimport { decode } from \"./decode\";\n\n/**\n * The Accept header value used when only metadata required for package\n * installation is needed. The response includes all versions and some of their\n * metadata.\n *\n * @see https://github.com/npm/registry/blob/cfe04736f34db9274a780184d1cdb2fb3e4ead2a/docs/responses/package-metadata.md#package-metadata\n */\nconst NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER =\n\t\"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*\";\n\n/**\n * A minimally defined codec for NPM registry package metadata. Only data needed\n * for version detection is defined.\n */\nconst NPMRegistryPackageMetadataCodec = t.type({\n\tversions: t.UnknownRecord,\n});\n\ntype FetchNPMPackageVersionsArgs = {\n\tpackageName: string;\n};\n\nexport const fetchNPMPackageVersions = async (\n\targs: FetchNPMPackageVersionsArgs,\n): Promise<string[]> => {\n\tconst res = await fetch(`https://registry.npmjs.org/${args.packageName}`, {\n\t\theaders: {\n\t\t\tAccept: NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER,\n\t\t},\n\t});\n\n\tconst json = await res.json();\n\n\tconst { value, error } = decode(NPMRegistryPackageMetadataCodec, json);\n\n\tif (error) {\n\t\tthrow new Error(`Invalid NPM registry response.`, { cause: error });\n\t}\n\n\treturn Object.keys(value.versions);\n};\n"],"names":[],"mappings":";;;AAYA,MAAM,kDACL;AAMD,MAAM,kCAAkC,EAAE,KAAK;AAAA,EAC9C,UAAU,EAAE;AACZ,CAAA;AAMY,MAAA,0BAA0B,OACtC,SACsB;AACtB,QAAM,MAAM,MAAM,MAAM,8BAA8B,KAAK,
|
1
|
+
{"version":3,"file":"fetchNPMPackageVersions.js","sources":["../../../src/lib/fetchNPMPackageVersions.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport fetch from \"./fetch\";\n\nimport { decode } from \"./decode\";\n\n/**\n * The Accept header value used when only metadata required for package\n * installation is needed. The response includes all versions and some of their\n * metadata.\n *\n * @see https://github.com/npm/registry/blob/cfe04736f34db9274a780184d1cdb2fb3e4ead2a/docs/responses/package-metadata.md#package-metadata\n */\nconst NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER =\n\t\"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*\";\n\n/**\n * A minimally defined codec for NPM registry package metadata. Only data needed\n * for version detection is defined.\n */\nconst NPMRegistryPackageMetadataCodec = t.type({\n\tversions: t.UnknownRecord,\n});\n\ntype FetchNPMPackageVersionsArgs = {\n\tpackageName: string;\n};\n\nexport const fetchNPMPackageVersions = async (\n\targs: FetchNPMPackageVersionsArgs,\n): Promise<string[]> => {\n\tconst res = await fetch(`https://registry.npmjs.org/${args.packageName}`, {\n\t\theaders: {\n\t\t\tAccept: NPM_REGISTRY_ABBREVIATED_METADATA_ACCEPT_HEADER,\n\t\t},\n\t});\n\n\tconst json = await res.json();\n\n\tconst { value, error } = decode(NPMRegistryPackageMetadataCodec, json);\n\n\tif (error) {\n\t\tthrow new Error(`Invalid NPM registry response.`, { cause: error });\n\t}\n\n\treturn Object.keys(value.versions);\n};\n"],"names":[],"mappings":";;;AAYA,MAAM,kDACL;AAMD,MAAM,kCAAkC,EAAE,KAAK;AAAA,EAC9C,UAAU,EAAE;AACZ,CAAA;AAMY,MAAA,0BAA0B,OACtC,SACsB;AACtB,QAAM,MAAM,MAAM,MAAM,8BAA8B,KAAK,WAAW,IAAI;AAAA,IACzE,SAAS;AAAA,MACR,QAAQ;AAAA,IACR;AAAA,EAAA,CACD;AAEK,QAAA,OAAO,MAAM,IAAI;AAEvB,QAAM,EAAE,OAAO,MAAA,IAAU,OAAO,iCAAiC,IAAI;AAErE,MAAI,OAAO;AACV,UAAM,IAAI,MAAM,kCAAkC,EAAE,OAAO,OAAO;AAAA,EACnE;AAEO,SAAA,OAAO,KAAK,MAAM,QAAQ;AAClC;"}
|
@@ -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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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"],"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,sBAAsBA,yBAAAA;AAEtB,SAAA,OAAO,IAAIC,YAAA,YAAY,IAAI;AAC3B,SAAA,oBAAoB,IAAIC,yBAAA,yBAAyB,IAAI;AAErD,SAAA,UAAU,IAAIC,eAAA,eAAe,MAAM;AAAA,MAC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,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
|
+
{"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,sBAAsBA,yBAAAA;AAEtB,SAAA,OAAO,IAAIC,YAAA,YAAY,IAAI;AAC3B,SAAA,oBAAoB,IAAIC,yBAAA,yBAAyB,IAAI;AAErD,SAAA,UAAU,IAAIC,eAAA,eAAe,MAAM;AAAA,MACvC,eAAe,6BAAM;AAAA,IAAA,CACrB;AAEI,SAAA,UAAU,IAAIC,eAAA,eAAe,IAAI;AACjC,SAAA,cAAc,IAAIC,mBAAA,mBAAmB,IAAI;AACzC,SAAA,SAAS,IAAIC,cAAA,cAAc,IAAI;AAC/B,SAAA,WAAW,IAAIC,gBAAA,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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,IAAI;AAC7C,SAAA,uBAAuB,IAAI,4BAA4B,IAAI;AAE3D,SAAA,WAAW,IAAI,gBAAgB,IAAI;AAEnC,SAAA,YAAY,IAAI,iBAAiB,IAAI;AAErC,SAAA,MAAM,IAAI,WAAW,IAAI;AAE9B,SAAK,OAAM,6BAAM,QAAO,QAAQ,IAAG;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,8BAA2B;AAC1B,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,wBAAqB;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,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":["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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H,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":"CustomTypesManager.cjs","sources":["../../../../src/managers/customTypes/CustomTypesManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tCustomType,\n\tGroup,\n\tNestableWidget,\n\tNestedGroup,\n\tSharedSlice,\n\tUID,\n\ttraverseCustomType,\n\ttraverseSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport {\n\tCallHookReturnType,\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tCustomTypeReadHookData,\n\tCustomTypeRenameHook,\n\tCustomTypeRenameHookData,\n\tCustomTypeUpdateHook,\n\tCustomTypeUpdateHookData,\n\tHookError,\n} from \"@slicemachine/plugin-kit\";\nimport { z } from \"zod\";\n\nimport { DecodeError } from \"../../lib/DecodeError\";\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decodeHookResult } from \"../../lib/decodeHookResult\";\nimport fetch from \"../../lib/fetch\";\n\nimport { OnlyHookErrors } from \"../../types\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { UnauthorizedError } from \"../../errors\";\n\nimport { BaseManager } from \"../BaseManager\";\nimport { CustomTypeFormat } from \"./types\";\n\ntype SliceMachineManagerReadCustomTypeLibraryReturnType = {\n\tids: string[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesManagerReadAllCustomTypesArgs = {\n\tformat: CustomTypeFormat;\n};\n\ntype SliceMachineManagerReadAllCustomTypeReturnType = {\n\tmodels: { model: CustomType }[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadCustomTypeReturnType = {\n\tmodel: CustomType | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerPushCustomTypeArgs = {\n\tid: string;\n\tuserAgent?: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType = {\n\t// TODO\n\tmocksConfig?: Record<string, unknown>;\n\terrors: HookError[];\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n\t// TODO\n\tmocksConfig: Record<string, unknown>;\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType = {\n\terrors: HookError[];\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeArgs = {\n\tid: string;\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesMachineManagerUpdateCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypeFieldIdChangedMeta = {\n\tpreviousPath: string[];\n\tnewPath: string[];\n};\n\ntype CrCustomType =\n\t| string\n\t| { id: string; fields?: readonly CrCustomTypeNestedCr[] };\ntype CrCustomTypeNestedCr =\n\t| string\n\t| { id: string; customtypes: readonly CrCustomTypeFieldLeaf[] };\ntype CrCustomTypeFieldLeaf =\n\t| string\n\t| { id: string; fields?: readonly string[] };\n\nexport class CustomTypesManager extends BaseManager {\n\tasync readCustomTypeLibrary(): Promise<SliceMachineManagerReadCustomTypeLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type-library:read\",\n\t\t\tundefined,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tids: t.array(t.string),\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tids: data[0]?.ids || [],\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync readAllCustomTypes(\n\t\targs?: CustomTypesManagerReadAllCustomTypesArgs,\n\t): Promise<SliceMachineManagerReadAllCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst res: SliceMachineManagerReadAllCustomTypeReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tconst { ids, errors } = await this.readCustomTypeLibrary();\n\t\tres.errors = [...res.errors, ...errors];\n\n\t\tif (ids) {\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst { model, errors } = await this.readCustomType({ id });\n\t\t\t\tres.errors = [...res.errors, ...errors];\n\n\t\t\t\tif (model && (!args || args.format === model.format)) {\n\t\t\t\t\tres.models.push({ model });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync createCustomType(\n\t\targs: CustomTypeCreateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeCreateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:create\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync readCustomType(\n\t\targs: CustomTypeReadHookData,\n\t): Promise<SliceMachineManagerReadCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tmodel: CustomType,\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tmodel: data[0]?.model,\n\t\t\terrors,\n\t\t};\n\t}\n\n\t/**\n\t * Update the Content Relationship API IDs for all existing custom types and\n\t * slices. The change is determined by properties inside the `updateMeta`\n\t * property.\n\t */\n\tprivate async updateContentRelationships(\n\t\targs: { model: CustomType } & CustomTypeFieldIdChangedMeta,\n\t): Promise<\n\t\tOnlyHookErrors<CallHookReturnType<CustomTypeUpdateHook>> & {\n\t\t\trollback?: () => Promise<void>;\n\t\t}\n\t> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model } = args;\n\t\tlet { newPath, previousPath } = args;\n\n\t\tif (previousPath.join(\".\") !== newPath.join(\".\")) {\n\t\t\tpreviousPath = [model.id, ...previousPath];\n\t\t\tnewPath = [model.id, ...newPath];\n\n\t\t\tconst crUpdates: {\n\t\t\t\tupdatePromise: Promise<{ errors: HookError[] }>;\n\t\t\t\trollback: () => void;\n\t\t\t}[] = [];\n\n\t\t\t// Find existing content relationships that link to the renamed field id in\n\t\t\t// any custom type and update them to use the new one.\n\t\t\tconst customTypes = await this.readAllCustomTypes();\n\n\t\t\tupdateCustomTypeContentRelationships({\n\t\t\t\tmodels: customTypes.models,\n\t\t\t\tonUpdate: ({ previousModel, model: updatedModel }) => {\n\t\t\t\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t\t\t\tcrUpdates.push({\n\t\t\t\t\t\tupdatePromise: this.sliceMachinePluginRunner?.callHook(\n\t\t\t\t\t\t\t\"custom-type:update\",\n\t\t\t\t\t\t\t{ model: updatedModel },\n\t\t\t\t\t\t),\n\t\t\t\t\t\trollback: () => {\n\t\t\t\t\t\t\tthis.sliceMachinePluginRunner?.callHook(\"custom-type:update\", {\n\t\t\t\t\t\t\t\tmodel: previousModel,\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\tpreviousPath,\n\t\t\t\tnewPath,\n\t\t\t});\n\n\t\t\t// Find existing slice with content relationships that link to the renamed\n\t\t\t// field id in all libraries and update them to use the new one.\n\t\t\tconst { libraries } = await this.slices.readAllSliceLibraries();\n\n\t\t\tfor (const library of libraries) {\n\t\t\t\tconst slices = await this.slices.readAllSlicesForLibrary({\n\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t});\n\n\t\t\t\tupdateSharedSliceContentRelationships({\n\t\t\t\t\tmodels: slices.models,\n\t\t\t\t\tonUpdate: ({ previousModel, model: updatedModel }) => {\n\t\t\t\t\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t\t\t\t\tcrUpdates.push({\n\t\t\t\t\t\t\tupdatePromise: this.sliceMachinePluginRunner?.callHook(\n\t\t\t\t\t\t\t\t\"slice:update\",\n\t\t\t\t\t\t\t\t{ libraryID: library.libraryID, model: updatedModel },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\trollback: () => {\n\t\t\t\t\t\t\t\tthis.sliceMachinePluginRunner?.callHook(\"slice:update\", {\n\t\t\t\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t\t\t\t\tmodel: previousModel,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Process all the Content Relationship updates at once.\n\t\t\tconst crUpdatesResult = await Promise.all(\n\t\t\t\tcrUpdates.map((update) => update.updatePromise),\n\t\t\t);\n\n\t\t\tif (crUpdatesResult.some((result) => result.errors.length > 0)) {\n\t\t\t\treturn {\n\t\t\t\t\terrors: crUpdatesResult.flatMap((result) => result.errors),\n\t\t\t\t\trollback: async () => {\n\t\t\t\t\t\tawait Promise.all(crUpdates.map((update) => update.rollback()));\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn { errors: [] };\n\t}\n\n\tasync updateCustomType(\n\t\targs: CustomTypeUpdateHookData,\n\t): Promise<CustomTypesMachineManagerUpdateCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\t\tconst { model } = args;\n\t\tconst { fieldIdChanged } = args.updateMeta ?? {};\n\n\t\tlet previousCustomType: CustomType | undefined;\n\n\t\tif (fieldIdChanged) {\n\t\t\tconst customTypeRead = await this.readCustomType({ id: model.id });\n\n\t\t\tif (customTypeRead.errors.length > 0) {\n\t\t\t\treturn { errors: customTypeRead.errors };\n\t\t\t}\n\t\t\tif (!customTypeRead.model) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`readCustomType succeeded reading custom type ${model.id} but model is undefined.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpreviousCustomType = customTypeRead.model;\n\t\t}\n\n\t\tconst customTypeUpdateResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:update\",\n\t\t\t{ model },\n\t\t);\n\n\t\tif (customTypeUpdateResult.errors.length > 0) {\n\t\t\treturn { errors: customTypeUpdateResult.errors };\n\t\t}\n\n\t\tif (previousCustomType && fieldIdChanged) {\n\t\t\tconst crUpdateResult = await this.updateContentRelationships({\n\t\t\t\t...fieldIdChanged,\n\t\t\t\tmodel: previousCustomType,\n\t\t\t});\n\n\t\t\tif (crUpdateResult.errors.length > 0) {\n\t\t\t\t// put the previous custom type back\n\t\t\t\tawait this.sliceMachinePluginRunner?.callHook(\"custom-type:update\", {\n\t\t\t\t\tmodel: previousCustomType,\n\t\t\t\t});\n\t\t\t\t// revert the content relationships updates\n\t\t\t\tawait crUpdateResult.rollback?.();\n\n\t\t\t\treturn { errors: crUpdateResult.errors };\n\t\t\t}\n\t\t}\n\n\t\treturn { errors: [] };\n\t}\n\n\tasync renameCustomType(\n\t\targs: CustomTypeRenameHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeRenameHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:rename\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync deleteCustomType(\n\t\targs: CustomTypesMachineManagerDeleteCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerDeleteCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readCustomTypeErrors } = await this.readCustomType({\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\t\"custom-type:delete\",\n\t\t\t\t{ model },\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readCustomTypeErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync pushCustomType(\n\t\targs: SliceMachineManagerPushCustomTypeArgs,\n\t): Promise<void> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t// TODO: Handle errors\n\t\tconst { model } = await this.readCustomType({ id: args.id });\n\n\t\tif (model) {\n\t\t\t// TODO: Create a single shared client.\n\t\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\t\trepositoryName,\n\t\t\t\ttoken: authenticationToken,\n\t\t\t\tfetch,\n\t\t\t\tfetchOptions: {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\t// Check if Custom Type already exists on the repository.\n\t\t\t\tawait client.getCustomTypeByID(args.id);\n\n\t\t\t\t// If it exists on the repository, update it.\n\t\t\t\tawait client.updateCustomType(model);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof prismicCustomTypesClient.NotFoundError) {\n\t\t\t\t\t// If it doesn't exist on the repository, insert it.\n\t\t\t\t\tawait client.insertCustomType(model);\n\t\t\t\t} else if (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\"You do not have access to push types to this Prismic repository.\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync readCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerReadCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:read\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tassetID: \"mocks.config.json\",\n\t\t\t},\n\t\t);\n\t\tconst data = hookResult.data[0]?.data;\n\n\t\t// TODO: Validate the returned data.\n\n\t\tif (data) {\n\t\t\treturn {\n\t\t\t\tmocksConfig: JSON.parse(data.toString()),\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tmocksConfig: undefined,\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync updateCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerUpdateCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:update\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: \"mocks.config.json\",\n\t\t\t\t\tdata: Buffer.from(JSON.stringify(args.mocksConfig, null, \"\\t\")),\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync fetchRemoteCustomTypes(): Promise<CustomType[]> {\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\trepositoryName,\n\t\t\ttoken: authenticationToken,\n\t\t\tfetch,\n\t\t\tfetchOptions: {\n\t\t\t\theaders: {\n\t\t\t\t\t\"User-Agent\": SLICE_MACHINE_USER_AGENT,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\treturn await client.getAllCustomTypes();\n\t}\n\n\tasync inferSlice({\n\t\timageUrl,\n\t}: {\n\t\timageUrl: string;\n\t}): Promise<InferSliceResponse> {\n\t\tconst authToken = await this.user.getAuthenticationToken();\n\t\tconst headers = {\n\t\t\tAuthorization: `Bearer ${authToken}`,\n\t\t};\n\n\t\tconst repository = await this.project.getResolvedRepositoryName();\n\t\tconst searchParams = new URLSearchParams({\n\t\t\trepository,\n\t\t});\n\n\t\tconst url = new URL(\"./slices/infer\", API_ENDPOINTS.CustomTypeService);\n\t\turl.search = searchParams.toString();\n\n\t\tconst response = await fetch(url.toString(), {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: headers,\n\t\t\tbody: JSON.stringify({ imageUrl }),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`Failed to infer slice: ${response.statusText}`);\n\t\t}\n\n\t\tconst json = await response.json();\n\n\t\treturn InferSliceResponse.parse(json);\n\t}\n}\n\ntype InferSliceResponse = z.infer<typeof InferSliceResponse>;\n\nconst InferSliceResponse = z.object({\n\tslice: z.custom().transform((value, ctx) => {\n\t\tconst result = SharedSlice.decode(value);\n\t\tif (result._tag === \"Right\") {\n\t\t\treturn result.right;\n\t\t}\n\t\tctx.addIssue({\n\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\tmessage: `Invalid shared slice: ${JSON.stringify(value, null, 2)}`,\n\t\t});\n\n\t\treturn z.NEVER;\n\t}),\n\tlangSmithUrl: z.string().url().optional(),\n});\n\nfunction updateCRCustomType(\n\targs: { customType: CrCustomType } & CustomTypeFieldIdChangedMeta,\n): CrCustomType {\n\tconst [previousCustomTypeId, previousFieldId] = args.previousPath;\n\tconst [newCustomTypeId, newFieldId] = args.newPath;\n\n\tif (!previousCustomTypeId || !newCustomTypeId) {\n\t\tthrow new Error(\n\t\t\t\"Could not find a customtype id in previousPath and/or newPath, which should not be possible.\",\n\t\t);\n\t}\n\n\tif (!previousFieldId || !newFieldId) {\n\t\tthrow new Error(\n\t\t\t\"Could not find a field id in previousPath and/or newPath, which should not be possible.\",\n\t\t);\n\t}\n\n\tconst customType = shallowCloneIfObject(args.customType);\n\n\tif (typeof customType === \"string\" || !customType.fields) {\n\t\treturn customType;\n\t}\n\n\tconst matchedCustomTypeId = customType.id === previousCustomTypeId;\n\n\tconst newFields = customType.fields.map((fieldArg) => {\n\t\tconst customTypeField = shallowCloneIfObject(fieldArg);\n\n\t\tif (typeof customTypeField === \"string\") {\n\t\t\tif (\n\t\t\t\tmatchedCustomTypeId &&\n\t\t\t\tcustomTypeField === previousFieldId &&\n\t\t\t\tcustomTypeField !== newFieldId\n\t\t\t) {\n\t\t\t\t// We have reached a field id that matches the id that was renamed,\n\t\t\t\t// so we update it new one. The field is a string, so return the new\n\t\t\t\t// id.\n\t\t\t\treturn newFieldId;\n\t\t\t}\n\n\t\t\treturn customTypeField;\n\t\t}\n\n\t\tif (\n\t\t\tmatchedCustomTypeId &&\n\t\t\tcustomTypeField.id === previousFieldId &&\n\t\t\tcustomTypeField.id !== newFieldId\n\t\t) {\n\t\t\t// We have reached a field id that matches the id that was renamed,\n\t\t\t// so we update it new one.\n\t\t\t// Since field is not a string, we don't exit, as we might have\n\t\t\t// something to update further down in customtypes.\n\t\t\tcustomTypeField.id = newFieldId;\n\t\t}\n\n\t\treturn {\n\t\t\t...customTypeField,\n\t\t\tcustomtypes: customTypeField.customtypes.map((customTypeArg) => {\n\t\t\t\tconst nestedCustomType = shallowCloneIfObject(customTypeArg);\n\n\t\t\t\tif (\n\t\t\t\t\ttypeof nestedCustomType === \"string\" ||\n\t\t\t\t\t!nestedCustomType.fields ||\n\t\t\t\t\t// Since we are on the last level, if we don't start matching right\n\t\t\t\t\t// at the custom type id, we can return exit early because it's not\n\t\t\t\t\t// a match.\n\t\t\t\t\tnestedCustomType.id !== previousCustomTypeId\n\t\t\t\t) {\n\t\t\t\t\treturn nestedCustomType;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...nestedCustomType,\n\t\t\t\t\tfields: nestedCustomType.fields.map((fieldArg) => {\n\t\t\t\t\t\tconst nestedCustomTypeField = shallowCloneIfObject(fieldArg);\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnestedCustomTypeField === previousFieldId &&\n\t\t\t\t\t\t\tnestedCustomTypeField !== newFieldId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// Matches the previous id, so we update it and return because\n\t\t\t\t\t\t\t// it's the last level.\n\t\t\t\t\t\t\treturn newFieldId;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nestedCustomTypeField;\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t}),\n\t\t};\n\t});\n\n\treturn { ...customType, fields: newFields };\n}\n\n/**\n * Update the Content Relationship API IDs of a single field. The change is\n * determined by the `previousPath` and `newPath` properties.\n */\nfunction updateFieldContentRelationships<\n\tT extends UID | NestableWidget | Group | NestedGroup,\n>(args: { field: T } & CustomTypeFieldIdChangedMeta): T {\n\tconst { field, ...updateMeta } = args;\n\tif (\n\t\tfield.type !== \"Link\" ||\n\t\tfield.config?.select !== \"document\" ||\n\t\t!field.config?.customtypes\n\t) {\n\t\t// not a content relationship field\n\t\treturn field;\n\t}\n\n\tconst newCustomTypes = field.config.customtypes.map((customType) => {\n\t\treturn updateCRCustomType({ customType, ...updateMeta });\n\t});\n\n\treturn {\n\t\t...field,\n\t\tconfig: { ...field.config, customtypes: newCustomTypes },\n\t};\n}\n\nexport function updateCustomTypeContentRelationships(\n\targs: {\n\t\tmodels: { model: CustomType }[];\n\t\tonUpdate: (model: { previousModel: CustomType; model: CustomType }) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const { model: customType } of models) {\n\t\tconst updatedCustomType = traverseCustomType({\n\t\t\tcustomType,\n\t\t\tonField: ({ field }) => {\n\t\t\t\treturn updateFieldContentRelationships({\n\t\t\t\t\tfield,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\n\t\tif (!isEqualModel(customType, updatedCustomType)) {\n\t\t\tonUpdate({ model: updatedCustomType, previousModel: customType });\n\t\t}\n\t}\n}\n\nexport function updateSharedSliceContentRelationships(\n\targs: {\n\t\tmodels: { model: SharedSlice }[];\n\t\tonUpdate: (model: {\n\t\t\tpreviousModel: SharedSlice;\n\t\t\tmodel: SharedSlice;\n\t\t}) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const { model: slice } of models) {\n\t\tconst updateSlice = traverseSharedSlice({\n\t\t\tpath: [\".\"],\n\t\t\tslice,\n\t\t\tonField: ({ field }) => {\n\t\t\t\treturn updateFieldContentRelationships({\n\t\t\t\t\tfield,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\n\t\tif (!isEqualModel(slice, updateSlice)) {\n\t\t\tonUpdate({ model: updateSlice, previousModel: slice });\n\t\t}\n\t}\n}\n\nfunction isEqualModel<T extends CustomType | SharedSlice>(\n\tmodelA: T,\n\tmodelB: T,\n): boolean {\n\treturn JSON.stringify(modelA) === JSON.stringify(modelB);\n}\n\nfunction shallowCloneIfObject<T>(value: T): T {\n\tif (typeof value === \"object\") {\n\t\treturn { ...value };\n\t}\n\n\treturn value;\n}\n"],"names":["BaseManager","assertPluginsInitialized","errors","decodeHookResult","t","CustomType","_a","prismicCustomTypesClient","API_ENDPOINTS","fetch","SLICE_MACHINE_USER_AGENT","UnauthorizedError","z","SharedSlice","fieldArg","traverseCustomType","traverseSharedSlice"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6GM,MAAO,2BAA2BA,YAAAA,YAAW;AAAA,EAClD,MAAM,wBAAqB;;AAC1BC,sDAAyB,KAAK,wBAAwB;AAEtD,UAAM,aAAa,MAAM,KAAK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AAU,sCACf,MAMgC;AAEhC,QAAM,EAAE,QAAQ,cAAc,SAAS,aAAa;AAEpD,aAAW,EAAE,OAAO,MAAO,KAAI,QAAQ;AACtC,UAAM,cAAcC,YAAAA,oBAAoB;AAAA,MACvC,MAAM,CAAC,GAAG;AAAA,MACV;AAAA,MACA,SAAS,CAAC,EAAE,YAAW;AACtB,eAAO,gCAAgC;AAAA,UACtC;AAAA,UACA;AAAA,UACA;AAAA,QAAA,CACA;AAAA,MACF;AAAA,IAAA,CACA;AAED,QAAI,CAAC,aAAa,OAAO,WAAW,GAAG;AACtC,eAAS,EAAE,OAAO,aAAa,eAAe,MAAO,CAAA;AAAA,IACtD;AAAA,EACD;AACD;AAEA,SAAS,aACR,QACA,QAAS;AAET,SAAO,KAAK,UAAU,MAAM,MAAM,KAAK,UAAU,MAAM;AACxD;AAEA,SAAS,qBAAwB,OAAQ;AACpC,MAAA,OAAO,UAAU,UAAU;AACvB,WAAA,EAAE,GAAG;EACb;AAEO,SAAA;AACR;;;;"}
|
1
|
+
{"version":3,"file":"CustomTypesManager.cjs","sources":["../../../../src/managers/customTypes/CustomTypesManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tCustomType,\n\tGroup,\n\tNestableWidget,\n\tNestedGroup,\n\tSharedSlice,\n\tUID,\n\ttraverseCustomType,\n\ttraverseSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport {\n\tCallHookReturnType,\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tCustomTypeReadHookData,\n\tCustomTypeRenameHook,\n\tCustomTypeRenameHookData,\n\tCustomTypeUpdateHook,\n\tCustomTypeUpdateHookData,\n\tHookError,\n} from \"@slicemachine/plugin-kit\";\nimport { z } from \"zod\";\n\nimport { DecodeError } from \"../../lib/DecodeError\";\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decodeHookResult } from \"../../lib/decodeHookResult\";\nimport fetch from \"../../lib/fetch\";\n\nimport { OnlyHookErrors } from \"../../types\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { UnauthorizedError } from \"../../errors\";\n\nimport { BaseManager } from \"../BaseManager\";\nimport { CustomTypeFormat } from \"./types\";\n\ntype SliceMachineManagerReadCustomTypeLibraryReturnType = {\n\tids: string[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesManagerReadAllCustomTypesArgs = {\n\tformat: CustomTypeFormat;\n};\n\ntype SliceMachineManagerReadAllCustomTypeReturnType = {\n\tmodels: { model: CustomType }[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadCustomTypeReturnType = {\n\tmodel: CustomType | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerPushCustomTypeArgs = {\n\tid: string;\n\tuserAgent?: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType = {\n\t// TODO\n\tmocksConfig?: Record<string, unknown>;\n\terrors: HookError[];\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n\t// TODO\n\tmocksConfig: Record<string, unknown>;\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType = {\n\terrors: HookError[];\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeArgs = {\n\tid: string;\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesMachineManagerUpdateCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypeFieldIdChangedMeta = {\n\tpreviousPath: string[];\n\tnewPath: string[];\n};\n\ntype CrCustomType =\n\t| string\n\t| { id: string; fields?: readonly CrCustomTypeNestedCr[] };\ntype CrCustomTypeNestedCr =\n\t| string\n\t| { id: string; customtypes: readonly CrCustomTypeFieldLeaf[] };\ntype CrCustomTypeFieldLeaf =\n\t| string\n\t| { id: string; fields?: readonly string[] };\n\nexport class CustomTypesManager extends BaseManager {\n\tasync readCustomTypeLibrary(): Promise<SliceMachineManagerReadCustomTypeLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type-library:read\",\n\t\t\tundefined,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tids: t.array(t.string),\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tids: data[0]?.ids || [],\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync readAllCustomTypes(\n\t\targs?: CustomTypesManagerReadAllCustomTypesArgs,\n\t): Promise<SliceMachineManagerReadAllCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst res: SliceMachineManagerReadAllCustomTypeReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tconst { ids, errors } = await this.readCustomTypeLibrary();\n\t\tres.errors = [...res.errors, ...errors];\n\n\t\tif (ids) {\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst { model, errors } = await this.readCustomType({ id });\n\t\t\t\tres.errors = [...res.errors, ...errors];\n\n\t\t\t\tif (model && (!args || args.format === model.format)) {\n\t\t\t\t\tres.models.push({ model });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync createCustomType(\n\t\targs: CustomTypeCreateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeCreateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:create\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync readCustomType(\n\t\targs: CustomTypeReadHookData,\n\t): Promise<SliceMachineManagerReadCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tmodel: CustomType,\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tmodel: data[0]?.model,\n\t\t\terrors,\n\t\t};\n\t}\n\n\t/**\n\t * Update the Content Relationship API IDs for all existing custom types and\n\t * slices. The change is determined by properties inside the `updateMeta`\n\t * property.\n\t */\n\tprivate async updateContentRelationships(\n\t\targs: { model: CustomType } & CustomTypeFieldIdChangedMeta,\n\t): Promise<\n\t\tOnlyHookErrors<CallHookReturnType<CustomTypeUpdateHook>> & {\n\t\t\trollback?: () => Promise<void>;\n\t\t}\n\t> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model } = args;\n\t\tlet { newPath, previousPath } = args;\n\n\t\tif (previousPath.join(\".\") !== newPath.join(\".\")) {\n\t\t\tpreviousPath = [model.id, ...previousPath];\n\t\t\tnewPath = [model.id, ...newPath];\n\n\t\t\tconst crUpdates: {\n\t\t\t\tupdatePromise: Promise<{ errors: HookError[] }>;\n\t\t\t\trollback: () => void;\n\t\t\t}[] = [];\n\n\t\t\t// Find existing content relationships that link to the renamed field id in\n\t\t\t// any custom type and update them to use the new one.\n\t\t\tconst customTypes = await this.readAllCustomTypes();\n\n\t\t\tupdateCustomTypeContentRelationships({\n\t\t\t\tmodels: customTypes.models,\n\t\t\t\tonUpdate: ({ previousModel, model: updatedModel }) => {\n\t\t\t\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t\t\t\tcrUpdates.push({\n\t\t\t\t\t\tupdatePromise: this.sliceMachinePluginRunner?.callHook(\n\t\t\t\t\t\t\t\"custom-type:update\",\n\t\t\t\t\t\t\t{ model: updatedModel },\n\t\t\t\t\t\t),\n\t\t\t\t\t\trollback: () => {\n\t\t\t\t\t\t\tthis.sliceMachinePluginRunner?.callHook(\"custom-type:update\", {\n\t\t\t\t\t\t\t\tmodel: previousModel,\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\tpreviousPath,\n\t\t\t\tnewPath,\n\t\t\t});\n\n\t\t\t// Find existing slice with content relationships that link to the renamed\n\t\t\t// field id in all libraries and update them to use the new one.\n\t\t\tconst { libraries } = await this.slices.readAllSliceLibraries();\n\n\t\t\tfor (const library of libraries) {\n\t\t\t\tconst slices = await this.slices.readAllSlicesForLibrary({\n\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t});\n\n\t\t\t\tupdateSharedSliceContentRelationships({\n\t\t\t\t\tmodels: slices.models,\n\t\t\t\t\tonUpdate: ({ previousModel, model: updatedModel }) => {\n\t\t\t\t\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t\t\t\t\tcrUpdates.push({\n\t\t\t\t\t\t\tupdatePromise: this.sliceMachinePluginRunner?.callHook(\n\t\t\t\t\t\t\t\t\"slice:update\",\n\t\t\t\t\t\t\t\t{ libraryID: library.libraryID, model: updatedModel },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\trollback: () => {\n\t\t\t\t\t\t\t\tthis.sliceMachinePluginRunner?.callHook(\"slice:update\", {\n\t\t\t\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t\t\t\t\tmodel: previousModel,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Process all the Content Relationship updates at once.\n\t\t\tconst crUpdatesResult = await Promise.all(\n\t\t\t\tcrUpdates.map((update) => update.updatePromise),\n\t\t\t);\n\n\t\t\tif (crUpdatesResult.some((result) => result.errors.length > 0)) {\n\t\t\t\treturn {\n\t\t\t\t\terrors: crUpdatesResult.flatMap((result) => result.errors),\n\t\t\t\t\trollback: async () => {\n\t\t\t\t\t\tawait Promise.all(crUpdates.map((update) => update.rollback()));\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn { errors: [] };\n\t}\n\n\tasync updateCustomType(\n\t\targs: CustomTypeUpdateHookData,\n\t): Promise<CustomTypesMachineManagerUpdateCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\t\tconst { model } = args;\n\t\tconst { fieldIdChanged } = args.updateMeta ?? {};\n\n\t\tlet previousCustomType: CustomType | undefined;\n\n\t\tif (fieldIdChanged) {\n\t\t\tconst customTypeRead = await this.readCustomType({ id: model.id });\n\n\t\t\tif (customTypeRead.errors.length > 0) {\n\t\t\t\treturn { errors: customTypeRead.errors };\n\t\t\t}\n\t\t\tif (!customTypeRead.model) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`readCustomType succeeded reading custom type ${model.id} but model is undefined.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpreviousCustomType = customTypeRead.model;\n\t\t}\n\n\t\tconst customTypeUpdateResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:update\",\n\t\t\t{ model },\n\t\t);\n\n\t\tif (customTypeUpdateResult.errors.length > 0) {\n\t\t\treturn { errors: customTypeUpdateResult.errors };\n\t\t}\n\n\t\tif (previousCustomType && fieldIdChanged) {\n\t\t\tconst crUpdateResult = await this.updateContentRelationships({\n\t\t\t\t...fieldIdChanged,\n\t\t\t\tmodel: previousCustomType,\n\t\t\t});\n\n\t\t\tif (crUpdateResult.errors.length > 0) {\n\t\t\t\t// put the previous custom type back\n\t\t\t\tawait this.sliceMachinePluginRunner?.callHook(\"custom-type:update\", {\n\t\t\t\t\tmodel: previousCustomType,\n\t\t\t\t});\n\t\t\t\t// revert the content relationships updates\n\t\t\t\tawait crUpdateResult.rollback?.();\n\n\t\t\t\treturn { errors: crUpdateResult.errors };\n\t\t\t}\n\t\t}\n\n\t\treturn { errors: [] };\n\t}\n\n\tasync renameCustomType(\n\t\targs: CustomTypeRenameHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeRenameHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:rename\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync deleteCustomType(\n\t\targs: CustomTypesMachineManagerDeleteCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerDeleteCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readCustomTypeErrors } = await this.readCustomType({\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\t\"custom-type:delete\",\n\t\t\t\t{ model },\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readCustomTypeErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync pushCustomType(\n\t\targs: SliceMachineManagerPushCustomTypeArgs,\n\t): Promise<void> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t// TODO: Handle errors\n\t\tconst { model } = await this.readCustomType({ id: args.id });\n\n\t\tif (model) {\n\t\t\t// TODO: Create a single shared client.\n\t\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\t\trepositoryName,\n\t\t\t\ttoken: authenticationToken,\n\t\t\t\tfetch,\n\t\t\t\tfetchOptions: {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\t// Check if Custom Type already exists on the repository.\n\t\t\t\tawait client.getCustomTypeByID(args.id);\n\n\t\t\t\t// If it exists on the repository, update it.\n\t\t\t\tawait client.updateCustomType(model);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof prismicCustomTypesClient.NotFoundError) {\n\t\t\t\t\t// If it doesn't exist on the repository, insert it.\n\t\t\t\t\tawait client.insertCustomType(model);\n\t\t\t\t} else if (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\"You do not have access to push types to this Prismic repository.\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync readCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerReadCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:read\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tassetID: \"mocks.config.json\",\n\t\t\t},\n\t\t);\n\t\tconst data = hookResult.data[0]?.data;\n\n\t\t// TODO: Validate the returned data.\n\n\t\tif (data) {\n\t\t\treturn {\n\t\t\t\tmocksConfig: JSON.parse(data.toString()),\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tmocksConfig: undefined,\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync updateCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerUpdateCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:update\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: \"mocks.config.json\",\n\t\t\t\t\tdata: Buffer.from(JSON.stringify(args.mocksConfig, null, \"\\t\")),\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync fetchRemoteCustomTypes(): Promise<CustomType[]> {\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\trepositoryName,\n\t\t\ttoken: authenticationToken,\n\t\t\tfetch,\n\t\t\tfetchOptions: {\n\t\t\t\theaders: {\n\t\t\t\t\t\"User-Agent\": SLICE_MACHINE_USER_AGENT,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\treturn await client.getAllCustomTypes();\n\t}\n\n\tasync inferSlice({\n\t\timageUrl,\n\t}: {\n\t\timageUrl: string;\n\t}): Promise<InferSliceResponse> {\n\t\tconst authToken = await this.user.getAuthenticationToken();\n\t\tconst headers = {\n\t\t\tAuthorization: `Bearer ${authToken}`,\n\t\t};\n\n\t\tconst repository = await this.project.getResolvedRepositoryName();\n\t\tconst searchParams = new URLSearchParams({\n\t\t\trepository,\n\t\t});\n\n\t\tconst url = new URL(\"./slices/infer\", API_ENDPOINTS.CustomTypeService);\n\t\turl.search = searchParams.toString();\n\n\t\tconst response = await fetch(url.toString(), {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: headers,\n\t\t\tbody: JSON.stringify({ imageUrl }),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`Failed to infer slice: ${response.statusText}`);\n\t\t}\n\n\t\tconst json = await response.json();\n\n\t\treturn InferSliceResponse.parse(json);\n\t}\n}\n\ntype InferSliceResponse = z.infer<typeof InferSliceResponse>;\n\nconst InferSliceResponse = z.object({\n\tslice: z.custom().transform((value, ctx) => {\n\t\tconst result = SharedSlice.decode(value);\n\t\tif (result._tag === \"Right\") {\n\t\t\treturn result.right;\n\t\t}\n\t\tctx.addIssue({\n\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\tmessage: `Invalid shared slice: ${JSON.stringify(value, null, 2)}`,\n\t\t});\n\n\t\treturn z.NEVER;\n\t}),\n\tlangSmithUrl: z.string().url().optional(),\n});\n\nfunction updateCRCustomType(\n\targs: { customType: CrCustomType } & CustomTypeFieldIdChangedMeta,\n): CrCustomType {\n\tconst [previousCustomTypeId, previousFieldId] = args.previousPath;\n\tconst [newCustomTypeId, newFieldId] = args.newPath;\n\n\tif (!previousCustomTypeId || !newCustomTypeId) {\n\t\tthrow new Error(\n\t\t\t\"Could not find a customtype id in previousPath and/or newPath, which should not be possible.\",\n\t\t);\n\t}\n\n\tif (!previousFieldId || !newFieldId) {\n\t\tthrow new Error(\n\t\t\t\"Could not find a field id in previousPath and/or newPath, which should not be possible.\",\n\t\t);\n\t}\n\n\tconst customType = shallowCloneIfObject(args.customType);\n\n\tif (typeof customType === \"string\" || !customType.fields) {\n\t\treturn customType;\n\t}\n\n\tconst matchedCustomTypeId = customType.id === previousCustomTypeId;\n\n\tconst newFields = customType.fields.map((fieldArg) => {\n\t\tconst customTypeField = shallowCloneIfObject(fieldArg);\n\n\t\tif (typeof customTypeField === \"string\") {\n\t\t\tif (\n\t\t\t\tmatchedCustomTypeId &&\n\t\t\t\tcustomTypeField === previousFieldId &&\n\t\t\t\tcustomTypeField !== newFieldId\n\t\t\t) {\n\t\t\t\t// We have reached a field id that matches the id that was renamed,\n\t\t\t\t// so we update it new one. The field is a string, so return the new\n\t\t\t\t// id.\n\t\t\t\treturn newFieldId;\n\t\t\t}\n\n\t\t\treturn customTypeField;\n\t\t}\n\n\t\tif (\n\t\t\tmatchedCustomTypeId &&\n\t\t\tcustomTypeField.id === previousFieldId &&\n\t\t\tcustomTypeField.id !== newFieldId\n\t\t) {\n\t\t\t// We have reached a field id that matches the id that was renamed,\n\t\t\t// so we update it new one.\n\t\t\t// Since field is not a string, we don't exit, as we might have\n\t\t\t// something to update further down in customtypes.\n\t\t\tcustomTypeField.id = newFieldId;\n\t\t}\n\n\t\treturn {\n\t\t\t...customTypeField,\n\t\t\tcustomtypes: customTypeField.customtypes.map((customTypeArg) => {\n\t\t\t\tconst nestedCustomType = shallowCloneIfObject(customTypeArg);\n\n\t\t\t\tif (\n\t\t\t\t\ttypeof nestedCustomType === \"string\" ||\n\t\t\t\t\t!nestedCustomType.fields ||\n\t\t\t\t\t// Since we are on the last level, if we don't start matching right\n\t\t\t\t\t// at the custom type id, we can return exit early because it's not\n\t\t\t\t\t// a match.\n\t\t\t\t\tnestedCustomType.id !== previousCustomTypeId\n\t\t\t\t) {\n\t\t\t\t\treturn nestedCustomType;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...nestedCustomType,\n\t\t\t\t\tfields: nestedCustomType.fields.map((fieldArg) => {\n\t\t\t\t\t\tconst nestedCustomTypeField = shallowCloneIfObject(fieldArg);\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnestedCustomTypeField === previousFieldId &&\n\t\t\t\t\t\t\tnestedCustomTypeField !== newFieldId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// Matches the previous id, so we update it and return because\n\t\t\t\t\t\t\t// it's the last level.\n\t\t\t\t\t\t\treturn newFieldId;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nestedCustomTypeField;\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t}),\n\t\t};\n\t});\n\n\treturn { ...customType, fields: newFields };\n}\n\n/**\n * Update the Content Relationship API IDs of a single field. The change is\n * determined by the `previousPath` and `newPath` properties.\n */\nfunction updateFieldContentRelationships<\n\tT extends UID | NestableWidget | Group | NestedGroup,\n>(args: { field: T } & CustomTypeFieldIdChangedMeta): T {\n\tconst { field, ...updateMeta } = args;\n\tif (\n\t\tfield.type !== \"Link\" ||\n\t\tfield.config?.select !== \"document\" ||\n\t\t!field.config?.customtypes\n\t) {\n\t\t// not a content relationship field\n\t\treturn field;\n\t}\n\n\tconst newCustomTypes = field.config.customtypes.map((customType) => {\n\t\treturn updateCRCustomType({ customType, ...updateMeta });\n\t});\n\n\treturn {\n\t\t...field,\n\t\tconfig: { ...field.config, customtypes: newCustomTypes },\n\t};\n}\n\nexport function updateCustomTypeContentRelationships(\n\targs: {\n\t\tmodels: { model: CustomType }[];\n\t\tonUpdate: (model: { previousModel: CustomType; model: CustomType }) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const { model: customType } of models) {\n\t\tconst updatedCustomType = traverseCustomType({\n\t\t\tcustomType,\n\t\t\tonField: ({ field }) => {\n\t\t\t\treturn updateFieldContentRelationships({\n\t\t\t\t\tfield,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\n\t\tif (!isEqualModel(customType, updatedCustomType)) {\n\t\t\tonUpdate({ model: updatedCustomType, previousModel: customType });\n\t\t}\n\t}\n}\n\nexport function updateSharedSliceContentRelationships(\n\targs: {\n\t\tmodels: { model: SharedSlice }[];\n\t\tonUpdate: (model: {\n\t\t\tpreviousModel: SharedSlice;\n\t\t\tmodel: SharedSlice;\n\t\t}) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const { model: slice } of models) {\n\t\tconst updateSlice = traverseSharedSlice({\n\t\t\tpath: [\".\"],\n\t\t\tslice,\n\t\t\tonField: ({ field }) => {\n\t\t\t\treturn updateFieldContentRelationships({\n\t\t\t\t\tfield,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\n\t\tif (!isEqualModel(slice, updateSlice)) {\n\t\t\tonUpdate({ model: updateSlice, previousModel: slice });\n\t\t}\n\t}\n}\n\nfunction isEqualModel<T extends CustomType | SharedSlice>(\n\tmodelA: T,\n\tmodelB: T,\n): boolean {\n\treturn JSON.stringify(modelA) === JSON.stringify(modelB);\n}\n\nfunction shallowCloneIfObject<T>(value: T): T {\n\tif (typeof value === \"object\") {\n\t\treturn { ...value };\n\t}\n\n\treturn value;\n}\n"],"names":["BaseManager","assertPluginsInitialized","errors","decodeHookResult","t","CustomType","_a","prismicCustomTypesClient","API_ENDPOINTS","fetch","SLICE_MACHINE_USER_AGENT","UnauthorizedError","z","SharedSlice","fieldArg","traverseCustomType","traverseSharedSlice"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6GM,MAAO,2BAA2BA,YAAAA,YAAW;AAAA,EAClD,MAAM,wBAAqB;;AAC1BC,sDAAyB,KAAK,wBAAwB;AAEtD,UAAM,aAAa,MAAM,KAAK,yBAAyB,SACtD,4BACA,MAAS;AAEV,UAAM,EAAE,MAAM,QAAAC,QAAA,IAAWC,iBAAAA,iBACxBC,aAAE,KAAK;AAAA,MACN,KAAKA,aAAE,MAAMA,aAAE,MAAM;AAAA,IAAA,CACrB,GACD,UAAU;AAGJ,WAAA;AAAA,MACN,OAAK,UAAK,CAAC,MAAN,mBAAS,QAAO,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