@slicemachine/manager 0.24.4-alpha.xru-poc-ai.1 → 0.24.4-alpha.xru-kong-obelix-services.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,7 +14,6 @@ import { SLICE_MACHINE_USER_AGENT } from "../../constants/SLICE_MACHINE_USER_AGE
14
14
  import { API_ENDPOINTS } from "../../constants/API_ENDPOINTS.js";
15
15
  import { UnauthenticatedError, UnauthorizedError } from "../../errors.js";
16
16
  import { BaseManager } from "../BaseManager.js";
17
- import { BedrockRuntimeClient, ConverseCommand } from "@aws-sdk/client-bedrock-runtime";
18
17
  class SlicesManager extends BaseManager {
19
18
  async readSliceLibrary(args) {
20
19
  var _a;
@@ -636,683 +635,6 @@ class SlicesManager extends BaseManager {
636
635
  }));
637
636
  return { errors: customTypeReadErrors };
638
637
  }
639
- async generateSlice(args) {
640
- var _a, _b, _c, _d, _e;
641
- assertPluginsInitialized(this.sliceMachinePluginRunner);
642
- const AWS_REGION = "us-east-1";
643
- const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;
644
- const AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY;
645
- if (!AWS_ACCESS_KEY_ID || !AWS_SECRET_ACCESS_KEY) {
646
- throw new Error("AWS credentials are not set.");
647
- }
648
- const bedrockClient = new BedrockRuntimeClient({
649
- region: AWS_REGION,
650
- credentials: {
651
- accessKeyId: AWS_ACCESS_KEY_ID,
652
- secretAccessKey: AWS_SECRET_ACCESS_KEY
653
- }
654
- });
655
- const getSharedSliceSchema = () => {
656
- return `
657
-
658
- /**
659
- * Represents a Prismic Slice.
660
- * @property {string} type - Should always be "SharedSlice".
661
- * @property {string} id - Unique identifier for the slice in snake_case.
662
- * @property {string} name - Human-readable name in PascalCase.
663
- * @property {string} description - Brief explanation of the slice's purpose.
664
- * @property {SliceVariation[]} variations - Array of variations for the slice.
665
- */
666
- type PrismicSlice = {
667
- type: "SharedSlice";
668
- id: string;
669
- name: string;
670
- description: string;
671
- variations: SliceVariation[];
672
- };
673
-
674
- /**
675
- * Represents a variation of a Prismic Slice.
676
- * @property {string} id - Unique identifier for the variation in snake_case.
677
- * @property {string} name - Human-readable name in PascalCase.
678
- * @property {string} description - Brief explanation of the variation's purpose.
679
- * @property {string} docURL - Legacy property, required with an empty string.
680
- * @property {string} version - Legacy property, required with the name property value.
681
- * @property {Record<string, PrismicField>} [primary] - Primary fields defining the main content of the slice.
682
- */
683
- type SliceVariation = {
684
- id: string;
685
- name: string;
686
- description: string;
687
- primary: Record<string, PrismicField>;
688
- docURL: string;
689
- version: string;
690
- };
691
-
692
- /**
693
- * Union type representing all possible Prismic fields.
694
- */
695
- type PrismicField =
696
- | UIDField
697
- | BooleanField
698
- | ColorField
699
- | DateField
700
- | TimestampField
701
- | NumberField
702
- | KeyTextField
703
- | SelectField
704
- | StructuredTextField
705
- | ImageField
706
- | LinkField
707
- | GeoPointField
708
- | EmbedField
709
- | GroupField;
710
-
711
- /**
712
- * Represents a UID Field in Prismic.
713
- * @property {"UID"} type - Field type.
714
- * @property {Object} config - Configuration object.
715
- * @property {string} config.label - Label displayed in the editor.
716
- * @property {string} [config.placeholder] - Placeholder text.
717
- * @property {string} [config.customregex] - Custom regex for validation.
718
- * @property {string} [config.errorMessage] - Error message for invalid input.
719
- */
720
- type UIDField = {
721
- type: "UID";
722
- config: {
723
- label: string;
724
- placeholder?: string;
725
- customregex?: string;
726
- errorMessage?: string;
727
- };
728
- };
729
-
730
- /**
731
- * Represents a Boolean Field in Prismic.
732
- * @property {"Boolean"} type - Field type.
733
- * @property {Object} config - Configuration object.
734
- * @property {string} config.label - Label displayed in the editor.
735
- * @property {boolean} [config.default_value] - Default value (true or false).
736
- */
737
- type BooleanField = {
738
- type: "Boolean";
739
- config: {
740
- label: string;
741
- default_value?: boolean;
742
- };
743
- };
744
-
745
- /**
746
- * Represents a Color Field in Prismic.
747
- * @property {"Color"} type - Field type.
748
- * @property {Object} config - Configuration object.
749
- * @property {string} config.label - Label displayed in the editor.
750
- */
751
- type ColorField = {
752
- type: "Color";
753
- config: {
754
- label: string;
755
- };
756
- };
757
-
758
- /**
759
- * Represents a Date Field in Prismic.
760
- * @property {"Date"} type - Field type.
761
- * @property {Object} config - Configuration object.
762
- * @property {string} config.label - Label displayed in the editor.
763
- */
764
- type DateField = {
765
- type: "Date";
766
- config: {
767
- label: string;
768
- };
769
- };
770
-
771
- /**
772
- * Represents a Timestamp Field in Prismic.
773
- * @property {"Timestamp"} type - Field type.
774
- * @property {Object} config - Configuration object.
775
- * @property {string} config.label - Label displayed in the editor.
776
- */
777
- type TimestampField = {
778
- type: "Timestamp";
779
- config: {
780
- label: string;
781
- };
782
- };
783
-
784
- /**
785
- * Represents a Number Field in Prismic.
786
- * @property {"Number"} type - Field type.
787
- * @property {Object} config - Configuration object.
788
- * @property {string} config.label - Label displayed in the editor.
789
- * @property {string} [config.placeholder] - Placeholder text.
790
- * @property {number} [config.min] - Minimum allowable value.
791
- * @property {number} [config.max] - Maximum allowable value.
792
- */
793
- type NumberField = {
794
- type: "Number";
795
- config: {
796
- label: string;
797
- placeholder?: string;
798
- min?: number;
799
- max?: number;
800
- };
801
- };
802
-
803
- /**
804
- * Represents a Key Text Field in Prismic.
805
- * @property {"Text"} type - Field type.
806
- * @property {Object} config - Configuration object.
807
- * @property {string} config.label - Label displayed in the editor.
808
- * @property {string} [config.placeholder] - Placeholder text.
809
- */
810
- type KeyTextField = {
811
- type: "Text";
812
- config: {
813
- label: string;
814
- placeholder?: string;
815
- };
816
- };
817
-
818
- /**
819
- * Represents a Select Field in Prismic.
820
- * @property {"Select"} type - Field type.
821
- * @property {Object} config - Configuration object.
822
- * @property {string} config.label - Label displayed in the editor.
823
- * @property {string[]} config.options - Array of options for the select dropdown.
824
- */
825
- type SelectField = {
826
- type: "Select";
827
- config: {
828
- label: string;
829
- options: string[];
830
- };
831
- };
832
-
833
- /**
834
- * Represents a Structured Text Field in Prismic.
835
- * @property {"StructuredText"} type - Field type.
836
- * @property {Object} config - Configuration object.
837
- * @property {string} config.label - Label displayed in the editor.
838
- * @property {string} [config.placeholder] - Placeholder text.
839
- * @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.
840
- * @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.
841
- * @property {boolean} [config.allowTargetBlank] - Allows links to open in a new tab.
842
- * @property {string[]} [config.labels] - An array of strings to define labels for custom formatting.
843
- * @property {ImageConstraint} [config.imageConstraint] - Constraints for images within the rich text field.
844
- */
845
- type StructuredTextField = {
846
- type: "StructuredText";
847
- config: {
848
- label: string;
849
- placeholder?: string;
850
- single?: string;
851
- multi?: string;
852
- allowTargetBlank?: boolean;
853
- labels?: string[];
854
- imageConstraint?: ImageConstraint;
855
- };
856
- };
857
-
858
- /**
859
- * Represents constraints for images within a rich text field.
860
- * @property {number} [width] - Width constraint in pixels.
861
- * @property {number
862
- * @property {number} [height] - Height constraint in pixels.
863
- */
864
- type ImageConstraint = {
865
- width?: number;
866
- height?: number;
867
- };
868
-
869
- /**
870
- * Represents an Image Field in Prismic.
871
- * @property {"Image"} type - Field type.
872
- * @property {Object} config - Configuration object.
873
- * @property {string} config.label - Label displayed in the editor.
874
- * @property {Object} [config.constraint] - Constraints for the image dimensions.
875
- * @property {number} [config.constraint.width] - Width constraint.
876
- * @property {number} [config.constraint.height] - Height constraint.
877
- * @property {Thumbnail[]} [config.thumbnails] - Array of thumbnail configurations.
878
- */
879
- type ImageField = {
880
- type: "Image";
881
- config: {
882
- label: string;
883
- constraint?: {
884
- width?: number;
885
- height?: number;
886
- };
887
- thumbnails?: Thumbnail[];
888
- };
889
- };
890
-
891
- /**
892
- * Represents a Thumbnail configuration for an Image field.
893
- * @property {string} name - Name of the thumbnail.
894
- * @property {number} [width] - Width of the thumbnail in pixels.
895
- * @property {number} [height] - Height of the thumbnail in pixels.
896
- */
897
- type Thumbnail = {
898
- name: string;
899
- width?: number;
900
- height?: number;
901
- };
902
-
903
- /**
904
- * Represents a Link Field in Prismic.
905
- * @property {"Link"} type - Field type.
906
- * @property {Object} config - Configuration object.
907
- * @property {string} config.label - Label displayed in the editor.
908
- * @property {"web" | "document" | "media"} config.select - Defines the type of link allowed.
909
- * @property {string[]} [config.customtypes] - Defines which Prismic document types are allowed if select is "document".
910
- */
911
- type LinkField = {
912
- type: "Link";
913
- config: {
914
- label: string;
915
- select: "web" | "document" | "media";
916
- customtypes?: string[];
917
- allowText: boolean;
918
- };
919
- };
920
-
921
- /**
922
- * Represents an Embed Field in Prismic.
923
- * @property {"Embed"} type - Field type.
924
- * @property {Object} config - Configuration object.
925
- * @property {string} config.label - Label displayed in the editor.
926
- */
927
- type EmbedField = {
928
- type: "Embed";
929
- config: {
930
- label: string;
931
- };
932
- };
933
-
934
- /**
935
- * Represents a GeoPoint Field in Prismic.
936
- * @property {"GeoPoint"} type - Field type.
937
- * @property {Object} config - Configuration object.
938
- * @property {string} config.label - Label displayed in the editor.
939
- */
940
- type GeoPointField = {
941
- type: "GeoPoint";
942
- config: {
943
- label: string;
944
- };
945
- };
946
-
947
- /**
948
- * Represents a Group Field (Repeatable Fields) in Prismic.
949
- * @property {"Group"} type - Field type.
950
- * @property {Object} config - Configuration object.
951
- * @property {string} config.label - Label displayed in the editor.
952
- * @property {Record<string, PrismicField>} config.fields - Defines the fields inside the group.
953
- */
954
- type GroupField = {
955
- type: "Group";
956
- config: {
957
- label: string;
958
- fields: Record<string, PrismicField>;
959
- };
960
- };
961
- `;
962
- };
963
- const buildSystemMessage = (schema, existingSlice) => {
964
- return `
965
- You are a world-class expert in creating Prismic Custom Type models for slices.
966
- Your task is to generate a valid Prismic JSON model based solely on the provided description and the TypeScript schema below.
967
- The JSON model must adhere strictly to these rules:
968
- 1. Include all necessary fields as described.
969
- 2. Use the "primary" object for all main content fields.
970
- 3. Do NOT use an "items" field. If a field represents a collection, it must be defined inside a Group field within the "primary" object.
971
- 4. Ensure that each field has appropriate placeholders, labels, and configurations.
972
- 5. If the existing slices contain fields, ensure to understand the user prompt to update the existing slice instead of creating something from scratch.
973
- 6. If you detect the user wants to add a variation, always ensure the new variation is not exactly the same as another existing one
974
- 7. Always return the full valid slice, as given in existing it should be returned in a valid format.
975
- 8. 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.
976
- 9. 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.
977
- 10. 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!
978
-
979
- ### TypeScript Schema for reference:
980
- ${schema}
981
-
982
- ### Existing slice
983
- ${JSON.stringify(existingSlice)}
984
- `.trim();
985
- };
986
- const generatePrismicModel = async (userPrompt) => {
987
- var _a2, _b2, _c2, _d2, _e2;
988
- const schema = getSharedSliceSchema();
989
- const systemMessage = buildSystemMessage(schema, args.slice);
990
- const command = new ConverseCommand({
991
- modelId: "anthropic.claude-3-5-sonnet-20240620-v1:0",
992
- system: [
993
- {
994
- text: systemMessage + (args.imageFile ? `
995
- ### Additional important rules
996
- A. SUPER IMPORTANT, you have to check and read the image and generate the model according to what is visible.
997
- B. 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.
998
- C. 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!
999
- D. NEVER EVER ADD decorative elements as detailled fields
1000
- ` : ``)
1001
- }
1002
- ],
1003
- messages: [
1004
- args.imageFile ? {
1005
- role: "user",
1006
- content: [
1007
- {
1008
- image: {
1009
- format: "png",
1010
- source: { bytes: args.imageFile }
1011
- }
1012
- }
1013
- ]
1014
- } : {
1015
- role: "user",
1016
- content: [
1017
- {
1018
- text: `Generate a valid Prismic JSON model based on the following description:
1019
-
1020
- ${userPrompt}`
1021
- }
1022
- ]
1023
- }
1024
- ]
1025
- });
1026
- try {
1027
- console.log("Before sending command");
1028
- const response2 = await bedrockClient.send(command);
1029
- console.log("After response", JSON.stringify(response2));
1030
- const result = (_e2 = (_d2 = (_c2 = (_b2 = (_a2 = response2.output) == null ? void 0 : _a2.message) == null ? void 0 : _b2.content) == null ? void 0 : _c2[0]) == null ? void 0 : _d2.text) == null ? void 0 : _e2.trim();
1031
- console.log("After sending command");
1032
- if (!result) {
1033
- throw new Error("No valid response received.");
1034
- }
1035
- return result;
1036
- } catch (error) {
1037
- console.error("Error generating Prismic model:", error);
1038
- throw error;
1039
- }
1040
- };
1041
- const prismicModel = await generatePrismicModel(args.userPrompt);
1042
- console.log("After saving slice", prismicModel);
1043
- const newSlice = {
1044
- ...args.slice,
1045
- variations: JSON.parse(prismicModel).variations
1046
- };
1047
- const response = await this.updateSlice({
1048
- libraryID: args.libraryID,
1049
- model: newSlice
1050
- });
1051
- if (response.errors.length) {
1052
- return {
1053
- errors: response.errors
1054
- };
1055
- }
1056
- try {
1057
- if (args.imageFile) {
1058
- await this.updateSliceScreenshot({
1059
- libraryID: args.libraryID,
1060
- sliceID: newSlice.id,
1061
- variationID: newSlice.variations[0].id,
1062
- data: args.imageFile
1063
- });
1064
- const extMocks = mockSlice({ model: newSlice });
1065
- console.log("extMocks", extMocks);
1066
- const command = new ConverseCommand({
1067
- modelId: "anthropic.claude-3-5-sonnet-20240620-v1:0",
1068
- system: [
1069
- {
1070
- text: `
1071
- # Task 1
1072
- You are a world-class expert in creating Prismic Mocks for slices.
1073
- Your task is to generate a valid Prismic JSON mocks based solely on the provided existing mocks.
1074
- The 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.
1075
- Don't handle images.
1076
- Only handle text.
1077
- If you see a repetition with a group, you must create the same number of group items that are visible on the image.
1078
- KEEP THE EXACT SAME STRUCTURE FOR THE MOCKS DATA, ONLY FILL IN THE TEXT FIELDS!
1079
- AND 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!
1080
-
1081
- ### Existing mocks
1082
- ${JSON.stringify(extMocks)}
1083
-
1084
- THAT was your FIRST task!
1085
- # Task 2
1086
-
1087
- Now you also have a second task, generating the slice code!
1088
- Generate fully isolated slice mock that don't require any package. The code is in React.
1089
- You have to ensure the mocks data will be the input of your code.
1090
- Use 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.
1091
- NEVER USE <style jsx> in the final code, just <style> is enough! It's important to not use <style jsx>!
1092
- Ensure 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.
1093
- Your goal is to make the code visually looks as close as possible to the image from the user input.
1094
- AND 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.
1095
-
1096
- ### Tips
1097
- For links just use PrismicNextLink just pass the field, PrismicNextLink will handle the display of the link text.
1098
- DO NOT TRY TO MANUALLY GO INSIDE THE LINK TO WRITE THE TEXT IT"S DONE AUTOMATICALLY.
1099
-
1100
- ### Example of a slice fully isolated
1101
- import { type Content } from "@prismicio/client";
1102
- import { PrismicNextLink, PrismicNextImage } from "@prismicio/next";
1103
- import { SliceComponentProps, PrismicRichText } from "@prismicio/react";
1104
-
1105
- export type HeroProps = SliceComponentProps<Content.HeroSlice>;
1106
-
1107
- const Hero = ({ slice }: HeroProps): JSX.Element => {
1108
- return (
1109
- <section
1110
- data-slice-type={slice.slice_type}
1111
- data-slice-variation={slice.variation}
1112
- className="es-bounded es-fullpage-hero"
1113
- >
1114
- <div
1115
- className="es-fullpage-hero__content"
1116
- >
1117
- <div>
1118
- <PrismicNextImage
1119
- field={slice.primary.image}
1120
- className="es-fullpage-hero__image"
1121
- />
1122
- </div>
1123
-
1124
- <div className="es-fullpage-hero__content-right">
1125
- <div className="es-fullpage-hero__content__intro">
1126
- <p className="es-fullpage-hero__content__intro__eyebrow">
1127
- {slice.primary.eyebrowHeadline}
1128
- </p>
1129
-
1130
- <div className="es-fullpage-hero__content__intro__headline">
1131
- <PrismicRichText field={slice.primary.title} />
1132
- </div>
1133
-
1134
-
1135
- <div className="es-fullpage-hero__content__intro__description">
1136
- <PrismicRichText field={slice.primary.description} />
1137
- </div>
1138
-
1139
- <PrismicNextLink
1140
- className="es-call-to-action__link"
1141
- field={slice.primary.callToActionLink}
1142
- />
1143
- </div>
1144
- </div>
1145
- </div>
1146
- <style>
1147
- {\`
1148
- .es-bounded {
1149
- margin: 0px;
1150
- min-width: 0px;
1151
- position: relative;
1152
- }
1153
-
1154
- .es-fullpage-hero {
1155
- font-family: system-ui, sans-serif;
1156
- background-color: #fff;
1157
- color: #333;
1158
- }
1159
-
1160
- .es-fullpage-hero__image {
1161
- max-width: 100%;
1162
- height: auto;
1163
- align-self: center;
1164
- }
1165
-
1166
- .es-fullpage-hero__content {
1167
- display: flex;
1168
- flex-direction: column;
1169
- gap: 2rem;
1170
- }
1171
-
1172
- .es-fullpage-hero__content-right {
1173
- display: flex;
1174
- flex-direction: column;
1175
- justify-content: space-around;
1176
- padding: 1.5rem;
1177
- }
1178
-
1179
- @media (min-width: 1080px) {
1180
- .es-fullpage-hero__content {
1181
- flex-direction: row;
1182
- }
1183
-
1184
- .es-fullpage-hero__content > div {
1185
- width: 50%;
1186
- }
1187
- }
1188
-
1189
- .es-fullpage-hero__content__intro {
1190
- display: grid;
1191
- gap: 1rem;
1192
- }
1193
-
1194
- .es-fullpage-hero__content__intro__eyebrow {
1195
- color: #47C1AF;
1196
- font-size: 1.15rem;
1197
- font-weight: 500;
1198
- margin: 0;
1199
- }
1200
-
1201
- .es-fullpage-hero__content__intro__headline {
1202
- font-size: 1.625rem;
1203
- font-weight: 700;
1204
- }
1205
-
1206
- .es-fullpage-hero__content__intro__headline * {
1207
- margin: 0;
1208
- }
1209
-
1210
- @media (min-width: 640px) {
1211
- .es-fullpage-hero__content__intro__headline {
1212
- font-size: 2rem;
1213
- }
1214
- }
1215
-
1216
- @media (min-width: 1024px) {
1217
- .es-fullpage-hero__content__intro__headline {
1218
- font-size: 2.5rem;
1219
- }
1220
- }
1221
-
1222
- @media (min-width: 1200px) {
1223
- .es-fullpage-hero__content__intro__headline {
1224
- font-size: 2.75rem;
1225
- }
1226
- }
1227
-
1228
- .es-fullpage-hero__content__intro__description {
1229
- font-size: 1.15rem;
1230
- max-width: 38rem;
1231
- }
1232
-
1233
- .es-fullpage-hero__content__intro__description > p {
1234
- margin: 0;
1235
- }
1236
-
1237
- @media (min-width: 1200px) {
1238
- .es-fullpage-hero__content__intro__description {
1239
- font-size: 1.4rem;
1240
- }
1241
- }
1242
-
1243
- .es-call-to-action__link {
1244
- justify-self: flex-start;
1245
- border-radius: 0.25rem;
1246
- font-size: 0.875rem;
1247
- line-height: 1.3;
1248
- padding: 1rem 2.625rem;
1249
- transition: background-color 100ms linear;
1250
- background-color: #16745f;
1251
- color: #fff;
1252
- }
1253
-
1254
- .es-call-to-action__link:hover {
1255
- background-color: #0d5e4c;
1256
- }
1257
- \`}
1258
- </style>
1259
- </section>
1260
- );
1261
- };
1262
-
1263
- export default Hero;
1264
-
1265
-
1266
- # Final output of task 1 and 2
1267
- Return the task 1 and 2 output in a an object:
1268
- {
1269
- task1: <JSON of task 1 for the mocks>,
1270
- task2: <plain string of the slice code for task 2>
1271
- }
1272
- THIS 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.
1273
- `
1274
- }
1275
- ],
1276
- messages: [
1277
- {
1278
- role: "user",
1279
- content: [
1280
- {
1281
- image: {
1282
- format: "png",
1283
- source: { bytes: args.imageFile }
1284
- }
1285
- }
1286
- ]
1287
- }
1288
- ]
1289
- });
1290
- console.log("Before sending mock command");
1291
- const response2 = await bedrockClient.send(command);
1292
- console.log("After response", JSON.stringify(response2));
1293
- const result = (_e = (_d = (_c = (_b = (_a = response2.output) == null ? void 0 : _a.message) == null ? void 0 : _b.content) == null ? void 0 : _c[0]) == null ? void 0 : _d.text) == null ? void 0 : _e.trim();
1294
- console.log("After sending mock command");
1295
- if (result) {
1296
- await this.updateSliceMocks({
1297
- libraryID: args.libraryID,
1298
- sliceID: newSlice.id,
1299
- mocks: JSON.parse(result).task1
1300
- });
1301
- await this.sliceMachinePluginRunner.callHook("slice:update-code", {
1302
- libraryID: args.libraryID,
1303
- model: newSlice,
1304
- componentContents: JSON.parse(result).task2
1305
- });
1306
- }
1307
- }
1308
- } catch (e) {
1309
- console.log("Error", e);
1310
- }
1311
- return {
1312
- errors: [],
1313
- slice: newSlice
1314
- };
1315
- }
1316
638
  }
1317
639
  export {
1318
640
  SlicesManager