@slicemachine/manager 0.24.4-alpha.xru-kong-obelix-services.1 → 0.24.4-alpha.xru-poc-ai.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/constants/API_ENDPOINTS.cjs +6 -6
- package/dist/constants/API_ENDPOINTS.cjs.map +1 -1
- package/dist/constants/API_ENDPOINTS.js +6 -6
- package/dist/constants/API_ENDPOINTS.js.map +1 -1
- package/dist/managers/slices/SlicesManager.cjs +678 -0
- package/dist/managers/slices/SlicesManager.cjs.map +1 -1
- package/dist/managers/slices/SlicesManager.d.ts +11 -0
- package/dist/managers/slices/SlicesManager.js +678 -0
- package/dist/managers/slices/SlicesManager.js.map +1 -1
- package/package.json +5 -3
- package/src/constants/API_ENDPOINTS.ts +6 -6
- package/src/managers/slices/SlicesManager.ts +738 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SlicesManager.js","sources":["../../../../src/managers/slices/SlicesManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport { SharedSliceContent } from \"@prismicio/types-internal/lib/content\";\nimport { SliceComparator } from \"@prismicio/types-internal/lib/customtypes/diff\";\nimport {\n\tCompositeSlice,\n\tLegacySlice,\n\tSharedSlice,\n\tVariation,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport {\n\tCallHookReturnType,\n\tHookError,\n\tSliceAssetUpdateHook,\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceLibraryReadHookData,\n\tSliceReadHookData,\n\tSliceRenameHook,\n\tSliceRenameHookData,\n\tSliceUpdateHook,\n} from \"@slicemachine/plugin-kit\";\n\nimport { DecodeError } from \"../../lib/DecodeError\";\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { bufferCodec } from \"../../lib/bufferCodec\";\nimport { decodeHookResult } from \"../../lib/decodeHookResult\";\nimport { createContentDigest } from \"../../lib/createContentDigest\";\nimport { mockSlice } from \"../../lib/mockSlice\";\nimport fetch from \"../../lib/fetch\";\n\nimport { OnlyHookErrors } from \"../../types\";\nimport { DEFAULT_SLICE_SCREENSHOT_URL } from \"../../constants/DEFAULT_SLICE_SCREENSHOT_URL\";\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { UnauthenticatedError, UnauthorizedError } from \"../../errors\";\n\nimport { BaseManager } from \"../BaseManager\";\n\ntype SlicesManagerReadSliceLibraryReturnType = {\n\tsliceIDs: string[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SlicesManagerReadAllSliceLibrariesReturnType = {\n\tlibraries: {\n\t\tlibraryID: string;\n\t\tsliceIDs: string[] | undefined;\n\t}[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadAllSlicesForLibraryArgs = {\n\tlibraryID: string;\n};\n\ntype SliceMachineManagerUpdateSliceArgs = {\n\tlibraryID: string;\n\tmodel: SharedSlice;\n\tmocks?: SharedSliceContent[];\n};\n\ntype SliceMachineManagerReadAllSlicesForLibraryReturnType = {\n\tmodels: { model: SharedSlice }[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadAllSlicesReturnType = {\n\tmodels: {\n\t\tlibraryID: string;\n\t\tmodel: SharedSlice;\n\t}[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadSliceReturnType = {\n\tmodel: SharedSlice | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerPushSliceArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\tuserAgent?: string;\n};\n\nexport type SliceMachineManagerPushSliceReturnType = {\n\t/**\n\t * A record of Slice variation IDs mapped to uploaded screenshot URLs.\n\t */\n\tscreenshotURLs: Record<string, string> | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadSliceScreenshotArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\tvariationID: string;\n};\n\ntype SliceMachineManagerReadSliceScreenshotReturnType = {\n\tdata: Buffer | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerUpdateSliceScreenshotArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\tvariationID: string;\n\tdata: Buffer;\n};\n\ntype SliceMachineManagerDeleteSliceScreenshotArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\tvariationID: string;\n};\n\ntype SliceMachineManagerReadSliceMocksArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n};\n\ntype SliceMachineManagerReadSliceMocksReturnType = {\n\tmocks?: SharedSliceContent[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadSliceMocksConfigArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n};\n\ntype SliceMachineManagerReadSliceMocksConfigArgsReturnType = {\n\t// TODO\n\tmocksConfig?: Record<string, unknown>;\n\terrors: HookError[];\n};\n\ntype SliceMachineManagerUpdateSliceMocksArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\tmocks: SharedSliceContent[];\n};\n\ntype SliceMachineManagerUpdateSliceMocksArgsReturnType = {\n\terrors: HookError[];\n};\n\ntype SlicesManagerUpsertHostedSliceScrenshotsArgs = {\n\tlibraryID: string;\n\tmodel: SharedSlice;\n};\n\ntype SliceMachineManagerDeleteSliceArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n};\n\ntype SliceMachineManagerDeleteSliceReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerRenameSliceVariationArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\t/**\n\t * Current ID of the variation to rename.\n\t */\n\tvariationID: string;\n\tmodel: Variation;\n};\n\ntype SliceMachineManagerRenameSliceVariationReturnType = {\n\terrors: (DecodeError | HookError)[];\n\tassetsErrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerDeleteSliceVariationArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\tvariationID: string;\n};\n\ntype SliceMachineManagerDeleteSliceVariationReturnType = {\n\terrors: (DecodeError | HookError)[];\n\tassetsErrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerConvertLegacySliceToSharedSliceArgs = {\n\tmodel: CompositeSlice | LegacySlice;\n\tsrc: {\n\t\tcustomTypeID: string;\n\t\ttabID: string;\n\t\tsliceZoneID: string;\n\t\tsliceID: string;\n\t};\n\tdest: {\n\t\tlibraryID: string;\n\t\tsliceID: string;\n\t\tvariationName: string;\n\t\tvariationID: string;\n\t};\n};\n\ntype SliceMachineManagerConvertLegacySliceToSharedSliceReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\nexport class SlicesManager extends BaseManager {\n\tasync readSliceLibrary(\n\t\targs: SliceLibraryReadHookData,\n\t): Promise<SlicesManagerReadSliceLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t// TODO: Should validation happen at the `callHook` level?\n\t\t// Including validation at the hook level would ensure\n\t\t// hook-based actions are validated.\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice-library:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tid: t.string,\n\t\t\t\tsliceIDs: t.array(t.string),\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tsliceIDs: data[0]?.sliceIDs ?? [],\n\t\t\terrors: errors,\n\t\t};\n\t}\n\n\tasync readAllSliceLibraries(): Promise<SlicesManagerReadAllSliceLibrariesReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst sliceMachineConfig = await this.project.getSliceMachineConfig();\n\t\tconst libraryIDs = sliceMachineConfig.libraries || [];\n\n\t\tconst res: SlicesManagerReadAllSliceLibrariesReturnType = {\n\t\t\tlibraries: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tfor (const libraryID of libraryIDs) {\n\t\t\tconst { sliceIDs, errors } = await this.readSliceLibrary({\n\t\t\t\tlibraryID,\n\t\t\t});\n\t\t\tres.errors = [...res.errors, ...errors];\n\n\t\t\tres.libraries.push({\n\t\t\t\tlibraryID,\n\t\t\t\tsliceIDs,\n\t\t\t});\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync readAllSlicesForLibrary(\n\t\targs: SliceMachineManagerReadAllSlicesForLibraryArgs,\n\t): Promise<SliceMachineManagerReadAllSlicesForLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst res: SliceMachineManagerReadAllSlicesForLibraryReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tconst { sliceIDs, errors } = await this.readSliceLibrary({\n\t\t\tlibraryID: args.libraryID,\n\t\t});\n\t\tres.errors.push(...errors);\n\n\t\tif (sliceIDs) {\n\t\t\tfor (const sliceID of sliceIDs) {\n\t\t\t\tconst { model, errors } = await this.readSlice({\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tsliceID,\n\t\t\t\t});\n\t\t\t\tres.errors.push(...errors);\n\n\t\t\t\tif (model) {\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 readAllSlices(): Promise<SliceMachineManagerReadAllSlicesReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst sliceMachineConfig = await this.project.getSliceMachineConfig();\n\t\tconst libraryIDs = sliceMachineConfig.libraries || [];\n\n\t\tconst res: SliceMachineManagerReadAllSlicesReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tfor (const libraryID of libraryIDs) {\n\t\t\tconst { models, errors } = await this.readAllSlicesForLibrary({\n\t\t\t\tlibraryID,\n\t\t\t});\n\t\t\tres.errors.push(...errors);\n\n\t\t\tfor (const model of models) {\n\t\t\t\tres.models.push({\n\t\t\t\t\tlibraryID,\n\t\t\t\t\tmodel: model.model,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync createSlice(\n\t\targs: SliceCreateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<SliceCreateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:create\",\n\t\t\targs,\n\t\t);\n\n\t\tconst updateSliceMocksArgs: SliceMachineManagerUpdateSliceMocksArgs = {\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.model.id,\n\t\t\tmocks: mockSlice({ model: args.model }),\n\t\t};\n\n\t\tconst { errors: updateSliceHookErrors } =\n\t\t\tawait this.updateSliceMocks(updateSliceMocksArgs);\n\n\t\treturn {\n\t\t\terrors: [...hookResult.errors, ...updateSliceHookErrors],\n\t\t};\n\t}\n\n\tasync readSlice(\n\t\targs: SliceReadHookData,\n\t): Promise<SliceMachineManagerReadSliceReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tmodel: SharedSlice,\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: errors.map((error) => {\n\t\t\t\terror.message = `Failed to decode slice model with id '${args.sliceID}': ${error.message}`;\n\n\t\t\t\treturn error;\n\t\t\t}),\n\t\t};\n\t}\n\n\tasync updateSlice(\n\t\targs: SliceMachineManagerUpdateSliceArgs,\n\t): Promise<OnlyHookErrors<CallHookReturnType<SliceUpdateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { mocks: previousMocks } = await this.readSliceMocks({\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.model.id,\n\t\t});\n\t\tconst { model: previousModel } = await this.readSlice({\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.model.id,\n\t\t});\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:update\",\n\t\t\targs,\n\t\t);\n\n\t\tconst updatedMocks = mockSlice({\n\t\t\tmodel: args.model,\n\t\t\tmocks: previousMocks,\n\t\t\tdiff: SliceComparator.compare(previousModel, args.model),\n\t\t});\n\t\tconst updateSliceMocksArgs: SliceMachineManagerUpdateSliceMocksArgs = {\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.model.id,\n\t\t\tmocks: updatedMocks,\n\t\t};\n\n\t\tconst { errors: updateSliceMocksHookResult } =\n\t\t\tawait this.updateSliceMocks(updateSliceMocksArgs);\n\n\t\treturn {\n\t\t\terrors: [...hookResult.errors, ...updateSliceMocksHookResult],\n\t\t};\n\t}\n\n\tasync renameSlice(\n\t\targs: SliceRenameHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<SliceRenameHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice: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 deleteSlice(\n\t\targs: SliceMachineManagerDeleteSliceArgs,\n\t): Promise<SliceMachineManagerDeleteSliceReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readSliceErrors } = await this.readSlice({\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.sliceID,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst { errors: deleteSliceErrors } =\n\t\t\t\tawait this.sliceMachinePluginRunner.callHook(\"slice:delete\", {\n\t\t\t\t\tmodel,\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t});\n\n\t\t\t// Do not update custom types if slice deletion failed\n\t\t\tif (deleteSliceErrors.length > 0) {\n\t\t\t\treturn {\n\t\t\t\t\terrors: deleteSliceErrors,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { errors: updateCustomTypeErrors } =\n\t\t\t\tawait this._removeSliceFromCustomTypes(args.sliceID);\n\n\t\t\treturn {\n\t\t\t\terrors: updateCustomTypeErrors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readSliceErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync renameSliceVariation(\n\t\targs: SliceMachineManagerRenameSliceVariationArgs,\n\t): Promise<SliceMachineManagerRenameSliceVariationReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t// TODO: Remove when we support renaming variation ID, see: DT-1708\n\t\tif (args.variationID !== args.model.id) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Renaming variation ID is not supported yet by the backend, only rename its name! For more information, see: https://linear.app/prismic/issue/DT-1708\",\n\t\t\t);\n\t\t}\n\n\t\tconst { model, errors: readSliceErrors } = await this.readSlice({\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.sliceID,\n\t\t});\n\n\t\tif (model) {\n\t\t\t// Find and rename the variation\n\t\t\tconst updatedModel = {\n\t\t\t\t...model,\n\t\t\t\tvariations: model.variations.map((variation) => {\n\t\t\t\t\tif (variation.id === args.variationID) {\n\t\t\t\t\t\t// Matches the slice we want to rename\n\t\t\t\t\t\treturn args.model;\n\t\t\t\t\t} else if (variation.id === args.model.id) {\n\t\t\t\t\t\t// Matches any other slice that has the ID of the renamed variation and throw.\n\t\t\t\t\t\t// This should be validated on the frontend first for better UX, this is only backend validation.\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Cannot rename variation \\`${args.variationID}\\` to \\`${args.model.id}\\`. A variation already exists with that ID in slice \\`${args.sliceID}\\` from library \\`${args.libraryID}\\`, try deleting it first or choose another variation ID to rename that slice.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn variation;\n\t\t\t\t}),\n\t\t\t};\n\t\t\tconst updateSliceHookResult =\n\t\t\t\tawait this.sliceMachinePluginRunner.callHook(\"slice:update\", {\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tmodel: updatedModel,\n\t\t\t\t});\n\n\t\t\t// If variation ID has changed, we need to rename assets accordingly\n\t\t\tconst assetsErrors: (DecodeError<unknown> | HookError<unknown>)[] = [];\n\t\t\tif (args.variationID !== args.model.id) {\n\t\t\t\t// Renaming screenshot\n\t\t\t\tconst { data: screenshot, errors: readSliceScreenshotErrors } =\n\t\t\t\t\tawait this.readSliceScreenshot({\n\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\tsliceID: args.sliceID,\n\t\t\t\t\t\tvariationID: args.variationID,\n\t\t\t\t\t});\n\t\t\t\tassetsErrors.push(...readSliceScreenshotErrors);\n\n\t\t\t\tif (screenshot) {\n\t\t\t\t\t// Delete old ID screenshot\n\t\t\t\t\tconst { errors: deleteSliceScreenshotErrors } =\n\t\t\t\t\t\tawait this.deleteSliceScreenshot({\n\t\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\t\tsliceID: args.sliceID,\n\t\t\t\t\t\t\tvariationID: args.variationID,\n\t\t\t\t\t\t});\n\t\t\t\t\tassetsErrors.push(...deleteSliceScreenshotErrors);\n\n\t\t\t\t\t// Create new ID screenshot\n\t\t\t\t\tconst { errors: updateSliceScreenshotErrors } =\n\t\t\t\t\t\tawait this.updateSliceScreenshot({\n\t\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\t\tsliceID: args.sliceID,\n\t\t\t\t\t\t\tvariationID: args.model.id,\n\t\t\t\t\t\t\tdata: screenshot,\n\t\t\t\t\t\t});\n\t\t\t\t\tassetsErrors.push(...updateSliceScreenshotErrors);\n\t\t\t\t}\n\n\t\t\t\t// Renaming mocks\n\t\t\t\tconst { mocks, errors: readSliceMocksErrors } =\n\t\t\t\t\tawait this.readSliceMocks({\n\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\tsliceID: args.sliceID,\n\t\t\t\t\t});\n\t\t\t\tassetsErrors.push(...readSliceMocksErrors);\n\n\t\t\t\tif (mocks?.length) {\n\t\t\t\t\tconst { errors: updateSliceMocksErrors } =\n\t\t\t\t\t\tawait this.updateSliceMocks({\n\t\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\t\tsliceID: args.sliceID,\n\t\t\t\t\t\t\tmocks: mocks.map((mock) => {\n\t\t\t\t\t\t\t\tif (mock.variation === args.variationID) {\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t...mock,\n\t\t\t\t\t\t\t\t\t\tvariation: args.model.id,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn mock;\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t});\n\t\t\t\t\tassetsErrors.push(...updateSliceMocksErrors);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\terrors: updateSliceHookResult.errors,\n\t\t\t\tassetsErrors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readSliceErrors,\n\t\t\t\tassetsErrors: [],\n\t\t\t};\n\t\t}\n\t}\n\n\tasync deleteSliceVariation(\n\t\targs: SliceMachineManagerDeleteSliceVariationArgs,\n\t): Promise<SliceMachineManagerDeleteSliceVariationReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readSliceErrors } = await this.readSlice({\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.sliceID,\n\t\t});\n\n\t\tif (model) {\n\t\t\t// Remove variation from model and update it\n\t\t\tconst updatedModel = {\n\t\t\t\t...model,\n\t\t\t\tvariations: model.variations.filter(\n\t\t\t\t\t(variation) => variation.id !== args.variationID,\n\t\t\t\t),\n\t\t\t};\n\t\t\tconst updateSliceHookResult =\n\t\t\t\tawait this.sliceMachinePluginRunner.callHook(\"slice:update\", {\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tmodel: updatedModel,\n\t\t\t\t});\n\n\t\t\t// Cleanup deleted variation screenshot\n\t\t\tconst { errors: deleteSliceScreenshotErrors } =\n\t\t\t\tawait this.deleteSliceScreenshot(args);\n\n\t\t\t// Cleanup deleted variation mocks\n\t\t\tconst { mocks, errors: readSliceMocksErrors } = await this.readSliceMocks(\n\t\t\t\t{\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tsliceID: args.sliceID,\n\t\t\t\t},\n\t\t\t);\n\t\t\tlet updateSliceMocksErrors: SliceMachineManagerUpdateSliceMocksArgsReturnType[\"errors\"] =\n\t\t\t\t[];\n\t\t\tif (mocks?.length) {\n\t\t\t\tupdateSliceMocksErrors = (\n\t\t\t\t\tawait this.updateSliceMocks({\n\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\tsliceID: args.sliceID,\n\t\t\t\t\t\tmocks: mocks.filter((mock) => mock.variation !== args.variationID),\n\t\t\t\t\t})\n\t\t\t\t).errors;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\terrors: updateSliceHookResult.errors,\n\t\t\t\tassetsErrors: [\n\t\t\t\t\t...deleteSliceScreenshotErrors,\n\t\t\t\t\t...readSliceMocksErrors,\n\t\t\t\t\t...updateSliceMocksErrors,\n\t\t\t\t],\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readSliceErrors,\n\t\t\t\tassetsErrors: [],\n\t\t\t};\n\t\t}\n\t}\n\n\tasync convertLegacySliceToSharedSlice(\n\t\targs: SliceMachineManagerConvertLegacySliceToSharedSliceArgs,\n\t): Promise<SliceMachineManagerConvertLegacySliceToSharedSliceReturnType> {\n\t\tconst errors: (DecodeError | HookError)[] = [];\n\n\t\tconst { model: maybeExistingSlice } = await this.readSlice({\n\t\t\tlibraryID: args.dest.libraryID,\n\t\t\tsliceID: args.dest.sliceID,\n\t\t});\n\n\t\tconst legacySliceAsVariation: Variation = {\n\t\t\tid: args.dest.variationID,\n\t\t\tname: args.dest.variationName,\n\t\t\tdescription: args.dest.variationName,\n\t\t\timageUrl: \"\",\n\t\t\tdocURL: \"\",\n\t\t\tversion: \"initial\",\n\t\t\tprimary: {},\n\t\t\titems: {},\n\t\t};\n\n\t\tswitch (args.model.type) {\n\t\t\tcase \"Slice\":\n\t\t\t\tlegacySliceAsVariation.primary = args.model[\"non-repeat\"];\n\t\t\t\tlegacySliceAsVariation.items = args.model.repeat;\n\t\t\t\tbreak;\n\n\t\t\tcase \"Group\":\n\t\t\t\tlegacySliceAsVariation.items = args.model.config?.fields ?? {};\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tlegacySliceAsVariation.primary = { [args.src.sliceID]: args.model };\n\t\t\t\tbreak;\n\t\t}\n\n\t\t// Convert as a slice variation, or merge against an existing slice variation\n\t\tif (maybeExistingSlice) {\n\t\t\tconst maybeVariation = maybeExistingSlice.variations.find(\n\t\t\t\t(variation) => variation.id === args.dest.variationID,\n\t\t\t);\n\n\t\t\t// If we're not merging against an existing slice variation, then we need to insert the new variation\n\t\t\tif (!maybeVariation) {\n\t\t\t\tmaybeExistingSlice.variations = [\n\t\t\t\t\t...maybeExistingSlice.variations,\n\t\t\t\t\tlegacySliceAsVariation,\n\t\t\t\t];\n\t\t\t}\n\n\t\t\tmaybeExistingSlice.legacyPaths ||= {};\n\t\t\tmaybeExistingSlice.legacyPaths[\n\t\t\t\t`${args.src.customTypeID}::${args.src.sliceZoneID}::${args.src.sliceID}`\n\t\t\t] = args.dest.variationID;\n\n\t\t\tawait this.updateSlice({\n\t\t\t\tlibraryID: args.dest.libraryID,\n\t\t\t\tmodel: maybeExistingSlice,\n\t\t\t});\n\t\t} else {\n\t\t\t// Convert to new shared slice\n\t\t\tawait this.createSlice({\n\t\t\t\tlibraryID: args.dest.libraryID,\n\t\t\t\tmodel: {\n\t\t\t\t\tid: args.dest.sliceID,\n\t\t\t\t\ttype: \"SharedSlice\",\n\t\t\t\t\tname: args.dest.sliceID,\n\t\t\t\t\tlegacyPaths: {\n\t\t\t\t\t\t[`${args.src.customTypeID}::${args.src.sliceZoneID}::${args.src.sliceID}`]:\n\t\t\t\t\t\t\targs.dest.variationID,\n\t\t\t\t\t},\n\t\t\t\t\tvariations: [legacySliceAsVariation],\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Update source custom type\n\t\tconst { model: customType, errors: customTypeReadErrors } =\n\t\t\tawait this.customTypes.readCustomType({\n\t\t\t\tid: args.src.customTypeID,\n\t\t\t});\n\t\terrors.push(...customTypeReadErrors);\n\n\t\tif (customType) {\n\t\t\tconst field = customType.json[args.src.tabID][args.src.sliceZoneID];\n\n\t\t\t// Convert legacy slice definition in slice zone to shared slice reference\n\t\t\tif (field.type === \"Slices\" && field.config?.choices) {\n\t\t\t\tdelete field.config.choices[args.src.sliceID];\n\t\t\t\tfield.config.choices[args.dest.sliceID] = {\n\t\t\t\t\ttype: \"SharedSlice\",\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { errors: customTypeUpdateErrors } =\n\t\t\t\tawait this.customTypes.updateCustomType({ model: customType });\n\t\t\terrors.push(...customTypeUpdateErrors);\n\t\t}\n\n\t\treturn { errors };\n\t}\n\n\t/**\n\t * @returns Record of variation IDs mapped to uploaded screenshot URLs.\n\t */\n\tasync pushSlice(\n\t\targs: SliceMachineManagerPushSliceArgs,\n\t): Promise<SliceMachineManagerPushSliceReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tif (!(await this.user.checkIsLoggedIn())) {\n\t\t\tthrow new UnauthenticatedError();\n\t\t}\n\n\t\tconst { model, errors: readSliceErrors } = await this.readSlice({\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.sliceID,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst modelWithScreenshots =\n\t\t\t\tawait this.updateSliceModelScreenshotsInPlace({\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tmodel,\n\t\t\t\t});\n\n\t\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\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 Slice already exists on the repository.\n\t\t\t\tawait client.getSharedSliceByID(args.sliceID);\n\n\t\t\t\t// If it exists on the repository, update it.\n\t\t\t\tawait client.updateSharedSlice(modelWithScreenshots);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof prismicCustomTypesClient.NotFoundError) {\n\t\t\t\t\t// If the Slice doesn't exist on the repository, insert it.\n\t\t\t\t\tawait client.insertSharedSlice(modelWithScreenshots);\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 Slices to this Prismic repository.\",\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t// Pass the error through if it isn't the one we were expecting.\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst screenshotURLs: Record<string, string> = {};\n\t\t\tfor (const variation of modelWithScreenshots.variations) {\n\t\t\t\tscreenshotURLs[variation.id] = variation.imageUrl;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tscreenshotURLs,\n\t\t\t\terrors: readSliceErrors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tscreenshotURLs: undefined,\n\t\t\t\terrors: readSliceErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync readSliceScreenshot(\n\t\targs: SliceMachineManagerReadSliceScreenshotArgs,\n\t): Promise<SliceMachineManagerReadSliceScreenshotReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:asset:read\",\n\t\t\t{\n\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\tsliceID: args.sliceID,\n\t\t\t\tassetID: `screenshot-${args.variationID}.png`,\n\t\t\t},\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tdata: bufferCodec,\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tdata: data[0]?.data,\n\t\t\terrors: errors,\n\t\t};\n\t}\n\n\tasync updateSliceScreenshot(\n\t\targs: SliceMachineManagerUpdateSliceScreenshotArgs,\n\t): Promise<OnlyHookErrors<CallHookReturnType<SliceAssetUpdateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:asset:update\",\n\t\t\t{\n\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\tsliceID: args.sliceID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: `screenshot-${args.variationID}.png`,\n\t\t\t\t\tdata: args.data,\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 deleteSliceScreenshot(\n\t\targs: SliceMachineManagerDeleteSliceScreenshotArgs,\n\t): Promise<OnlyHookErrors<CallHookReturnType<SliceAssetUpdateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:asset:delete\",\n\t\t\t{\n\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\tsliceID: args.sliceID,\n\t\t\t\tassetID: `screenshot-${args.variationID}.png`,\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 readSliceMocks(\n\t\targs: SliceMachineManagerReadSliceMocksArgs,\n\t): Promise<SliceMachineManagerReadSliceMocksReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:asset:read\",\n\t\t\t{\n\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\tsliceID: args.sliceID,\n\t\t\t\tassetID: `mocks.json`,\n\t\t\t},\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tdata: t.array(SharedSliceContent),\n\t\t\t}),\n\t\t\t{\n\t\t\t\t...hookResult,\n\t\t\t\t// Convert the asset data from a Buffer to JSON\n\t\t\t\t// to prepare it for validation.\n\t\t\t\tdata: hookResult.data.map((result) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tdata: JSON.parse(result.data.toString()),\n\t\t\t\t\t\t};\n\t\t\t\t\t} catch {\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t},\n\t\t);\n\n\t\tif (data) {\n\t\t\treturn {\n\t\t\t\tmocks: data[0]?.data,\n\t\t\t\terrors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tmocks: [],\n\t\t\t\terrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync updateSliceMocks(\n\t\targs: SliceMachineManagerUpdateSliceMocksArgs,\n\t): Promise<SliceMachineManagerUpdateSliceMocksArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:asset:update\",\n\t\t\t{\n\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\tsliceID: args.sliceID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: \"mocks.json\",\n\t\t\t\t\tdata: Buffer.from(JSON.stringify(args.mocks, 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\t// TODO: Remove\n\tasync readSliceMocksConfig(\n\t\targs: SliceMachineManagerReadSliceMocksConfigArgs,\n\t): Promise<SliceMachineManagerReadSliceMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:asset:read\",\n\t\t\t{\n\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\tsliceID: args.sliceID,\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\tasync fetchRemoteSlices(): Promise<SharedSlice[]> {\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.getAllSharedSlices();\n\t}\n\n\tasync updateSliceModelScreenshotsInPlace(\n\t\targs: SlicesManagerUpsertHostedSliceScrenshotsArgs,\n\t): Promise<SharedSlice> {\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\tconst variations = await Promise.all(\n\t\t\targs.model.variations.map(async (variation) => {\n\t\t\t\tconst screenshot = await this.readSliceScreenshot({\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tsliceID: args.model.id,\n\t\t\t\t\tvariationID: variation.id,\n\t\t\t\t});\n\n\t\t\t\t// If there's no screenshot, delete it by replacing it with the default screenshot\n\t\t\t\tif (!screenshot.data) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...variation,\n\t\t\t\t\t\timageUrl: DEFAULT_SLICE_SCREENSHOT_URL,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst hasScreenshotChanged = !variation.imageUrl?.includes(\n\t\t\t\t\tcreateContentDigest(screenshot.data),\n\t\t\t\t);\n\n\t\t\t\t// If screenshot hasn't changed, do nothing\n\t\t\t\tif (!hasScreenshotChanged) {\n\t\t\t\t\treturn variation;\n\t\t\t\t}\n\n\t\t\t\tconst keyPrefix = [\n\t\t\t\t\trepositoryName,\n\t\t\t\t\t\"shared-slices\",\n\t\t\t\t\targs.model.id,\n\t\t\t\t\tvariation.id,\n\t\t\t\t].join(\"/\");\n\n\t\t\t\tconst uploadedScreenshot = await this.screenshots.uploadScreenshot({\n\t\t\t\t\tdata: screenshot.data,\n\t\t\t\t\tkeyPrefix,\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\t...variation,\n\t\t\t\t\timageUrl: uploadedScreenshot.url,\n\t\t\t\t};\n\t\t\t}),\n\t\t);\n\n\t\treturn {\n\t\t\t...args.model,\n\t\t\tvariations,\n\t\t};\n\t}\n\n\tprivate async _removeSliceFromCustomTypes(sliceID: string) {\n\t\tconst { models, errors: customTypeReadErrors } =\n\t\t\tawait this.customTypes.readAllCustomTypes();\n\n\t\t// Successfully update all custom types or throw\n\t\tawait Promise.all(\n\t\t\tmodels.map(async (customType) => {\n\t\t\t\tconst updatedJsonModel = Object.entries(customType.model.json).reduce(\n\t\t\t\t\t(tabAccumulator, [tabKey, tab]) => {\n\t\t\t\t\t\tconst updatedTabFields = Object.entries(tab).reduce(\n\t\t\t\t\t\t\t(fieldAccumulator, [fieldKey, field]) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tfield.config === undefined ||\n\t\t\t\t\t\t\t\t\tfield.type !== \"Slices\" ||\n\t\t\t\t\t\t\t\t\tfield.config.choices === undefined\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn { ...fieldAccumulator, [fieldKey]: field };\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst filteredChoices = Object.entries(\n\t\t\t\t\t\t\t\t\tfield.config.choices,\n\t\t\t\t\t\t\t\t).reduce((choiceAccumulator, [choiceKey, choice]) => {\n\t\t\t\t\t\t\t\t\tif (choiceKey === sliceID) {\n\t\t\t\t\t\t\t\t\t\treturn choiceAccumulator;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\treturn { ...choiceAccumulator, [choiceKey]: choice };\n\t\t\t\t\t\t\t\t}, {});\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...fieldAccumulator,\n\t\t\t\t\t\t\t\t\t[fieldKey]: {\n\t\t\t\t\t\t\t\t\t\t...field,\n\t\t\t\t\t\t\t\t\t\tconfig: { ...field.config, choices: filteredChoices },\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\t{},\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn { ...tabAccumulator, [tabKey]: updatedTabFields };\n\t\t\t\t\t},\n\t\t\t\t\t{},\n\t\t\t\t);\n\n\t\t\t\tawait this.customTypes.updateCustomType({\n\t\t\t\t\tmodel: { ...customType.model, json: updatedJsonModel },\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\n\t\treturn { errors: customTypeReadErrors };\n\t}\n}\n"],"names":["errors"],"mappings":";;;;;;;;;;;;;;;;AAiNM,MAAO,sBAAsB,YAAW;AAAA,EAC7C,MAAM,iBACL,MAA8B;;AAE9B,6BAAyB,KAAK,wBAAwB;AAKtD,UAAM,aAAa,MAAM,KAAK,yBAAyB,SACtD,sBACA,IAAI;AAEL,UAAM,EAAE,MAAM,OAAA,IAAW,iBACxB,EAAE,KAAK;AAAA,MACN,IAAI,EAAE;AAAA,MACN,UAAU,EAAE,MAAM,EAAE,MAAM;AAAA,IAAA,CAC1B,GACD,UAAU;AAGJ,WAAA;AAAA,MACN,YAAU,UAAK,CAAC,MAAN,mBAAS,aAAY,CAAE;AAAA,MACjC;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,MAAM,wBAAqB;AAC1B,6BAAyB,KAAK,wBAAwB;AAEtD,UAAM,qBAAqB,MAAM,KAAK,QAAQ,sBAAqB;AAC7D,UAAA,aAAa,mBAAmB,aAAa;AAEnD,UAAM,MAAoD;AAAA,MACzD,WAAW,CAAE;AAAA,MACb,QAAQ,CAAE;AAAA,IAAA;AAGX,eAAW,aAAa,YAAY;AACnC,YAAM,EAAE,UAAU,OAAW,IAAA,MAAM,KAAK,iBAAiB;AAAA,QACxD;AAAA,MAAA,CACA;AACD,UAAI,SAAS,CAAC,GAAG,IAAI,QAAQ,GAAG,MAAM;AAEtC,UAAI,UAAU,KAAK;AAAA,QAClB;AAAA,QACA;AAAA,MAAA,CACA;AAAA,IACF;AAEO,WAAA;AAAA,EACR;AAAA,EAEA,MAAM,wBACL,MAAoD;AAEpD,6BAAyB,KAAK,wBAAwB;AAEtD,UAAM,MAA4D;AAAA,MACjE,QAAQ,CAAE;AAAA,MACV,QAAQ,CAAE;AAAA,IAAA;AAGX,UAAM,EAA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AAA,IACD,CAAA,CAAC;AAGI,WAAA,EAAE,QAAQ;EAClB;AACA;"}
|
1
|
+
{"version":3,"file":"SlicesManager.js","sources":["../../../../src/managers/slices/SlicesManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport { SharedSliceContent } from \"@prismicio/types-internal/lib/content\";\nimport { SliceComparator } from \"@prismicio/types-internal/lib/customtypes/diff\";\nimport {\n\tCompositeSlice,\n\tLegacySlice,\n\tSharedSlice,\n\tVariation,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport {\n\tCallHookReturnType,\n\tHookError,\n\tSliceAssetUpdateHook,\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceLibraryReadHookData,\n\tSliceReadHookData,\n\tSliceRenameHook,\n\tSliceRenameHookData,\n\tSliceUpdateHook,\n} from \"@slicemachine/plugin-kit\";\n\nimport { DecodeError } from \"../../lib/DecodeError\";\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { bufferCodec } from \"../../lib/bufferCodec\";\nimport { decodeHookResult } from \"../../lib/decodeHookResult\";\nimport { createContentDigest } from \"../../lib/createContentDigest\";\nimport { mockSlice } from \"../../lib/mockSlice\";\nimport fetch from \"../../lib/fetch\";\n\nimport { OnlyHookErrors } from \"../../types\";\nimport { DEFAULT_SLICE_SCREENSHOT_URL } from \"../../constants/DEFAULT_SLICE_SCREENSHOT_URL\";\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { UnauthenticatedError, UnauthorizedError } from \"../../errors\";\n\nimport { BaseManager } from \"../BaseManager\";\nimport {\n\tBedrockRuntimeClient,\n\tConverseCommand,\n} from \"@aws-sdk/client-bedrock-runtime\";\n\ntype SlicesManagerReadSliceLibraryReturnType = {\n\tsliceIDs: string[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SlicesManagerReadAllSliceLibrariesReturnType = {\n\tlibraries: {\n\t\tlibraryID: string;\n\t\tsliceIDs: string[] | undefined;\n\t}[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadAllSlicesForLibraryArgs = {\n\tlibraryID: string;\n};\n\ntype SliceMachineManagerUpdateSliceArgs = {\n\tlibraryID: string;\n\tmodel: SharedSlice;\n\tmocks?: SharedSliceContent[];\n};\n\ntype SliceMachineManagerReadAllSlicesForLibraryReturnType = {\n\tmodels: { model: SharedSlice }[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadAllSlicesReturnType = {\n\tmodels: {\n\t\tlibraryID: string;\n\t\tmodel: SharedSlice;\n\t}[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadSliceReturnType = {\n\tmodel: SharedSlice | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerPushSliceArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\tuserAgent?: string;\n};\n\nexport type SliceMachineManagerPushSliceReturnType = {\n\t/**\n\t * A record of Slice variation IDs mapped to uploaded screenshot URLs.\n\t */\n\tscreenshotURLs: Record<string, string> | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadSliceScreenshotArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\tvariationID: string;\n};\n\ntype SliceMachineManagerReadSliceScreenshotReturnType = {\n\tdata: Buffer | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerUpdateSliceScreenshotArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\tvariationID: string;\n\tdata: Buffer;\n};\n\ntype SliceMachineManagerDeleteSliceScreenshotArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\tvariationID: string;\n};\n\ntype SliceMachineManagerReadSliceMocksArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n};\n\ntype SliceMachineManagerReadSliceMocksReturnType = {\n\tmocks?: SharedSliceContent[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadSliceMocksConfigArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n};\n\ntype SliceMachineManagerReadSliceMocksConfigArgsReturnType = {\n\t// TODO\n\tmocksConfig?: Record<string, unknown>;\n\terrors: HookError[];\n};\n\ntype SliceMachineManagerUpdateSliceMocksArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\tmocks: SharedSliceContent[];\n};\n\ntype SliceMachineManagerUpdateSliceMocksArgsReturnType = {\n\terrors: HookError[];\n};\n\ntype SlicesManagerUpsertHostedSliceScrenshotsArgs = {\n\tlibraryID: string;\n\tmodel: SharedSlice;\n};\n\ntype SliceMachineManagerDeleteSliceArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n};\n\ntype SliceMachineManagerDeleteSliceReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerRenameSliceVariationArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\t/**\n\t * Current ID of the variation to rename.\n\t */\n\tvariationID: string;\n\tmodel: Variation;\n};\n\ntype SliceMachineManagerRenameSliceVariationReturnType = {\n\terrors: (DecodeError | HookError)[];\n\tassetsErrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerDeleteSliceVariationArgs = {\n\tlibraryID: string;\n\tsliceID: string;\n\tvariationID: string;\n};\n\ntype SliceMachineManagerDeleteSliceVariationReturnType = {\n\terrors: (DecodeError | HookError)[];\n\tassetsErrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerConvertLegacySliceToSharedSliceArgs = {\n\tmodel: CompositeSlice | LegacySlice;\n\tsrc: {\n\t\tcustomTypeID: string;\n\t\ttabID: string;\n\t\tsliceZoneID: string;\n\t\tsliceID: string;\n\t};\n\tdest: {\n\t\tlibraryID: string;\n\t\tsliceID: string;\n\t\tvariationName: string;\n\t\tvariationID: string;\n\t};\n};\n\ntype SliceMachineManagerConvertLegacySliceToSharedSliceReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerGenerateSliceArgs = {\n\tuserPrompt: string;\n\tlibraryID: string;\n\tslice: SharedSlice;\n\timageFile?: Buffer;\n};\n\ntype SliceMachineManagerGenerateSliceReturnType = {\n\tslice?: SharedSlice;\n\terrors: (DecodeError | HookError)[];\n};\n\nexport class SlicesManager extends BaseManager {\n\tasync readSliceLibrary(\n\t\targs: SliceLibraryReadHookData,\n\t): Promise<SlicesManagerReadSliceLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t// TODO: Should validation happen at the `callHook` level?\n\t\t// Including validation at the hook level would ensure\n\t\t// hook-based actions are validated.\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice-library:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tid: t.string,\n\t\t\t\tsliceIDs: t.array(t.string),\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tsliceIDs: data[0]?.sliceIDs ?? [],\n\t\t\terrors: errors,\n\t\t};\n\t}\n\n\tasync readAllSliceLibraries(): Promise<SlicesManagerReadAllSliceLibrariesReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst sliceMachineConfig = await this.project.getSliceMachineConfig();\n\t\tconst libraryIDs = sliceMachineConfig.libraries || [];\n\n\t\tconst res: SlicesManagerReadAllSliceLibrariesReturnType = {\n\t\t\tlibraries: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tfor (const libraryID of libraryIDs) {\n\t\t\tconst { sliceIDs, errors } = await this.readSliceLibrary({\n\t\t\t\tlibraryID,\n\t\t\t});\n\t\t\tres.errors = [...res.errors, ...errors];\n\n\t\t\tres.libraries.push({\n\t\t\t\tlibraryID,\n\t\t\t\tsliceIDs,\n\t\t\t});\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync readAllSlicesForLibrary(\n\t\targs: SliceMachineManagerReadAllSlicesForLibraryArgs,\n\t): Promise<SliceMachineManagerReadAllSlicesForLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst res: SliceMachineManagerReadAllSlicesForLibraryReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tconst { sliceIDs, errors } = await this.readSliceLibrary({\n\t\t\tlibraryID: args.libraryID,\n\t\t});\n\t\tres.errors.push(...errors);\n\n\t\tif (sliceIDs) {\n\t\t\tfor (const sliceID of sliceIDs) {\n\t\t\t\tconst { model, errors } = await this.readSlice({\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tsliceID,\n\t\t\t\t});\n\t\t\t\tres.errors.push(...errors);\n\n\t\t\t\tif (model) {\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 readAllSlices(): Promise<SliceMachineManagerReadAllSlicesReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst sliceMachineConfig = await this.project.getSliceMachineConfig();\n\t\tconst libraryIDs = sliceMachineConfig.libraries || [];\n\n\t\tconst res: SliceMachineManagerReadAllSlicesReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tfor (const libraryID of libraryIDs) {\n\t\t\tconst { models, errors } = await this.readAllSlicesForLibrary({\n\t\t\t\tlibraryID,\n\t\t\t});\n\t\t\tres.errors.push(...errors);\n\n\t\t\tfor (const model of models) {\n\t\t\t\tres.models.push({\n\t\t\t\t\tlibraryID,\n\t\t\t\t\tmodel: model.model,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync createSlice(\n\t\targs: SliceCreateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<SliceCreateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:create\",\n\t\t\targs,\n\t\t);\n\n\t\tconst updateSliceMocksArgs: SliceMachineManagerUpdateSliceMocksArgs = {\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.model.id,\n\t\t\tmocks: mockSlice({ model: args.model }),\n\t\t};\n\n\t\tconst { errors: updateSliceHookErrors } =\n\t\t\tawait this.updateSliceMocks(updateSliceMocksArgs);\n\n\t\treturn {\n\t\t\terrors: [...hookResult.errors, ...updateSliceHookErrors],\n\t\t};\n\t}\n\n\tasync readSlice(\n\t\targs: SliceReadHookData,\n\t): Promise<SliceMachineManagerReadSliceReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tmodel: SharedSlice,\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: errors.map((error) => {\n\t\t\t\terror.message = `Failed to decode slice model with id '${args.sliceID}': ${error.message}`;\n\n\t\t\t\treturn error;\n\t\t\t}),\n\t\t};\n\t}\n\n\tasync updateSlice(\n\t\targs: SliceMachineManagerUpdateSliceArgs,\n\t): Promise<OnlyHookErrors<CallHookReturnType<SliceUpdateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { mocks: previousMocks } = await this.readSliceMocks({\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.model.id,\n\t\t});\n\t\tconst { model: previousModel } = await this.readSlice({\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.model.id,\n\t\t});\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:update\",\n\t\t\targs,\n\t\t);\n\n\t\tconst updatedMocks = mockSlice({\n\t\t\tmodel: args.model,\n\t\t\tmocks: previousMocks,\n\t\t\tdiff: SliceComparator.compare(previousModel, args.model),\n\t\t});\n\t\tconst updateSliceMocksArgs: SliceMachineManagerUpdateSliceMocksArgs = {\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.model.id,\n\t\t\tmocks: updatedMocks,\n\t\t};\n\n\t\tconst { errors: updateSliceMocksHookResult } =\n\t\t\tawait this.updateSliceMocks(updateSliceMocksArgs);\n\n\t\treturn {\n\t\t\terrors: [...hookResult.errors, ...updateSliceMocksHookResult],\n\t\t};\n\t}\n\n\tasync renameSlice(\n\t\targs: SliceRenameHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<SliceRenameHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice: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 deleteSlice(\n\t\targs: SliceMachineManagerDeleteSliceArgs,\n\t): Promise<SliceMachineManagerDeleteSliceReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readSliceErrors } = await this.readSlice({\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.sliceID,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst { errors: deleteSliceErrors } =\n\t\t\t\tawait this.sliceMachinePluginRunner.callHook(\"slice:delete\", {\n\t\t\t\t\tmodel,\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t});\n\n\t\t\t// Do not update custom types if slice deletion failed\n\t\t\tif (deleteSliceErrors.length > 0) {\n\t\t\t\treturn {\n\t\t\t\t\terrors: deleteSliceErrors,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { errors: updateCustomTypeErrors } =\n\t\t\t\tawait this._removeSliceFromCustomTypes(args.sliceID);\n\n\t\t\treturn {\n\t\t\t\terrors: updateCustomTypeErrors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readSliceErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync renameSliceVariation(\n\t\targs: SliceMachineManagerRenameSliceVariationArgs,\n\t): Promise<SliceMachineManagerRenameSliceVariationReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t// TODO: Remove when we support renaming variation ID, see: DT-1708\n\t\tif (args.variationID !== args.model.id) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Renaming variation ID is not supported yet by the backend, only rename its name! For more information, see: https://linear.app/prismic/issue/DT-1708\",\n\t\t\t);\n\t\t}\n\n\t\tconst { model, errors: readSliceErrors } = await this.readSlice({\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.sliceID,\n\t\t});\n\n\t\tif (model) {\n\t\t\t// Find and rename the variation\n\t\t\tconst updatedModel = {\n\t\t\t\t...model,\n\t\t\t\tvariations: model.variations.map((variation) => {\n\t\t\t\t\tif (variation.id === args.variationID) {\n\t\t\t\t\t\t// Matches the slice we want to rename\n\t\t\t\t\t\treturn args.model;\n\t\t\t\t\t} else if (variation.id === args.model.id) {\n\t\t\t\t\t\t// Matches any other slice that has the ID of the renamed variation and throw.\n\t\t\t\t\t\t// This should be validated on the frontend first for better UX, this is only backend validation.\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Cannot rename variation \\`${args.variationID}\\` to \\`${args.model.id}\\`. A variation already exists with that ID in slice \\`${args.sliceID}\\` from library \\`${args.libraryID}\\`, try deleting it first or choose another variation ID to rename that slice.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn variation;\n\t\t\t\t}),\n\t\t\t};\n\t\t\tconst updateSliceHookResult =\n\t\t\t\tawait this.sliceMachinePluginRunner.callHook(\"slice:update\", {\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tmodel: updatedModel,\n\t\t\t\t});\n\n\t\t\t// If variation ID has changed, we need to rename assets accordingly\n\t\t\tconst assetsErrors: (DecodeError<unknown> | HookError<unknown>)[] = [];\n\t\t\tif (args.variationID !== args.model.id) {\n\t\t\t\t// Renaming screenshot\n\t\t\t\tconst { data: screenshot, errors: readSliceScreenshotErrors } =\n\t\t\t\t\tawait this.readSliceScreenshot({\n\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\tsliceID: args.sliceID,\n\t\t\t\t\t\tvariationID: args.variationID,\n\t\t\t\t\t});\n\t\t\t\tassetsErrors.push(...readSliceScreenshotErrors);\n\n\t\t\t\tif (screenshot) {\n\t\t\t\t\t// Delete old ID screenshot\n\t\t\t\t\tconst { errors: deleteSliceScreenshotErrors } =\n\t\t\t\t\t\tawait this.deleteSliceScreenshot({\n\t\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\t\tsliceID: args.sliceID,\n\t\t\t\t\t\t\tvariationID: args.variationID,\n\t\t\t\t\t\t});\n\t\t\t\t\tassetsErrors.push(...deleteSliceScreenshotErrors);\n\n\t\t\t\t\t// Create new ID screenshot\n\t\t\t\t\tconst { errors: updateSliceScreenshotErrors } =\n\t\t\t\t\t\tawait this.updateSliceScreenshot({\n\t\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\t\tsliceID: args.sliceID,\n\t\t\t\t\t\t\tvariationID: args.model.id,\n\t\t\t\t\t\t\tdata: screenshot,\n\t\t\t\t\t\t});\n\t\t\t\t\tassetsErrors.push(...updateSliceScreenshotErrors);\n\t\t\t\t}\n\n\t\t\t\t// Renaming mocks\n\t\t\t\tconst { mocks, errors: readSliceMocksErrors } =\n\t\t\t\t\tawait this.readSliceMocks({\n\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\tsliceID: args.sliceID,\n\t\t\t\t\t});\n\t\t\t\tassetsErrors.push(...readSliceMocksErrors);\n\n\t\t\t\tif (mocks?.length) {\n\t\t\t\t\tconst { errors: updateSliceMocksErrors } =\n\t\t\t\t\t\tawait this.updateSliceMocks({\n\t\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\t\tsliceID: args.sliceID,\n\t\t\t\t\t\t\tmocks: mocks.map((mock) => {\n\t\t\t\t\t\t\t\tif (mock.variation === args.variationID) {\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t...mock,\n\t\t\t\t\t\t\t\t\t\tvariation: args.model.id,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn mock;\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t});\n\t\t\t\t\tassetsErrors.push(...updateSliceMocksErrors);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\terrors: updateSliceHookResult.errors,\n\t\t\t\tassetsErrors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readSliceErrors,\n\t\t\t\tassetsErrors: [],\n\t\t\t};\n\t\t}\n\t}\n\n\tasync deleteSliceVariation(\n\t\targs: SliceMachineManagerDeleteSliceVariationArgs,\n\t): Promise<SliceMachineManagerDeleteSliceVariationReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readSliceErrors } = await this.readSlice({\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.sliceID,\n\t\t});\n\n\t\tif (model) {\n\t\t\t// Remove variation from model and update it\n\t\t\tconst updatedModel = {\n\t\t\t\t...model,\n\t\t\t\tvariations: model.variations.filter(\n\t\t\t\t\t(variation) => variation.id !== args.variationID,\n\t\t\t\t),\n\t\t\t};\n\t\t\tconst updateSliceHookResult =\n\t\t\t\tawait this.sliceMachinePluginRunner.callHook(\"slice:update\", {\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tmodel: updatedModel,\n\t\t\t\t});\n\n\t\t\t// Cleanup deleted variation screenshot\n\t\t\tconst { errors: deleteSliceScreenshotErrors } =\n\t\t\t\tawait this.deleteSliceScreenshot(args);\n\n\t\t\t// Cleanup deleted variation mocks\n\t\t\tconst { mocks, errors: readSliceMocksErrors } = await this.readSliceMocks(\n\t\t\t\t{\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tsliceID: args.sliceID,\n\t\t\t\t},\n\t\t\t);\n\t\t\tlet updateSliceMocksErrors: SliceMachineManagerUpdateSliceMocksArgsReturnType[\"errors\"] =\n\t\t\t\t[];\n\t\t\tif (mocks?.length) {\n\t\t\t\tupdateSliceMocksErrors = (\n\t\t\t\t\tawait this.updateSliceMocks({\n\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\tsliceID: args.sliceID,\n\t\t\t\t\t\tmocks: mocks.filter((mock) => mock.variation !== args.variationID),\n\t\t\t\t\t})\n\t\t\t\t).errors;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\terrors: updateSliceHookResult.errors,\n\t\t\t\tassetsErrors: [\n\t\t\t\t\t...deleteSliceScreenshotErrors,\n\t\t\t\t\t...readSliceMocksErrors,\n\t\t\t\t\t...updateSliceMocksErrors,\n\t\t\t\t],\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readSliceErrors,\n\t\t\t\tassetsErrors: [],\n\t\t\t};\n\t\t}\n\t}\n\n\tasync convertLegacySliceToSharedSlice(\n\t\targs: SliceMachineManagerConvertLegacySliceToSharedSliceArgs,\n\t): Promise<SliceMachineManagerConvertLegacySliceToSharedSliceReturnType> {\n\t\tconst errors: (DecodeError | HookError)[] = [];\n\n\t\tconst { model: maybeExistingSlice } = await this.readSlice({\n\t\t\tlibraryID: args.dest.libraryID,\n\t\t\tsliceID: args.dest.sliceID,\n\t\t});\n\n\t\tconst legacySliceAsVariation: Variation = {\n\t\t\tid: args.dest.variationID,\n\t\t\tname: args.dest.variationName,\n\t\t\tdescription: args.dest.variationName,\n\t\t\timageUrl: \"\",\n\t\t\tdocURL: \"\",\n\t\t\tversion: \"initial\",\n\t\t\tprimary: {},\n\t\t\titems: {},\n\t\t};\n\n\t\tswitch (args.model.type) {\n\t\t\tcase \"Slice\":\n\t\t\t\tlegacySliceAsVariation.primary = args.model[\"non-repeat\"];\n\t\t\t\tlegacySliceAsVariation.items = args.model.repeat;\n\t\t\t\tbreak;\n\n\t\t\tcase \"Group\":\n\t\t\t\tlegacySliceAsVariation.items = args.model.config?.fields ?? {};\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tlegacySliceAsVariation.primary = { [args.src.sliceID]: args.model };\n\t\t\t\tbreak;\n\t\t}\n\n\t\t// Convert as a slice variation, or merge against an existing slice variation\n\t\tif (maybeExistingSlice) {\n\t\t\tconst maybeVariation = maybeExistingSlice.variations.find(\n\t\t\t\t(variation) => variation.id === args.dest.variationID,\n\t\t\t);\n\n\t\t\t// If we're not merging against an existing slice variation, then we need to insert the new variation\n\t\t\tif (!maybeVariation) {\n\t\t\t\tmaybeExistingSlice.variations = [\n\t\t\t\t\t...maybeExistingSlice.variations,\n\t\t\t\t\tlegacySliceAsVariation,\n\t\t\t\t];\n\t\t\t}\n\n\t\t\tmaybeExistingSlice.legacyPaths ||= {};\n\t\t\tmaybeExistingSlice.legacyPaths[\n\t\t\t\t`${args.src.customTypeID}::${args.src.sliceZoneID}::${args.src.sliceID}`\n\t\t\t] = args.dest.variationID;\n\n\t\t\tawait this.updateSlice({\n\t\t\t\tlibraryID: args.dest.libraryID,\n\t\t\t\tmodel: maybeExistingSlice,\n\t\t\t});\n\t\t} else {\n\t\t\t// Convert to new shared slice\n\t\t\tawait this.createSlice({\n\t\t\t\tlibraryID: args.dest.libraryID,\n\t\t\t\tmodel: {\n\t\t\t\t\tid: args.dest.sliceID,\n\t\t\t\t\ttype: \"SharedSlice\",\n\t\t\t\t\tname: args.dest.sliceID,\n\t\t\t\t\tlegacyPaths: {\n\t\t\t\t\t\t[`${args.src.customTypeID}::${args.src.sliceZoneID}::${args.src.sliceID}`]:\n\t\t\t\t\t\t\targs.dest.variationID,\n\t\t\t\t\t},\n\t\t\t\t\tvariations: [legacySliceAsVariation],\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Update source custom type\n\t\tconst { model: customType, errors: customTypeReadErrors } =\n\t\t\tawait this.customTypes.readCustomType({\n\t\t\t\tid: args.src.customTypeID,\n\t\t\t});\n\t\terrors.push(...customTypeReadErrors);\n\n\t\tif (customType) {\n\t\t\tconst field = customType.json[args.src.tabID][args.src.sliceZoneID];\n\n\t\t\t// Convert legacy slice definition in slice zone to shared slice reference\n\t\t\tif (field.type === \"Slices\" && field.config?.choices) {\n\t\t\t\tdelete field.config.choices[args.src.sliceID];\n\t\t\t\tfield.config.choices[args.dest.sliceID] = {\n\t\t\t\t\ttype: \"SharedSlice\",\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { errors: customTypeUpdateErrors } =\n\t\t\t\tawait this.customTypes.updateCustomType({ model: customType });\n\t\t\terrors.push(...customTypeUpdateErrors);\n\t\t}\n\n\t\treturn { errors };\n\t}\n\n\t/**\n\t * @returns Record of variation IDs mapped to uploaded screenshot URLs.\n\t */\n\tasync pushSlice(\n\t\targs: SliceMachineManagerPushSliceArgs,\n\t): Promise<SliceMachineManagerPushSliceReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tif (!(await this.user.checkIsLoggedIn())) {\n\t\t\tthrow new UnauthenticatedError();\n\t\t}\n\n\t\tconst { model, errors: readSliceErrors } = await this.readSlice({\n\t\t\tlibraryID: args.libraryID,\n\t\t\tsliceID: args.sliceID,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst modelWithScreenshots =\n\t\t\t\tawait this.updateSliceModelScreenshotsInPlace({\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tmodel,\n\t\t\t\t});\n\n\t\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\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 Slice already exists on the repository.\n\t\t\t\tawait client.getSharedSliceByID(args.sliceID);\n\n\t\t\t\t// If it exists on the repository, update it.\n\t\t\t\tawait client.updateSharedSlice(modelWithScreenshots);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof prismicCustomTypesClient.NotFoundError) {\n\t\t\t\t\t// If the Slice doesn't exist on the repository, insert it.\n\t\t\t\t\tawait client.insertSharedSlice(modelWithScreenshots);\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 Slices to this Prismic repository.\",\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t// Pass the error through if it isn't the one we were expecting.\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst screenshotURLs: Record<string, string> = {};\n\t\t\tfor (const variation of modelWithScreenshots.variations) {\n\t\t\t\tscreenshotURLs[variation.id] = variation.imageUrl;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tscreenshotURLs,\n\t\t\t\terrors: readSliceErrors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tscreenshotURLs: undefined,\n\t\t\t\terrors: readSliceErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync readSliceScreenshot(\n\t\targs: SliceMachineManagerReadSliceScreenshotArgs,\n\t): Promise<SliceMachineManagerReadSliceScreenshotReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:asset:read\",\n\t\t\t{\n\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\tsliceID: args.sliceID,\n\t\t\t\tassetID: `screenshot-${args.variationID}.png`,\n\t\t\t},\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tdata: bufferCodec,\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tdata: data[0]?.data,\n\t\t\terrors: errors,\n\t\t};\n\t}\n\n\tasync updateSliceScreenshot(\n\t\targs: SliceMachineManagerUpdateSliceScreenshotArgs,\n\t): Promise<OnlyHookErrors<CallHookReturnType<SliceAssetUpdateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:asset:update\",\n\t\t\t{\n\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\tsliceID: args.sliceID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: `screenshot-${args.variationID}.png`,\n\t\t\t\t\tdata: args.data,\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 deleteSliceScreenshot(\n\t\targs: SliceMachineManagerDeleteSliceScreenshotArgs,\n\t): Promise<OnlyHookErrors<CallHookReturnType<SliceAssetUpdateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:asset:delete\",\n\t\t\t{\n\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\tsliceID: args.sliceID,\n\t\t\t\tassetID: `screenshot-${args.variationID}.png`,\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 readSliceMocks(\n\t\targs: SliceMachineManagerReadSliceMocksArgs,\n\t): Promise<SliceMachineManagerReadSliceMocksReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:asset:read\",\n\t\t\t{\n\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\tsliceID: args.sliceID,\n\t\t\t\tassetID: `mocks.json`,\n\t\t\t},\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tdata: t.array(SharedSliceContent),\n\t\t\t}),\n\t\t\t{\n\t\t\t\t...hookResult,\n\t\t\t\t// Convert the asset data from a Buffer to JSON\n\t\t\t\t// to prepare it for validation.\n\t\t\t\tdata: hookResult.data.map((result) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tdata: JSON.parse(result.data.toString()),\n\t\t\t\t\t\t};\n\t\t\t\t\t} catch {\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t},\n\t\t);\n\n\t\tif (data) {\n\t\t\treturn {\n\t\t\t\tmocks: data[0]?.data,\n\t\t\t\terrors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tmocks: [],\n\t\t\t\terrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync updateSliceMocks(\n\t\targs: SliceMachineManagerUpdateSliceMocksArgs,\n\t): Promise<SliceMachineManagerUpdateSliceMocksArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:asset:update\",\n\t\t\t{\n\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\tsliceID: args.sliceID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: \"mocks.json\",\n\t\t\t\t\tdata: Buffer.from(JSON.stringify(args.mocks, 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\t// TODO: Remove\n\tasync readSliceMocksConfig(\n\t\targs: SliceMachineManagerReadSliceMocksConfigArgs,\n\t): Promise<SliceMachineManagerReadSliceMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"slice:asset:read\",\n\t\t\t{\n\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\tsliceID: args.sliceID,\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\tasync fetchRemoteSlices(): Promise<SharedSlice[]> {\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.getAllSharedSlices();\n\t}\n\n\tasync updateSliceModelScreenshotsInPlace(\n\t\targs: SlicesManagerUpsertHostedSliceScrenshotsArgs,\n\t): Promise<SharedSlice> {\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\tconst variations = await Promise.all(\n\t\t\targs.model.variations.map(async (variation) => {\n\t\t\t\tconst screenshot = await this.readSliceScreenshot({\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tsliceID: args.model.id,\n\t\t\t\t\tvariationID: variation.id,\n\t\t\t\t});\n\n\t\t\t\t// If there's no screenshot, delete it by replacing it with the default screenshot\n\t\t\t\tif (!screenshot.data) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...variation,\n\t\t\t\t\t\timageUrl: DEFAULT_SLICE_SCREENSHOT_URL,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst hasScreenshotChanged = !variation.imageUrl?.includes(\n\t\t\t\t\tcreateContentDigest(screenshot.data),\n\t\t\t\t);\n\n\t\t\t\t// If screenshot hasn't changed, do nothing\n\t\t\t\tif (!hasScreenshotChanged) {\n\t\t\t\t\treturn variation;\n\t\t\t\t}\n\n\t\t\t\tconst keyPrefix = [\n\t\t\t\t\trepositoryName,\n\t\t\t\t\t\"shared-slices\",\n\t\t\t\t\targs.model.id,\n\t\t\t\t\tvariation.id,\n\t\t\t\t].join(\"/\");\n\n\t\t\t\tconst uploadedScreenshot = await this.screenshots.uploadScreenshot({\n\t\t\t\t\tdata: screenshot.data,\n\t\t\t\t\tkeyPrefix,\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\t...variation,\n\t\t\t\t\timageUrl: uploadedScreenshot.url,\n\t\t\t\t};\n\t\t\t}),\n\t\t);\n\n\t\treturn {\n\t\t\t...args.model,\n\t\t\tvariations,\n\t\t};\n\t}\n\n\tprivate async _removeSliceFromCustomTypes(sliceID: string) {\n\t\tconst { models, errors: customTypeReadErrors } =\n\t\t\tawait this.customTypes.readAllCustomTypes();\n\n\t\t// Successfully update all custom types or throw\n\t\tawait Promise.all(\n\t\t\tmodels.map(async (customType) => {\n\t\t\t\tconst updatedJsonModel = Object.entries(customType.model.json).reduce(\n\t\t\t\t\t(tabAccumulator, [tabKey, tab]) => {\n\t\t\t\t\t\tconst updatedTabFields = Object.entries(tab).reduce(\n\t\t\t\t\t\t\t(fieldAccumulator, [fieldKey, field]) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tfield.config === undefined ||\n\t\t\t\t\t\t\t\t\tfield.type !== \"Slices\" ||\n\t\t\t\t\t\t\t\t\tfield.config.choices === undefined\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn { ...fieldAccumulator, [fieldKey]: field };\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst filteredChoices = Object.entries(\n\t\t\t\t\t\t\t\t\tfield.config.choices,\n\t\t\t\t\t\t\t\t).reduce((choiceAccumulator, [choiceKey, choice]) => {\n\t\t\t\t\t\t\t\t\tif (choiceKey === sliceID) {\n\t\t\t\t\t\t\t\t\t\treturn choiceAccumulator;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\treturn { ...choiceAccumulator, [choiceKey]: choice };\n\t\t\t\t\t\t\t\t}, {});\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...fieldAccumulator,\n\t\t\t\t\t\t\t\t\t[fieldKey]: {\n\t\t\t\t\t\t\t\t\t\t...field,\n\t\t\t\t\t\t\t\t\t\tconfig: { ...field.config, choices: filteredChoices },\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\t{},\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn { ...tabAccumulator, [tabKey]: updatedTabFields };\n\t\t\t\t\t},\n\t\t\t\t\t{},\n\t\t\t\t);\n\n\t\t\t\tawait this.customTypes.updateCustomType({\n\t\t\t\t\tmodel: { ...customType.model, json: updatedJsonModel },\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\n\t\treturn { errors: customTypeReadErrors };\n\t}\n\n\tasync generateSlice(\n\t\targs: SliceMachineManagerGenerateSliceArgs,\n\t): Promise<SliceMachineManagerGenerateSliceReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst AWS_REGION = \"us-east-1\";\n\t\tconst AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;\n\t\tconst AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY;\n\n\t\tif (!AWS_ACCESS_KEY_ID || !AWS_SECRET_ACCESS_KEY) {\n\t\t\tthrow new Error(\"AWS credentials are not set.\");\n\t\t}\n\n\t\t// Initialize AWS Bedrock client\n\t\tconst bedrockClient = new BedrockRuntimeClient({\n\t\t\tregion: AWS_REGION,\n\t\t\tcredentials: {\n\t\t\t\taccessKeyId: AWS_ACCESS_KEY_ID,\n\t\t\t\tsecretAccessKey: AWS_SECRET_ACCESS_KEY,\n\t\t\t},\n\t\t});\n\n\t\t/**\n\t\t * Generates the JSON schema for the SharedSlice TypeScript type.\n\t\t */\n\t\tconst getSharedSliceSchema = (): string => {\n\t\t\treturn `\n\n\t\t\t/**\n\t\t\t * Represents a Prismic Slice.\n\t\t\t * @property {string} type - Should always be \"SharedSlice\".\n\t\t\t * @property {string} id - Unique identifier for the slice in snake_case.\n\t\t\t * @property {string} name - Human-readable name in PascalCase.\n\t\t\t * @property {string} description - Brief explanation of the slice's purpose.\n\t\t\t * @property {SliceVariation[]} variations - Array of variations for the slice.\n\t\t\t */\n\t\t\ttype PrismicSlice = {\n\t\t\t type: \"SharedSlice\";\n\t\t\t id: string;\n\t\t\t name: string;\n\t\t\t description: string;\n\t\t\t variations: SliceVariation[];\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents a variation of a Prismic Slice.\n\t\t\t * @property {string} id - Unique identifier for the variation in snake_case.\n\t\t\t * @property {string} name - Human-readable name in PascalCase.\n\t\t\t * @property {string} description - Brief explanation of the variation's purpose.\n\t\t\t * @property {string} docURL - Legacy property, required with an empty string.\n\t\t\t * @property {string} version - Legacy property, required with the name property value.\n\t\t\t * @property {Record<string, PrismicField>} [primary] - Primary fields defining the main content of the slice.\n\t\t\t */\n\t\t\ttype SliceVariation = {\n\t\t\t id: string;\n\t\t\t name: string;\n\t\t\t description: string;\n\t\t\t primary: Record<string, PrismicField>;\n\t\t\t docURL: string;\n\t\t\t version: string;\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Union type representing all possible Prismic fields.\n\t\t\t */\n\t\t\ttype PrismicField =\n\t\t\t | UIDField\n\t\t\t | BooleanField\n\t\t\t | ColorField\n\t\t\t | DateField\n\t\t\t | TimestampField\n\t\t\t | NumberField\n\t\t\t | KeyTextField\n\t\t\t | SelectField\n\t\t\t | StructuredTextField\n\t\t\t | ImageField\n\t\t\t | LinkField\n\t\t\t | GeoPointField\n\t\t\t | EmbedField\n\t\t\t | GroupField;\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents a UID Field in Prismic.\n\t\t\t * @property {\"UID\"} type - Field type.\n\t\t\t * @property {Object} config - Configuration object.\n\t\t\t * @property {string} config.label - Label displayed in the editor.\n\t\t\t * @property {string} [config.placeholder] - Placeholder text.\n\t\t\t * @property {string} [config.customregex] - Custom regex for validation.\n\t\t\t * @property {string} [config.errorMessage] - Error message for invalid input.\n\t\t\t */\n\t\t\ttype UIDField = {\n\t\t\t type: \"UID\";\n\t\t\t config: {\n\t\t\t\tlabel: string;\n\t\t\t\tplaceholder?: string;\n\t\t\t\tcustomregex?: string;\n\t\t\t\terrorMessage?: string;\n\t\t\t };\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents a Boolean Field in Prismic.\n\t\t\t * @property {\"Boolean\"} type - Field type.\n\t\t\t * @property {Object} config - Configuration object.\n\t\t\t * @property {string} config.label - Label displayed in the editor.\n\t\t\t * @property {boolean} [config.default_value] - Default value (true or false).\n\t\t\t */\n\t\t\ttype BooleanField = {\n\t\t\t type: \"Boolean\";\n\t\t\t config: {\n\t\t\t\tlabel: string;\n\t\t\t\tdefault_value?: boolean;\n\t\t\t };\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents a Color Field in Prismic.\n\t\t\t * @property {\"Color\"} type - Field type.\n\t\t\t * @property {Object} config - Configuration object.\n\t\t\t * @property {string} config.label - Label displayed in the editor.\n\t\t\t */\n\t\t\ttype ColorField = {\n\t\t\t type: \"Color\";\n\t\t\t config: {\n\t\t\t\tlabel: string;\n\t\t\t };\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents a Date Field in Prismic.\n\t\t\t * @property {\"Date\"} type - Field type.\n\t\t\t * @property {Object} config - Configuration object.\n\t\t\t * @property {string} config.label - Label displayed in the editor.\n\t\t\t */\n\t\t\ttype DateField = {\n\t\t\t type: \"Date\";\n\t\t\t config: {\n\t\t\t\tlabel: string;\n\t\t\t };\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents a Timestamp Field in Prismic.\n\t\t\t * @property {\"Timestamp\"} type - Field type.\n\t\t\t * @property {Object} config - Configuration object.\n\t\t\t * @property {string} config.label - Label displayed in the editor.\n\t\t\t */\n\t\t\ttype TimestampField = {\n\t\t\t type: \"Timestamp\";\n\t\t\t config: {\n\t\t\t\tlabel: string;\n\t\t\t };\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents a Number Field in Prismic.\n\t\t\t * @property {\"Number\"} type - Field type.\n\t\t\t * @property {Object} config - Configuration object.\n\t\t\t * @property {string} config.label - Label displayed in the editor.\n\t\t\t * @property {string} [config.placeholder] - Placeholder text.\n\t\t\t * @property {number} [config.min] - Minimum allowable value.\n\t\t\t * @property {number} [config.max] - Maximum allowable value.\n\t\t\t */\n\t\t\ttype NumberField = {\n\t\t\t type: \"Number\";\n\t\t\t config: {\n\t\t\t\tlabel: string;\n\t\t\t\tplaceholder?: string;\n\t\t\t\tmin?: number;\n\t\t\t\tmax?: number;\n\t\t\t };\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents a Key Text Field in Prismic.\n\t\t\t * @property {\"Text\"} type - Field type.\n\t\t\t * @property {Object} config - Configuration object.\n\t\t\t * @property {string} config.label - Label displayed in the editor.\n\t\t\t * @property {string} [config.placeholder] - Placeholder text.\n\t\t\t */\n\t\t\ttype KeyTextField = {\n\t\t\t type: \"Text\";\n\t\t\t config: {\n\t\t\t\tlabel: string;\n\t\t\t\tplaceholder?: string;\n\t\t\t };\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents a Select Field in Prismic.\n\t\t\t * @property {\"Select\"} type - Field type.\n\t\t\t * @property {Object} config - Configuration object.\n\t\t\t * @property {string} config.label - Label displayed in the editor.\n\t\t\t * @property {string[]} config.options - Array of options for the select dropdown.\n\t\t\t */\n\t\t\ttype SelectField = {\n\t\t\t type: \"Select\";\n\t\t\t config: {\n\t\t\t\tlabel: string;\n\t\t\t\toptions: string[];\n\t\t\t };\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents a Structured Text Field in Prismic.\n\t\t\t * @property {\"StructuredText\"} type - Field type.\n\t\t\t * @property {Object} config - Configuration object.\n\t\t\t * @property {string} config.label - Label displayed in the editor.\n\t\t\t * @property {string} [config.placeholder] - Placeholder text.\n\t\t\t * @property {string} [config.single] - A comma-separated list of formatting options that does not allow line breaks. Options: paragraph | preformatted | heading1 | heading2 | heading3 | heading4 | heading5 | heading6 | strong | em | hyperlink | image | embed | list-item | o-list-item | rtl.\n\t\t\t * @property {string} [config.multi] - A comma-separated list of formatting options, with paragraph breaks allowed. Options: paragraph | preformatted | heading1 | heading2 | heading3 | heading4 | heading5 | heading6 | strong | em | hyperlink | image | embed | list-item | o-list-item | rtl.\n\t\t\t * @property {boolean} [config.allowTargetBlank] - Allows links to open in a new tab.\n\t\t\t * @property {string[]} [config.labels] - An array of strings to define labels for custom formatting.\n\t\t\t * @property {ImageConstraint} [config.imageConstraint] - Constraints for images within the rich text field.\n\t\t\t */\n\t\t\ttype StructuredTextField = {\n\t\t\t type: \"StructuredText\";\n\t\t\t config: {\n\t\t\t\tlabel: string;\n\t\t\t\tplaceholder?: string;\n\t\t\t\tsingle?: string;\n\t\t\t\tmulti?: string;\n\t\t\t\tallowTargetBlank?: boolean;\n\t\t\t\tlabels?: string[];\n\t\t\t\timageConstraint?: ImageConstraint;\n\t\t\t };\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents constraints for images within a rich text field.\n\t\t\t * @property {number} [width] - Width constraint in pixels.\n\t\t\t * @property {number\n\t\t\t * @property {number} [height] - Height constraint in pixels.\n\t\t\t */\n\t\t\ttype ImageConstraint = {\n\t\t\t width?: number;\n\t\t\t height?: number;\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents an Image Field in Prismic.\n\t\t\t * @property {\"Image\"} type - Field type.\n\t\t\t * @property {Object} config - Configuration object.\n\t\t\t * @property {string} config.label - Label displayed in the editor.\n\t\t\t * @property {Object} [config.constraint] - Constraints for the image dimensions.\n\t\t\t * @property {number} [config.constraint.width] - Width constraint.\n\t\t\t * @property {number} [config.constraint.height] - Height constraint.\n\t\t\t * @property {Thumbnail[]} [config.thumbnails] - Array of thumbnail configurations.\n\t\t\t */\n\t\t\ttype ImageField = {\n\t\t\t type: \"Image\";\n\t\t\t config: {\n\t\t\t\tlabel: string;\n\t\t\t\tconstraint?: {\n\t\t\t\t width?: number;\n\t\t\t\t height?: number;\n\t\t\t\t};\n\t\t\t\tthumbnails?: Thumbnail[];\n\t\t\t };\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents a Thumbnail configuration for an Image field.\n\t\t\t * @property {string} name - Name of the thumbnail.\n\t\t\t * @property {number} [width] - Width of the thumbnail in pixels.\n\t\t\t * @property {number} [height] - Height of the thumbnail in pixels.\n\t\t\t */\n\t\t\ttype Thumbnail = {\n\t\t\t name: string;\n\t\t\t width?: number;\n\t\t\t height?: number;\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents a Link Field in Prismic.\n\t\t\t * @property {\"Link\"} type - Field type.\n\t\t\t * @property {Object} config - Configuration object.\n\t\t\t * @property {string} config.label - Label displayed in the editor.\n\t\t\t * @property {\"web\" | \"document\" | \"media\"} config.select - Defines the type of link allowed.\n\t\t\t * @property {string[]} [config.customtypes] - Defines which Prismic document types are allowed if select is \"document\".\n\t\t\t */\n\t\t\ttype LinkField = {\n\t\t\t type: \"Link\";\n\t\t\t config: {\n\t\t\t\tlabel: string;\n\t\t\t\tselect: \"web\" | \"document\" | \"media\";\n\t\t\t\tcustomtypes?: string[];\n\t\t\t\tallowText: boolean;\n\t\t\t };\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents an Embed Field in Prismic.\n\t\t\t * @property {\"Embed\"} type - Field type.\n\t\t\t * @property {Object} config - Configuration object.\n\t\t\t * @property {string} config.label - Label displayed in the editor.\n\t\t\t */\n\t\t\ttype EmbedField = {\n\t\t\t type: \"Embed\";\n\t\t\t config: {\n\t\t\t\tlabel: string;\n\t\t\t };\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents a GeoPoint Field in Prismic.\n\t\t\t * @property {\"GeoPoint\"} type - Field type.\n\t\t\t * @property {Object} config - Configuration object.\n\t\t\t * @property {string} config.label - Label displayed in the editor.\n\t\t\t */\n\t\t\ttype GeoPointField = {\n\t\t\t type: \"GeoPoint\";\n\t\t\t config: {\n\t\t\t\tlabel: string;\n\t\t\t };\n\t\t\t};\n\t\t\t\n\t\t\t/**\n\t\t\t * Represents a Group Field (Repeatable Fields) in Prismic.\n\t\t\t * @property {\"Group\"} type - Field type.\n\t\t\t * @property {Object} config - Configuration object.\n\t\t\t * @property {string} config.label - Label displayed in the editor.\n\t\t\t * @property {Record<string, PrismicField>} config.fields - Defines the fields inside the group.\n\t\t\t */\n\t\t\ttype GroupField = {\n\t\t\t type: \"Group\";\n\t\t\t config: {\n\t\t\t\tlabel: string;\n\t\t\t\tfields: Record<string, PrismicField>;\n\t\t\t };\n\t\t\t};\n`;\n\t\t};\n\n\t\t/**\n\t\t * Builds the system prompt message using the generated TypeScript schema.\n\t\t */\n\t\tconst buildSystemMessage = (\n\t\t\tschema: string,\n\t\t\texistingSlice: SharedSlice,\n\t\t): string => {\n\t\t\treturn `\nYou are a world-class expert in creating Prismic Custom Type models for slices.\nYour task is to generate a valid Prismic JSON model based solely on the provided description and the TypeScript schema below.\nThe JSON model must adhere strictly to these rules:\n1. Include all necessary fields as described.\n2. Use the \"primary\" object for all main content fields.\n3. Do NOT use an \"items\" field. If a field represents a collection, it must be defined inside a Group field within the \"primary\" object.\n4. Ensure that each field has appropriate placeholders, labels, and configurations.\n5. If the existing slices contain fields, ensure to understand the user prompt to update the existing slice instead of creating something from scratch.\n6. If you detect the user wants to add a variation, always ensure the new variation is not exactly the same as another existing one\n7. Always return the full valid slice, as given in existing it should be returned in a valid format.\n8. If you detect the user prompt is about creating a totally different slice, do it and discard what was given in the existing slice, BUT only if you detect if nothing related.\n9. NEVER generate a Link / Button text field, ONLY the Link / Button field itself is enough. So ONE field just for the Link / Button. ENABLE \"allowText\" when doing that.\n10. AND THE MOST ULTRA IMPORTANT THING! Output ONLY a valid JSON object without any additional commentary or formatting! ONLY JSON, I need to parse it after with JSON.parse!\n\n### TypeScript Schema for reference:\n${schema}\n\n### Existing slice\n${JSON.stringify(existingSlice)}\n`.trim();\n\t\t};\n\n\t\t/**\n\t\t * Sends the prompt to AWS Bedrock and returns the generated Prismic JSON\n\t\t * model.\n\t\t */\n\t\tconst generatePrismicModel = async (\n\t\t\tuserPrompt: string,\n\t\t): Promise<string> => {\n\t\t\tconst schema = getSharedSliceSchema();\n\n\t\t\tconst systemMessage = buildSystemMessage(schema, args.slice);\n\n\t\t\tconst command = new ConverseCommand({\n\t\t\t\tmodelId: \"anthropic.claude-3-5-sonnet-20240620-v1:0\",\n\t\t\t\tsystem: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\tsystemMessage +\n\t\t\t\t\t\t\t(args.imageFile\n\t\t\t\t\t\t\t\t? `\n\t\t\t\t\t\t\t\t### Additional important rules\n\t\t\t\t\tA. SUPER IMPORTANT, you have to check and read the image and generate the model according to what is visible.\n\t\t\t\t\tB. You MUST understand that background image are just a simple image field. Don't try to do anything fancy with it, just a simple image field. \n\t\t\t\t\tC. Even if the background image looks like two image, be smart and detect if it's actually just one simple background that don't need a GROUP!\n\t\t\t\t\tD. NEVER EVER ADD decorative elements as detailled fields\n\t\t\t\t\t`\n\t\t\t\t\t\t\t\t: ``),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tmessages: [\n\t\t\t\t\targs.imageFile\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\timage: {\n\t\t\t\t\t\t\t\t\t\t\tformat: \"png\",\n\t\t\t\t\t\t\t\t\t\t\tsource: { bytes: args.imageFile } as any,\n\t\t\t\t\t\t\t\t\t\t},\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 }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttext: `Generate a valid Prismic JSON model based on the following description:\\n\\n${userPrompt}`,\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 },\n\t\t\t\t],\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\tconsole.log(\"Before sending command\");\n\t\t\t\tconst response = await bedrockClient.send(command);\n\t\t\t\tconsole.log(\"After response\", JSON.stringify(response));\n\n\t\t\t\tconst result = response.output?.message?.content?.[0]?.text?.trim();\n\t\t\t\tconsole.log(\"After sending command\");\n\t\t\t\tif (!result) {\n\t\t\t\t\tthrow new Error(\"No valid response received.\");\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(\"Error generating Prismic model:\", error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t};\n\n\t\tconst prismicModel = await generatePrismicModel(args.userPrompt);\n\n\t\tconsole.log(\"After saving slice\", prismicModel);\n\n\t\tconst newSlice = {\n\t\t\t...args.slice,\n\t\t\tvariations: JSON.parse(prismicModel).variations,\n\t\t};\n\n\t\tconst response = await this.updateSlice({\n\t\t\tlibraryID: args.libraryID,\n\t\t\tmodel: newSlice,\n\t\t});\n\n\t\tif (response.errors.length) {\n\t\t\treturn {\n\t\t\t\terrors: response.errors,\n\t\t\t};\n\t\t}\n\n\t\ttry {\n\t\t\tif (args.imageFile) {\n\t\t\t\tawait this.updateSliceScreenshot({\n\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\tsliceID: newSlice.id,\n\t\t\t\t\tvariationID: newSlice.variations[0].id,\n\t\t\t\t\tdata: args.imageFile,\n\t\t\t\t});\n\n\t\t\t\tconst extMocks = mockSlice({ model: newSlice });\n\t\t\t\tconsole.log(\"extMocks\", extMocks);\n\n\t\t\t\tconst command = new ConverseCommand({\n\t\t\t\t\tmodelId: \"anthropic.claude-3-5-sonnet-20240620-v1:0\",\n\t\t\t\t\tsystem: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttext: `\n# Task 1\nYou are a world-class expert in creating Prismic Mocks for slices.\nYour task is to generate a valid Prismic JSON mocks based solely on the provided existing mocks.\nThe goal is for you to take the image from the user input, detect the text and fill ensure the existing mock data is aligned with what is visible.\nDon't handle images.\nOnly handle text.\nIf you see a repetition with a group, you must create the same number of group items that are visible on the image.\nKEEP THE EXACT SAME STRUCTURE FOR THE MOCKS DATA, ONLY FILL IN THE TEXT FIELDS!\nAND ULTRA IMPORTANT! Output ONLY a valid JSON object without any additional commentary or formatting! ONLY JSON with the same existing mock format, I need to parse it after with JSON.parse!\n\n### Existing mocks\n${JSON.stringify(extMocks)}\n\nTHAT was your FIRST task!\n# Task 2\n\nNow you also have a second task, generating the slice code!\nGenerate fully isolated slice mock that don't require any package. The code is in React.\nYou have to ensure the mocks data will be the input of your code.\nUse the example of a slice fully isolated from bellow to help you know how to code a slice. But use the mocks data as input and the slice name etc.\nNEVER USE <style jsx> in the final code, just <style> is enough! It's important to not use <style jsx>!\nEnsure that the color used for the background is the same as the image provide in the user prompt! It's better no background color than a wrong one.\nYour goal is to make the code visually looks as close as possible to the image from the user input.\nAND ULTRA IMPORTANT! Output ONLY a valid React code without any additional commentary or formatting! Give me the code so I can just copy paste it into a React component file.\n\n### Tips\nFor links just use PrismicNextLink just pass the field, PrismicNextLink will handle the display of the link text.\nDO NOT TRY TO MANUALLY GO INSIDE THE LINK TO WRITE THE TEXT IT\"S DONE AUTOMATICALLY.\n\n### Example of a slice fully isolated \nimport { type Content } from \"@prismicio/client\";\nimport { PrismicNextLink, PrismicNextImage } from \"@prismicio/next\";\nimport { SliceComponentProps, PrismicRichText } from \"@prismicio/react\";\n\nexport type HeroProps = SliceComponentProps<Content.HeroSlice>;\n\nconst Hero = ({ slice }: HeroProps): JSX.Element => {\n return (\n <section\n data-slice-type={slice.slice_type}\n data-slice-variation={slice.variation}\n className=\"es-bounded es-fullpage-hero\"\n >\n <div\n className=\"es-fullpage-hero__content\"\n >\n <div>\n <PrismicNextImage\n field={slice.primary.image}\n className=\"es-fullpage-hero__image\"\n />\n </div>\n\n <div className=\"es-fullpage-hero__content-right\">\n <div className=\"es-fullpage-hero__content__intro\">\n <p className=\"es-fullpage-hero__content__intro__eyebrow\">\n {slice.primary.eyebrowHeadline}\n </p>\n \n <div className=\"es-fullpage-hero__content__intro__headline\">\n <PrismicRichText field={slice.primary.title} />\n </div>\n\n \n <div className=\"es-fullpage-hero__content__intro__description\">\n <PrismicRichText field={slice.primary.description} />\n </div>\n \n <PrismicNextLink\n className=\"es-call-to-action__link\"\n field={slice.primary.callToActionLink}\n />\n </div>\n </div>\n </div>\n <style>\n {\\`\n .es-bounded {\n margin: 0px;\n min-width: 0px;\n position: relative;\n }\n \n .es-fullpage-hero {\n font-family: system-ui, sans-serif;\n background-color: #fff;\n color: #333;\n }\n \n .es-fullpage-hero__image {\n max-width: 100%;\n height: auto;\n align-self: center;\n\t\t}\n \n .es-fullpage-hero__content {\n display: flex;\n flex-direction: column;\n gap: 2rem;\n }\n \n .es-fullpage-hero__content-right {\n display: flex;\n flex-direction: column;\n justify-content: space-around;\n padding: 1.5rem;\n }\n \n @media (min-width: 1080px) {\n .es-fullpage-hero__content {\n flex-direction: row;\n }\n \n .es-fullpage-hero__content > div {\n width: 50%;\n }\n }\n \n .es-fullpage-hero__content__intro {\n display: grid;\n gap: 1rem;\n }\n \n .es-fullpage-hero__content__intro__eyebrow {\n color: #47C1AF;\n font-size: 1.15rem;\n font-weight: 500;\n margin: 0;\n }\n \n .es-fullpage-hero__content__intro__headline {\n font-size: 1.625rem;\n font-weight: 700;\n }\n \n .es-fullpage-hero__content__intro__headline * {\n margin: 0;\n }\n \n @media (min-width: 640px) {\n .es-fullpage-hero__content__intro__headline {\n font-size: 2rem;\n }\n }\n \n @media (min-width: 1024px) {\n .es-fullpage-hero__content__intro__headline {\n font-size: 2.5rem;\n }\n }\n \n @media (min-width: 1200px) {\n .es-fullpage-hero__content__intro__headline {\n font-size: 2.75rem;\n }\n }\n \n .es-fullpage-hero__content__intro__description {\n font-size: 1.15rem;\n max-width: 38rem;\n }\n \n .es-fullpage-hero__content__intro__description > p {\n margin: 0;\n }\n \n @media (min-width: 1200px) {\n .es-fullpage-hero__content__intro__description {\n font-size: 1.4rem;\n }\n }\n\n .es-call-to-action__link {\n justify-self: flex-start;\n border-radius: 0.25rem;\n font-size: 0.875rem;\n line-height: 1.3;\n padding: 1rem 2.625rem;\n transition: background-color 100ms linear;\n background-color: #16745f;\n color: #fff;\n }\n \n .es-call-to-action__link:hover {\n background-color: #0d5e4c;\n }\n \\`}\n </style>\n </section>\n );\n};\n\nexport default Hero;\n\n\n# Final output of task 1 and 2\nReturn the task 1 and 2 output in a an object:\n{\n task1: <JSON of task 1 for the mocks>,\n task2: <plain string of the slice code for task 2>\n}\nTHIS IS THE MOST IMPORTANT THING, YOU NEED A VALID JSON, with task1 and task2 property. And the correct format for each of the two property.\n\t\t\t\t\t\t`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tmessages: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\timage: {\n\t\t\t\t\t\t\t\t\t\tformat: \"png\",\n\t\t\t\t\t\t\t\t\t\tsource: { bytes: args.imageFile } as any,\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\t\t\t\t\t],\n\t\t\t\t});\n\n\t\t\t\tconsole.log(\"Before sending mock command\");\n\t\t\t\tconst response = await bedrockClient.send(command);\n\t\t\t\tconsole.log(\"After response\", JSON.stringify(response));\n\n\t\t\t\tconst result = response.output?.message?.content?.[0]?.text?.trim();\n\t\t\t\tconsole.log(\"After sending mock command\");\n\n\t\t\t\tif (result) {\n\t\t\t\t\tawait this.updateSliceMocks({\n\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\tsliceID: newSlice.id,\n\t\t\t\t\t\tmocks: JSON.parse(result).task1,\n\t\t\t\t\t});\n\n\t\t\t\t\tawait this.sliceMachinePluginRunner.callHook(\"slice:update-code\", {\n\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\tmodel: newSlice,\n\t\t\t\t\t\tcomponentContents: JSON.parse(result).task2,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tconsole.log(\"Error\", e);\n\t\t}\n\n\t\treturn {\n\t\t\terrors: [],\n\t\t\tslice: newSlice,\n\t\t};\n\t}\n}\n"],"names":["errors","response"],"mappings":";;;;;;;;;;;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K,yBAAyB,SAAS,qBAAqB;AAAA,YACjE,WAAW,KAAK;AAAA,YAChB,OAAO;AAAA,YACP,mBAAmB,KAAK,MAAM,MAAM,EAAE;AAAA,UAAA,CACtC;AAAA,QACF;AAAA,MACD;AAAA,aACQ;AACA,cAAA,IAAI,SAAS,CAAC;AAAA,IACvB;AAEO,WAAA;AAAA,MACN,QAAQ,CAAE;AAAA,MACV,OAAO;AAAA,IAAA;AAAA,EAET;AACA;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@slicemachine/manager",
|
3
|
-
"version": "0.24.4-alpha.xru-
|
3
|
+
"version": "0.24.4-alpha.xru-poc-ai.1",
|
4
4
|
"description": "Manage all aspects of a Slice Machine project.",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -65,12 +65,13 @@
|
|
65
65
|
},
|
66
66
|
"dependencies": {
|
67
67
|
"@antfu/ni": "^0.20.0",
|
68
|
+
"@aws-sdk/client-bedrock-runtime": "3.744.0",
|
68
69
|
"@prismicio/client": "^7.11.0",
|
69
70
|
"@prismicio/custom-types-client": "2.1.0",
|
70
71
|
"@prismicio/mocks": "2.8.0",
|
71
72
|
"@prismicio/types-internal": "3.3.0",
|
72
73
|
"@segment/analytics-node": "^2.1.2",
|
73
|
-
"@slicemachine/plugin-kit": "0.4.66-alpha.xru-
|
74
|
+
"@slicemachine/plugin-kit": "0.4.66-alpha.xru-poc-ai.1",
|
74
75
|
"cookie": "^1.0.1",
|
75
76
|
"cors": "^2.8.5",
|
76
77
|
"execa": "^7.1.1",
|
@@ -89,7 +90,8 @@
|
|
89
90
|
"r19": "0.1.8",
|
90
91
|
"rc9": "^2.0.1",
|
91
92
|
"readable-web-to-node-stream": "^3.0.2",
|
92
|
-
"semver": "^7.3.8"
|
93
|
+
"semver": "^7.3.8",
|
94
|
+
"typescript-json-schema": "0.65.1"
|
93
95
|
},
|
94
96
|
"devDependencies": {
|
95
97
|
"@amplitude/experiment-node-server": "1.8.1",
|
@@ -87,8 +87,8 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
|
|
87
87
|
PrismicEmbed: "https://oembed.wroom.io",
|
88
88
|
PrismicUnsplash: "https://unsplash.wroom.io/",
|
89
89
|
SliceMachineV1: "https://sm-api.wroom.io/v1/",
|
90
|
-
RepositoryService: "https://
|
91
|
-
LocaleService: "https://
|
90
|
+
RepositoryService: "https://repository.internal.wroom.io/",
|
91
|
+
LocaleService: "https://locale.internal.wroom.io/",
|
92
92
|
};
|
93
93
|
}
|
94
94
|
|
@@ -104,8 +104,8 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
|
|
104
104
|
PrismicEmbed: `https://oembed.${process.env.SM_ENV}-wroom.com`,
|
105
105
|
PrismicUnsplash: `https://unsplash.${process.env.SM_ENV}-wroom.com/`,
|
106
106
|
SliceMachineV1: `https://sm-api.${process.env.SM_ENV}-wroom.com/v1/`,
|
107
|
-
RepositoryService: `https://
|
108
|
-
LocaleService: `https://
|
107
|
+
RepositoryService: `https://repository.internal.${process.env.SM_ENV}-wroom.com/`,
|
108
|
+
LocaleService: `https://locale.internal.${process.env.SM_ENV}-wroom.com/`,
|
109
109
|
};
|
110
110
|
}
|
111
111
|
|
@@ -120,8 +120,8 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
|
|
120
120
|
PrismicEmbed: "https://oembed.prismic.io",
|
121
121
|
PrismicUnsplash: "https://unsplash.prismic.io/",
|
122
122
|
SliceMachineV1: "https://sm-api.prismic.io/v1/",
|
123
|
-
RepositoryService: "https://
|
124
|
-
LocaleService: "https://
|
123
|
+
RepositoryService: "https://repository.internal.prismic.io/",
|
124
|
+
LocaleService: "https://locale.internal.prismic.io/",
|
125
125
|
};
|
126
126
|
}
|
127
127
|
}
|