@aws-amplify/data-schema 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/dist/cjs/ClientSchema/ai/ClientConversation.js +6 -0
  2. package/dist/cjs/ClientSchema/ai/ClientConversation.js.map +1 -0
  3. package/dist/cjs/CustomOperation.js +22 -2
  4. package/dist/cjs/CustomOperation.js.map +1 -1
  5. package/dist/cjs/SchemaProcessor.js +41 -5
  6. package/dist/cjs/SchemaProcessor.js.map +1 -1
  7. package/dist/cjs/a.js +9 -1
  8. package/dist/cjs/a.js.map +1 -1
  9. package/dist/cjs/ai/ConversationSchemaTypes.js +210 -0
  10. package/dist/cjs/ai/ConversationSchemaTypes.js.map +1 -0
  11. package/dist/cjs/ai/ConversationType.js +27 -0
  12. package/dist/cjs/ai/ConversationType.js.map +1 -0
  13. package/dist/cjs/ai/ModelType.js +37 -0
  14. package/dist/cjs/ai/ModelType.js.map +1 -0
  15. package/dist/cjs/ai/types/ConversationMessageContent.js +6 -0
  16. package/dist/cjs/ai/types/ConversationMessageContent.js.map +1 -0
  17. package/dist/cjs/ai/types/ToolConfiguration.js +6 -0
  18. package/dist/cjs/ai/types/ToolConfiguration.js.map +1 -0
  19. package/dist/cjs/ai/types/ToolResultContent.js +6 -0
  20. package/dist/cjs/ai/types/ToolResultContent.js.map +1 -0
  21. package/dist/cjs/ai/types/contentBlocks.js +6 -0
  22. package/dist/cjs/ai/types/contentBlocks.js.map +1 -0
  23. package/dist/cjs/runtime/addSchemaToClient.js +2 -0
  24. package/dist/cjs/runtime/addSchemaToClient.js.map +1 -1
  25. package/dist/cjs/runtime/internals/APIClient.js +3 -3
  26. package/dist/cjs/runtime/internals/APIClient.js.map +1 -1
  27. package/dist/cjs/runtime/internals/ai/conversationMessageDeserializers.js +54 -0
  28. package/dist/cjs/runtime/internals/ai/conversationMessageDeserializers.js.map +1 -0
  29. package/dist/cjs/runtime/internals/ai/conversationMessageSerializers.js +58 -0
  30. package/dist/cjs/runtime/internals/ai/conversationMessageSerializers.js.map +1 -0
  31. package/dist/cjs/runtime/internals/ai/convertItemToConversation.js +22 -0
  32. package/dist/cjs/runtime/internals/ai/convertItemToConversation.js.map +1 -0
  33. package/dist/cjs/runtime/internals/ai/convertItemToConversationMessage.js +16 -0
  34. package/dist/cjs/runtime/internals/ai/convertItemToConversationMessage.js.map +1 -0
  35. package/dist/cjs/runtime/internals/ai/createCreateConversationFunction.js +18 -0
  36. package/dist/cjs/runtime/internals/ai/createCreateConversationFunction.js.map +1 -0
  37. package/dist/cjs/runtime/internals/ai/createGetConversationFunction.js +20 -0
  38. package/dist/cjs/runtime/internals/ai/createGetConversationFunction.js.map +1 -0
  39. package/dist/cjs/runtime/internals/ai/createListConversationsFunction.js +21 -0
  40. package/dist/cjs/runtime/internals/ai/createListConversationsFunction.js.map +1 -0
  41. package/dist/cjs/runtime/internals/ai/createListMessagesFunction.js +22 -0
  42. package/dist/cjs/runtime/internals/ai/createListMessagesFunction.js.map +1 -0
  43. package/dist/cjs/runtime/internals/ai/createOnMessageFunction.js +22 -0
  44. package/dist/cjs/runtime/internals/ai/createOnMessageFunction.js.map +1 -0
  45. package/dist/cjs/runtime/internals/ai/createSendMessageFunction.js +32 -0
  46. package/dist/cjs/runtime/internals/ai/createSendMessageFunction.js.map +1 -0
  47. package/dist/cjs/runtime/internals/index.js +5 -1
  48. package/dist/cjs/runtime/internals/index.js.map +1 -1
  49. package/dist/cjs/runtime/internals/operations/custom.js +17 -10
  50. package/dist/cjs/runtime/internals/operations/custom.js.map +1 -1
  51. package/dist/cjs/runtime/internals/utils/clientProperties/generateConversationsProperty.js +48 -0
  52. package/dist/cjs/runtime/internals/utils/clientProperties/generateConversationsProperty.js.map +1 -0
  53. package/dist/cjs/runtime/internals/utils/clientProperties/generateGenerationsProperty.js +22 -0
  54. package/dist/cjs/runtime/internals/utils/clientProperties/generateGenerationsProperty.js.map +1 -0
  55. package/dist/esm/ClientSchema/Core/ClientSchemaProperty.d.ts +1 -1
  56. package/dist/esm/ClientSchema/ai/ClientConversation.d.ts +7 -0
  57. package/dist/esm/ClientSchema/ai/ClientConversation.mjs +2 -0
  58. package/dist/esm/ClientSchema/ai/ClientConversation.mjs.map +1 -0
  59. package/dist/esm/ClientSchema/index.d.ts +12 -2
  60. package/dist/esm/CustomOperation.d.ts +33 -2
  61. package/dist/esm/CustomOperation.mjs +21 -2
  62. package/dist/esm/CustomOperation.mjs.map +1 -1
  63. package/dist/esm/ModelSchema.d.ts +3 -1
  64. package/dist/esm/SchemaProcessor.d.ts +1 -1
  65. package/dist/esm/SchemaProcessor.mjs +41 -5
  66. package/dist/esm/SchemaProcessor.mjs.map +1 -1
  67. package/dist/esm/a.d.ts +7 -2
  68. package/dist/esm/a.mjs +9 -1
  69. package/dist/esm/a.mjs.map +1 -1
  70. package/dist/esm/ai/ConversationSchemaTypes.d.ts +3 -0
  71. package/dist/esm/ai/ConversationSchemaTypes.mjs +208 -0
  72. package/dist/esm/ai/ConversationSchemaTypes.mjs.map +1 -0
  73. package/dist/esm/ai/ConversationType.d.ts +102 -0
  74. package/dist/esm/ai/ConversationType.mjs +25 -0
  75. package/dist/esm/ai/ConversationType.mjs.map +1 -0
  76. package/dist/esm/ai/ModelType.d.ts +30 -0
  77. package/dist/esm/ai/ModelType.mjs +34 -0
  78. package/dist/esm/ai/ModelType.mjs.map +1 -0
  79. package/dist/esm/ai/types/ConversationMessageContent.d.ts +27 -0
  80. package/dist/esm/ai/types/ConversationMessageContent.mjs +2 -0
  81. package/dist/esm/ai/types/ConversationMessageContent.mjs.map +1 -0
  82. package/dist/esm/ai/types/ToolConfiguration.d.ts +18 -0
  83. package/dist/esm/ai/types/ToolConfiguration.mjs +2 -0
  84. package/dist/esm/ai/types/ToolConfiguration.mjs.map +1 -0
  85. package/dist/esm/ai/types/ToolResultContent.d.ts +18 -0
  86. package/dist/esm/ai/types/ToolResultContent.mjs +2 -0
  87. package/dist/esm/ai/types/ToolResultContent.mjs.map +1 -0
  88. package/dist/esm/ai/types/contentBlocks.d.ts +19 -0
  89. package/dist/esm/ai/types/contentBlocks.mjs +2 -0
  90. package/dist/esm/ai/types/contentBlocks.mjs.map +1 -0
  91. package/dist/esm/runtime/addSchemaToClient.mjs +4 -0
  92. package/dist/esm/runtime/addSchemaToClient.mjs.map +1 -1
  93. package/dist/esm/runtime/addSchemaToClientWithInstance.mjs +2 -1
  94. package/dist/esm/runtime/addSchemaToClientWithInstance.mjs.map +1 -1
  95. package/dist/esm/runtime/bridge-types.d.ts +29 -3
  96. package/dist/esm/runtime/client/index.d.ts +35 -19
  97. package/dist/esm/runtime/internals/APIClient.mjs +3 -3
  98. package/dist/esm/runtime/internals/APIClient.mjs.map +1 -1
  99. package/dist/esm/runtime/internals/ai/conversationMessageDeserializers.d.ts +2 -0
  100. package/dist/esm/runtime/internals/ai/conversationMessageDeserializers.mjs +52 -0
  101. package/dist/esm/runtime/internals/ai/conversationMessageDeserializers.mjs.map +1 -0
  102. package/dist/esm/runtime/internals/ai/conversationMessageSerializers.d.ts +37 -0
  103. package/dist/esm/runtime/internals/ai/conversationMessageSerializers.mjs +54 -0
  104. package/dist/esm/runtime/internals/ai/conversationMessageSerializers.mjs.map +1 -0
  105. package/dist/esm/runtime/internals/ai/convertItemToConversation.d.ts +3 -0
  106. package/dist/esm/runtime/internals/ai/convertItemToConversation.mjs +20 -0
  107. package/dist/esm/runtime/internals/ai/convertItemToConversation.mjs.map +1 -0
  108. package/dist/esm/runtime/internals/ai/convertItemToConversationMessage.d.ts +7 -0
  109. package/dist/esm/runtime/internals/ai/convertItemToConversationMessage.mjs +14 -0
  110. package/dist/esm/runtime/internals/ai/convertItemToConversationMessage.mjs.map +1 -0
  111. package/dist/esm/runtime/internals/ai/createCreateConversationFunction.d.ts +3 -0
  112. package/dist/esm/runtime/internals/ai/createCreateConversationFunction.mjs +16 -0
  113. package/dist/esm/runtime/internals/ai/createCreateConversationFunction.mjs.map +1 -0
  114. package/dist/esm/runtime/internals/ai/createGetConversationFunction.d.ts +3 -0
  115. package/dist/esm/runtime/internals/ai/createGetConversationFunction.mjs +18 -0
  116. package/dist/esm/runtime/internals/ai/createGetConversationFunction.mjs.map +1 -0
  117. package/dist/esm/runtime/internals/ai/createListConversationsFunction.d.ts +3 -0
  118. package/dist/esm/runtime/internals/ai/createListConversationsFunction.mjs +19 -0
  119. package/dist/esm/runtime/internals/ai/createListConversationsFunction.mjs.map +1 -0
  120. package/dist/esm/runtime/internals/ai/createListMessagesFunction.d.ts +3 -0
  121. package/dist/esm/runtime/internals/ai/createListMessagesFunction.mjs +20 -0
  122. package/dist/esm/runtime/internals/ai/createListMessagesFunction.mjs.map +1 -0
  123. package/dist/esm/runtime/internals/ai/createOnMessageFunction.d.ts +3 -0
  124. package/dist/esm/runtime/internals/ai/createOnMessageFunction.mjs +20 -0
  125. package/dist/esm/runtime/internals/ai/createOnMessageFunction.mjs.map +1 -0
  126. package/dist/esm/runtime/internals/ai/createSendMessageFunction.d.ts +3 -0
  127. package/dist/esm/runtime/internals/ai/createSendMessageFunction.mjs +30 -0
  128. package/dist/esm/runtime/internals/ai/createSendMessageFunction.mjs.map +1 -0
  129. package/dist/esm/runtime/internals/index.d.ts +2 -0
  130. package/dist/esm/runtime/internals/index.mjs +2 -0
  131. package/dist/esm/runtime/internals/index.mjs.map +1 -1
  132. package/dist/esm/runtime/internals/operations/custom.d.ts +1 -1
  133. package/dist/esm/runtime/internals/operations/custom.mjs +17 -10
  134. package/dist/esm/runtime/internals/operations/custom.mjs.map +1 -1
  135. package/dist/esm/runtime/internals/utils/clientProperties/generateConversationsProperty.d.ts +3 -0
  136. package/dist/esm/runtime/internals/utils/clientProperties/generateConversationsProperty.mjs +46 -0
  137. package/dist/esm/runtime/internals/utils/clientProperties/generateConversationsProperty.mjs.map +1 -0
  138. package/dist/esm/runtime/internals/utils/clientProperties/generateGenerationsProperty.d.ts +3 -0
  139. package/dist/esm/runtime/internals/utils/clientProperties/generateGenerationsProperty.mjs +20 -0
  140. package/dist/esm/runtime/internals/utils/clientProperties/generateGenerationsProperty.mjs.map +1 -0
  141. package/dist/meta/cjs.tsbuildinfo +1 -1
  142. package/package.json +3 -1
  143. package/src/ClientSchema/Core/ClientSchemaProperty.ts +3 -1
  144. package/src/ClientSchema/ai/ClientConversation.ts +15 -0
  145. package/src/ClientSchema/index.ts +15 -1
  146. package/src/CustomOperation.ts +48 -5
  147. package/src/ModelSchema.ts +4 -1
  148. package/src/SchemaProcessor.ts +73 -8
  149. package/src/a.ts +10 -1
  150. package/src/ai/ConversationSchemaTypes.ts +253 -0
  151. package/src/ai/ConversationType.ts +135 -0
  152. package/src/ai/ModelType.ts +43 -0
  153. package/src/ai/types/ConversationMessageContent.ts +43 -0
  154. package/src/ai/types/ToolConfiguration.ts +24 -0
  155. package/src/ai/types/ToolResultContent.ts +28 -0
  156. package/src/ai/types/contentBlocks.ts +26 -0
  157. package/src/runtime/addSchemaToClient.ts +12 -0
  158. package/src/runtime/bridge-types.ts +41 -4
  159. package/src/runtime/client/index.ts +82 -23
  160. package/src/runtime/internals/APIClient.ts +3 -4
  161. package/src/runtime/internals/ai/conversationMessageDeserializers.ts +62 -0
  162. package/src/runtime/internals/ai/conversationMessageSerializers.ts +68 -0
  163. package/src/runtime/internals/ai/convertItemToConversation.ts +53 -0
  164. package/src/runtime/internals/ai/convertItemToConversationMessage.ts +18 -0
  165. package/src/runtime/internals/ai/createCreateConversationFunction.ts +44 -0
  166. package/src/runtime/internals/ai/createGetConversationFunction.ts +48 -0
  167. package/src/runtime/internals/ai/createListConversationsFunction.ts +46 -0
  168. package/src/runtime/internals/ai/createListMessagesFunction.ts +42 -0
  169. package/src/runtime/internals/ai/createOnMessageFunction.ts +41 -0
  170. package/src/runtime/internals/ai/createSendMessageFunction.ts +60 -0
  171. package/src/runtime/internals/index.ts +2 -0
  172. package/src/runtime/internals/operations/custom.ts +24 -12
  173. package/src/runtime/internals/utils/clientProperties/generateConversationsProperty.ts +91 -0
  174. package/src/runtime/internals/utils/clientProperties/generateGenerationsProperty.ts +41 -0
@@ -0,0 +1,52 @@
1
+ import { fromBase64 } from '@smithy/util-base64';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ const deserializeContent = (content) => content.map((block) => {
6
+ if (block.image) {
7
+ return deserializeImageBlock(block);
8
+ }
9
+ if (block.toolUse) {
10
+ return deserializeToolUseBlock(block);
11
+ }
12
+ if (block.toolResult) {
13
+ return deserializeToolResultBlock(block);
14
+ }
15
+ return removeNullsFromBlock(block);
16
+ });
17
+ const deserializeImageBlock = ({ image }) => ({
18
+ image: {
19
+ ...image,
20
+ source: {
21
+ ...image.source,
22
+ bytes: fromBase64(image.source.bytes),
23
+ },
24
+ },
25
+ });
26
+ const deserializeJsonBlock = ({ json }) => ({
27
+ json: JSON.parse(json),
28
+ });
29
+ const deserializeToolUseBlock = ({ toolUse }) => ({
30
+ toolUse: {
31
+ ...toolUse,
32
+ input: JSON.parse(toolUse.input),
33
+ },
34
+ });
35
+ const deserializeToolResultBlock = ({ toolResult, }) => ({
36
+ toolResult: {
37
+ toolUseId: toolResult.toolUseId,
38
+ content: toolResult.content.map((toolResultBlock) => {
39
+ if (toolResultBlock.image) {
40
+ return deserializeImageBlock(toolResultBlock);
41
+ }
42
+ if (toolResultBlock.json) {
43
+ return deserializeJsonBlock(toolResultBlock);
44
+ }
45
+ return removeNullsFromBlock(toolResultBlock);
46
+ }),
47
+ },
48
+ });
49
+ const removeNullsFromBlock = (block) => Object.fromEntries(Object.entries(block).filter(([_, v]) => v !== null));
50
+
51
+ export { deserializeContent };
52
+ //# sourceMappingURL=conversationMessageDeserializers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversationMessageDeserializers.mjs","sources":["../../../../../src/runtime/internals/ai/conversationMessageDeserializers.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { fromBase64 } from '@smithy/util-base64';\nexport const deserializeContent = (content) => content.map((block) => {\n if (block.image) {\n return deserializeImageBlock(block);\n }\n if (block.toolUse) {\n return deserializeToolUseBlock(block);\n }\n if (block.toolResult) {\n return deserializeToolResultBlock(block);\n }\n return removeNullsFromBlock(block);\n});\nconst deserializeImageBlock = ({ image }) => ({\n image: {\n ...image,\n source: {\n ...image.source,\n bytes: fromBase64(image.source.bytes),\n },\n },\n});\nconst deserializeJsonBlock = ({ json }) => ({\n json: JSON.parse(json),\n});\nconst deserializeToolUseBlock = ({ toolUse }) => ({\n toolUse: {\n ...toolUse,\n input: JSON.parse(toolUse.input),\n },\n});\nconst deserializeToolResultBlock = ({ toolResult, }) => ({\n toolResult: {\n toolUseId: toolResult.toolUseId,\n content: toolResult.content.map((toolResultBlock) => {\n if (toolResultBlock.image) {\n return deserializeImageBlock(toolResultBlock);\n }\n if (toolResultBlock.json) {\n return deserializeJsonBlock(toolResultBlock);\n }\n return removeNullsFromBlock(toolResultBlock);\n }),\n },\n});\nconst removeNullsFromBlock = (block) => Object.fromEntries(Object.entries(block).filter(([_, v]) => v !== null));\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,kBAAkB,GAAG,CAAC,OAAO,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK;AACtE,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE;AACrB,QAAQ,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAC;AAC5C,KAAK;AACL,IAAI,IAAI,KAAK,CAAC,OAAO,EAAE;AACvB,QAAQ,OAAO,uBAAuB,CAAC,KAAK,CAAC,CAAC;AAC9C,KAAK;AACL,IAAI,IAAI,KAAK,CAAC,UAAU,EAAE;AAC1B,QAAQ,OAAO,0BAA0B,CAAC,KAAK,CAAC,CAAC;AACjD,KAAK;AACL,IAAI,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC,EAAE;AACH,MAAM,qBAAqB,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM;AAC9C,IAAI,KAAK,EAAE;AACX,QAAQ,GAAG,KAAK;AAChB,QAAQ,MAAM,EAAE;AAChB,YAAY,GAAG,KAAK,CAAC,MAAM;AAC3B,YAAY,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;AACjD,SAAS;AACT,KAAK;AACL,CAAC,CAAC,CAAC;AACH,MAAM,oBAAoB,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM;AAC5C,IAAI,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;AAC1B,CAAC,CAAC,CAAC;AACH,MAAM,uBAAuB,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM;AAClD,IAAI,OAAO,EAAE;AACb,QAAQ,GAAG,OAAO;AAClB,QAAQ,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;AACxC,KAAK;AACL,CAAC,CAAC,CAAC;AACH,MAAM,0BAA0B,GAAG,CAAC,EAAE,UAAU,GAAG,MAAM;AACzD,IAAI,UAAU,EAAE;AAChB,QAAQ,SAAS,EAAE,UAAU,CAAC,SAAS;AACvC,QAAQ,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,eAAe,KAAK;AAC7D,YAAY,IAAI,eAAe,CAAC,KAAK,EAAE;AACvC,gBAAgB,OAAO,qBAAqB,CAAC,eAAe,CAAC,CAAC;AAC9D,aAAa;AACb,YAAY,IAAI,eAAe,CAAC,IAAI,EAAE;AACtC,gBAAgB,OAAO,oBAAoB,CAAC,eAAe,CAAC,CAAC;AAC7D,aAAa;AACb,YAAY,OAAO,oBAAoB,CAAC,eAAe,CAAC,CAAC;AACzD,SAAS,CAAC;AACV,KAAK;AACL,CAAC,CAAC,CAAC;AACH,MAAM,oBAAoB,GAAG,CAAC,KAAK,KAAK,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;;;;"}
@@ -0,0 +1,37 @@
1
+ import type { ConversationMessageContent } from '../../../ai/types/ConversationMessageContent';
2
+ import type { ToolConfiguration } from '../../../ai/types/ToolConfiguration';
3
+ import type { ToolResultJsonContent } from '../../../ai/types/ToolResultContent';
4
+ export declare const serializeAiContext: (aiContext: string | Record<string, any>) => string;
5
+ export declare const serializeContent: (content: ConversationMessageContent[]) => (import("../../../ai/types/ConversationMessageContent").ConversationMessageTextContent | import("../../../ai/types/ConversationMessageContent").ConversationMessageToolUseContent | {
6
+ image: {
7
+ source: {
8
+ bytes: string;
9
+ };
10
+ format: "gif" | "jpeg" | "png" | "webp";
11
+ };
12
+ } | {
13
+ toolResult: {
14
+ content: ({
15
+ image: {
16
+ source: {
17
+ bytes: string;
18
+ };
19
+ format: "gif" | "jpeg" | "png" | "webp";
20
+ };
21
+ } | import("../../../ai/types/ToolResultContent").ToolResultTextContent | ToolResultJsonContent | {
22
+ json: string;
23
+ })[];
24
+ toolUseId: string;
25
+ };
26
+ })[];
27
+ export declare const serializeToolConfiguration: ({ tools }: ToolConfiguration) => {
28
+ tools: {
29
+ toolSpec: {
30
+ name: string;
31
+ description: string | undefined;
32
+ inputSchema: {
33
+ json: string;
34
+ };
35
+ };
36
+ }[];
37
+ };
@@ -0,0 +1,54 @@
1
+ import { toBase64 } from '@smithy/util-base64';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ const serializeAiContext = (aiContext) => JSON.stringify(aiContext);
6
+ const serializeContent = (content) => content.map((block) => {
7
+ if (block.image) {
8
+ return serializeImageBlock(block);
9
+ }
10
+ if (block.toolResult) {
11
+ return serializeToolResultBlock(block);
12
+ }
13
+ return block;
14
+ });
15
+ const serializeToolConfiguration = ({ tools }) => ({
16
+ tools: Object.entries(tools).map(([name, tool]) => ({
17
+ toolSpec: {
18
+ name,
19
+ description: tool.description,
20
+ inputSchema: {
21
+ json: JSON.stringify(tool.inputSchema.json),
22
+ },
23
+ },
24
+ })),
25
+ });
26
+ const serializeImageBlock = ({ image }) => ({
27
+ image: {
28
+ ...image,
29
+ source: {
30
+ ...image.source,
31
+ bytes: toBase64(image.source.bytes),
32
+ },
33
+ },
34
+ });
35
+ const serializeJsonBlock = ({ json }) => ({
36
+ json: JSON.stringify(json),
37
+ });
38
+ const serializeToolResultBlock = ({ toolResult, }) => ({
39
+ toolResult: {
40
+ ...toolResult,
41
+ content: toolResult.content.map((toolResultBlock) => {
42
+ if (toolResultBlock.image) {
43
+ return serializeImageBlock(toolResultBlock);
44
+ }
45
+ if (toolResultBlock.json) {
46
+ return serializeJsonBlock(toolResultBlock);
47
+ }
48
+ return toolResultBlock;
49
+ }),
50
+ },
51
+ });
52
+
53
+ export { serializeAiContext, serializeContent, serializeToolConfiguration };
54
+ //# sourceMappingURL=conversationMessageSerializers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversationMessageSerializers.mjs","sources":["../../../../../src/runtime/internals/ai/conversationMessageSerializers.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { toBase64 } from '@smithy/util-base64';\nexport const serializeAiContext = (aiContext) => JSON.stringify(aiContext);\nexport const serializeContent = (content) => content.map((block) => {\n if (block.image) {\n return serializeImageBlock(block);\n }\n if (block.toolResult) {\n return serializeToolResultBlock(block);\n }\n return block;\n});\nexport const serializeToolConfiguration = ({ tools }) => ({\n tools: Object.entries(tools).map(([name, tool]) => ({\n toolSpec: {\n name,\n description: tool.description,\n inputSchema: {\n json: JSON.stringify(tool.inputSchema.json),\n },\n },\n })),\n});\nconst serializeImageBlock = ({ image }) => ({\n image: {\n ...image,\n source: {\n ...image.source,\n bytes: toBase64(image.source.bytes),\n },\n },\n});\nconst serializeJsonBlock = ({ json }) => ({\n json: JSON.stringify(json),\n});\nconst serializeToolResultBlock = ({ toolResult, }) => ({\n toolResult: {\n ...toolResult,\n content: toolResult.content.map((toolResultBlock) => {\n if (toolResultBlock.image) {\n return serializeImageBlock(toolResultBlock);\n }\n if (toolResultBlock.json) {\n return serializeJsonBlock(toolResultBlock);\n }\n return toolResultBlock;\n }),\n },\n});\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,kBAAkB,GAAG,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;AAC/D,MAAC,gBAAgB,GAAG,CAAC,OAAO,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK;AACpE,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE;AACrB,QAAQ,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAC1C,KAAK;AACL,IAAI,IAAI,KAAK,CAAC,UAAU,EAAE;AAC1B,QAAQ,OAAO,wBAAwB,CAAC,KAAK,CAAC,CAAC;AAC/C,KAAK;AACL,IAAI,OAAO,KAAK,CAAC;AACjB,CAAC,EAAE;AACS,MAAC,0BAA0B,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM;AAC1D,IAAI,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM;AACxD,QAAQ,QAAQ,EAAE;AAClB,YAAY,IAAI;AAChB,YAAY,WAAW,EAAE,IAAI,CAAC,WAAW;AACzC,YAAY,WAAW,EAAE;AACzB,gBAAgB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;AAC3D,aAAa;AACb,SAAS;AACT,KAAK,CAAC,CAAC;AACP,CAAC,EAAE;AACH,MAAM,mBAAmB,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM;AAC5C,IAAI,KAAK,EAAE;AACX,QAAQ,GAAG,KAAK;AAChB,QAAQ,MAAM,EAAE;AAChB,YAAY,GAAG,KAAK,CAAC,MAAM;AAC3B,YAAY,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;AAC/C,SAAS;AACT,KAAK;AACL,CAAC,CAAC,CAAC;AACH,MAAM,kBAAkB,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM;AAC1C,IAAI,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;AAC9B,CAAC,CAAC,CAAC;AACH,MAAM,wBAAwB,GAAG,CAAC,EAAE,UAAU,GAAG,MAAM;AACvD,IAAI,UAAU,EAAE;AAChB,QAAQ,GAAG,UAAU;AACrB,QAAQ,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,eAAe,KAAK;AAC7D,YAAY,IAAI,eAAe,CAAC,KAAK,EAAE;AACvC,gBAAgB,OAAO,mBAAmB,CAAC,eAAe,CAAC,CAAC;AAC5D,aAAa;AACb,YAAY,IAAI,eAAe,CAAC,IAAI,EAAE;AACtC,gBAAgB,OAAO,kBAAkB,CAAC,eAAe,CAAC,CAAC;AAC3D,aAAa;AACb,YAAY,OAAO,eAAe,CAAC;AACnC,SAAS,CAAC;AACV,KAAK;AACL,CAAC,CAAC;;;;"}
@@ -0,0 +1,3 @@
1
+ import type { Conversation } from '../../../ai/ConversationType';
2
+ import type { BaseClient, ClientInternalsGetter, ModelIntrospectionSchema, SchemaModel } from '../../bridge-types';
3
+ export declare const convertItemToConversation: (client: BaseClient, modelIntrospection: ModelIntrospectionSchema, conversationId: string, conversationRouteName: string, conversationMessageModel: SchemaModel, getInternals: ClientInternalsGetter) => Conversation;
@@ -0,0 +1,20 @@
1
+ import { createListMessagesFunction } from './createListMessagesFunction.mjs';
2
+ import { createOnMessageFunction } from './createOnMessageFunction.mjs';
3
+ import { createSendMessageFunction } from './createSendMessageFunction.mjs';
4
+
5
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
+ // SPDX-License-Identifier: Apache-2.0
7
+ const convertItemToConversation = (client, modelIntrospection, conversationId, conversationRouteName, conversationMessageModel, getInternals) => {
8
+ if (!conversationId) {
9
+ throw new Error(`An error occurred converting a ${conversationRouteName} conversation: Missing ID`);
10
+ }
11
+ return {
12
+ id: conversationId,
13
+ onMessage: createOnMessageFunction(client, modelIntrospection, conversationId, conversationRouteName, getInternals),
14
+ sendMessage: createSendMessageFunction(client, modelIntrospection, conversationId, conversationRouteName, getInternals),
15
+ listMessages: createListMessagesFunction(client, modelIntrospection, conversationId, conversationMessageModel, getInternals),
16
+ };
17
+ };
18
+
19
+ export { convertItemToConversation };
20
+ //# sourceMappingURL=convertItemToConversation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertItemToConversation.mjs","sources":["../../../../../src/runtime/internals/ai/convertItemToConversation.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createListMessagesFunction } from './createListMessagesFunction';\nimport { createOnMessageFunction } from './createOnMessageFunction';\nimport { createSendMessageFunction } from './createSendMessageFunction';\nexport const convertItemToConversation = (client, modelIntrospection, conversationId, conversationRouteName, conversationMessageModel, getInternals) => {\n if (!conversationId) {\n throw new Error(`An error occurred converting a ${conversationRouteName} conversation: Missing ID`);\n }\n return {\n id: conversationId,\n onMessage: createOnMessageFunction(client, modelIntrospection, conversationId, conversationRouteName, getInternals),\n sendMessage: createSendMessageFunction(client, modelIntrospection, conversationId, conversationRouteName, getInternals),\n listMessages: createListMessagesFunction(client, modelIntrospection, conversationId, conversationMessageModel, getInternals),\n };\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,yBAAyB,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,YAAY,KAAK;AACxJ,IAAI,IAAI,CAAC,cAAc,EAAE;AACzB,QAAQ,MAAM,IAAI,KAAK,CAAC,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,yBAAyB,CAAC,CAAC,CAAC;AAC5G,KAAK;AACL,IAAI,OAAO;AACX,QAAQ,EAAE,EAAE,cAAc;AAC1B,QAAQ,SAAS,EAAE,uBAAuB,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,CAAC;AAC3H,QAAQ,WAAW,EAAE,yBAAyB,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,CAAC;AAC/H,QAAQ,YAAY,EAAE,0BAA0B,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,wBAAwB,EAAE,YAAY,CAAC;AACpI,KAAK,CAAC;AACN;;;;"}
@@ -0,0 +1,7 @@
1
+ export declare const convertItemToConversationMessage: ({ content, createdAt, id, conversationId, role, }: any) => {
2
+ content: import("../../../ai/types/ConversationMessageContent").ConversationMessageContent[];
3
+ conversationId: any;
4
+ createdAt: any;
5
+ id: any;
6
+ role: any;
7
+ };
@@ -0,0 +1,14 @@
1
+ import { deserializeContent } from './conversationMessageDeserializers.mjs';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ const convertItemToConversationMessage = ({ content, createdAt, id, conversationId, role, }) => ({
6
+ content: deserializeContent(content),
7
+ conversationId,
8
+ createdAt,
9
+ id,
10
+ role,
11
+ });
12
+
13
+ export { convertItemToConversationMessage };
14
+ //# sourceMappingURL=convertItemToConversationMessage.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertItemToConversationMessage.mjs","sources":["../../../../../src/runtime/internals/ai/convertItemToConversationMessage.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { deserializeContent } from './conversationMessageDeserializers';\nexport const convertItemToConversationMessage = ({ content, createdAt, id, conversationId, role, }) => ({\n content: deserializeContent(content),\n conversationId,\n createdAt,\n id,\n role,\n});\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,gCAAgC,GAAG,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,cAAc,EAAE,IAAI,GAAG,MAAM;AACxG,IAAI,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC;AACxC,IAAI,cAAc;AAClB,IAAI,SAAS;AACb,IAAI,EAAE;AACN,IAAI,IAAI;AACR,CAAC;;;;"}
@@ -0,0 +1,3 @@
1
+ import type { ConversationRoute } from '../../../ai/ConversationType';
2
+ import type { BaseClient, ClientInternalsGetter, ModelIntrospectionSchema, SchemaModel } from '../../bridge-types';
3
+ export declare const createCreateConversationFunction: (client: BaseClient, modelIntrospection: ModelIntrospectionSchema, conversationRouteName: string, conversationModel: SchemaModel, conversationMessageModel: SchemaModel, getInternals: ClientInternalsGetter) => ConversationRoute['create'];
@@ -0,0 +1,16 @@
1
+ import { getFactory } from '../operations/get.mjs';
2
+ import { convertItemToConversation } from './convertItemToConversation.mjs';
3
+
4
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ // SPDX-License-Identifier: Apache-2.0
6
+ const createCreateConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async () => {
7
+ const get = getFactory(client, modelIntrospection, conversationModel, 'CREATE', getInternals);
8
+ const { data, errors } = await get();
9
+ return {
10
+ data: convertItemToConversation(client, modelIntrospection, data?.id, conversationRouteName, conversationMessageModel, getInternals),
11
+ errors,
12
+ };
13
+ };
14
+
15
+ export { createCreateConversationFunction };
16
+ //# sourceMappingURL=createCreateConversationFunction.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createCreateConversationFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createCreateConversationFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getFactory } from '../operations/get';\nimport { convertItemToConversation } from './convertItemToConversation';\nexport const createCreateConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async () => {\n const get = getFactory(client, modelIntrospection, conversationModel, 'CREATE', getInternals);\n const { data, errors } = await get();\n return {\n data: convertItemToConversation(client, modelIntrospection, data?.id, conversationRouteName, conversationMessageModel, getInternals),\n errors,\n };\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,gCAAgC,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,YAAY,KAAK,YAAY;AAC9K,IAAI,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;AAClG,IAAI,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,EAAE,CAAC;AACzC,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,yBAAyB,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAAE,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,YAAY,CAAC;AAC5I,QAAQ,MAAM;AACd,KAAK,CAAC;AACN;;;;"}
@@ -0,0 +1,3 @@
1
+ import type { ConversationRoute } from '../../../ai/ConversationType';
2
+ import type { BaseClient, ClientInternalsGetter, ModelIntrospectionSchema, SchemaModel } from '../../bridge-types';
3
+ export declare const createGetConversationFunction: (client: BaseClient, modelIntrospection: ModelIntrospectionSchema, conversationRouteName: string, conversationModel: SchemaModel, conversationMessageModel: SchemaModel, getInternals: ClientInternalsGetter) => ConversationRoute['get'];
@@ -0,0 +1,18 @@
1
+ import { getFactory } from '../operations/get.mjs';
2
+ import { convertItemToConversation } from './convertItemToConversation.mjs';
3
+
4
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ // SPDX-License-Identifier: Apache-2.0
6
+ const createGetConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async ({ id }) => {
7
+ const get = getFactory(client, modelIntrospection, conversationModel, 'GET', getInternals);
8
+ const { data, errors } = await get({ id });
9
+ return {
10
+ data: data
11
+ ? convertItemToConversation(client, modelIntrospection, data.id, conversationRouteName, conversationMessageModel, getInternals)
12
+ : data,
13
+ errors,
14
+ };
15
+ };
16
+
17
+ export { createGetConversationFunction };
18
+ //# sourceMappingURL=createGetConversationFunction.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGetConversationFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createGetConversationFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getFactory } from '../operations/get';\nimport { convertItemToConversation } from './convertItemToConversation';\nexport const createGetConversationFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async ({ id }) => {\n const get = getFactory(client, modelIntrospection, conversationModel, 'GET', getInternals);\n const { data, errors } = await get({ id });\n return {\n data: data\n ? convertItemToConversation(client, modelIntrospection, data.id, conversationRouteName, conversationMessageModel, getInternals)\n : data,\n errors,\n };\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,6BAA6B,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,YAAY,KAAK,OAAO,EAAE,EAAE,EAAE,KAAK;AACjL,IAAI,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;AAC/F,IAAI,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC/C,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,IAAI;AAClB,cAAc,yBAAyB,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,CAAC,EAAE,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,YAAY,CAAC;AAC3I,cAAc,IAAI;AAClB,QAAQ,MAAM;AACd,KAAK,CAAC;AACN;;;;"}
@@ -0,0 +1,3 @@
1
+ import type { ConversationRoute } from '../../../ai/ConversationType';
2
+ import type { BaseClient, ClientInternalsGetter, ModelIntrospectionSchema, SchemaModel } from '../../bridge-types';
3
+ export declare const createListConversationsFunction: (client: BaseClient, modelIntrospection: ModelIntrospectionSchema, conversationRouteName: string, conversationModel: SchemaModel, conversationMessageModel: SchemaModel, getInternals: ClientInternalsGetter) => ConversationRoute['list'];
@@ -0,0 +1,19 @@
1
+ import { listFactory } from '../operations/list.mjs';
2
+ import { convertItemToConversation } from './convertItemToConversation.mjs';
3
+
4
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ // SPDX-License-Identifier: Apache-2.0
6
+ const createListConversationsFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async (input) => {
7
+ const list = listFactory(client, modelIntrospection, conversationModel, getInternals);
8
+ const { data, nextToken, errors } = await list(input);
9
+ return {
10
+ data: data.map((datum) => {
11
+ return convertItemToConversation(client, modelIntrospection, datum.id, conversationRouteName, conversationMessageModel, getInternals);
12
+ }),
13
+ nextToken,
14
+ errors,
15
+ };
16
+ };
17
+
18
+ export { createListConversationsFunction };
19
+ //# sourceMappingURL=createListConversationsFunction.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createListConversationsFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createListConversationsFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { listFactory } from '../operations/list';\nimport { convertItemToConversation } from './convertItemToConversation';\nexport const createListConversationsFunction = (client, modelIntrospection, conversationRouteName, conversationModel, conversationMessageModel, getInternals) => async (input) => {\n const list = listFactory(client, modelIntrospection, conversationModel, getInternals);\n const { data, nextToken, errors } = await list(input);\n return {\n data: data.map((datum) => {\n return convertItemToConversation(client, modelIntrospection, datum.id, conversationRouteName, conversationMessageModel, getInternals);\n }),\n nextToken,\n errors,\n };\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,+BAA+B,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,YAAY,KAAK,OAAO,KAAK,KAAK;AAClL,IAAI,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,YAAY,CAAC,CAAC;AAC1F,IAAI,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1D,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK;AAClC,YAAY,OAAO,yBAAyB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,CAAC,EAAE,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,YAAY,CAAC,CAAC;AAClJ,SAAS,CAAC;AACV,QAAQ,SAAS;AACjB,QAAQ,MAAM;AACd,KAAK,CAAC;AACN;;;;"}
@@ -0,0 +1,3 @@
1
+ import type { Conversation } from '../../../ai/ConversationType';
2
+ import type { BaseClient, ClientInternalsGetter, ModelIntrospectionSchema, SchemaModel } from '../../bridge-types';
3
+ export declare const createListMessagesFunction: (client: BaseClient, modelIntrospection: ModelIntrospectionSchema, conversationId: string, conversationMessageModel: SchemaModel, getInternals: ClientInternalsGetter) => Conversation['listMessages'];
@@ -0,0 +1,20 @@
1
+ import { listFactory } from '../operations/list.mjs';
2
+ import { convertItemToConversationMessage } from './convertItemToConversationMessage.mjs';
3
+
4
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ // SPDX-License-Identifier: Apache-2.0
6
+ const createListMessagesFunction = (client, modelIntrospection, conversationId, conversationMessageModel, getInternals) => async (input) => {
7
+ const list = listFactory(client, modelIntrospection, conversationMessageModel, getInternals);
8
+ const { data, nextToken, errors } = await list({
9
+ ...input,
10
+ filter: { conversationId: { eq: conversationId } },
11
+ });
12
+ return {
13
+ data: data.map((item) => convertItemToConversationMessage(item)),
14
+ nextToken,
15
+ errors,
16
+ };
17
+ };
18
+
19
+ export { createListMessagesFunction };
20
+ //# sourceMappingURL=createListMessagesFunction.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createListMessagesFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createListMessagesFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { listFactory } from '../operations/list';\nimport { convertItemToConversationMessage } from './convertItemToConversationMessage';\nexport const createListMessagesFunction = (client, modelIntrospection, conversationId, conversationMessageModel, getInternals) => async (input) => {\n const list = listFactory(client, modelIntrospection, conversationMessageModel, getInternals);\n const { data, nextToken, errors } = await list({\n ...input,\n filter: { conversationId: { eq: conversationId } },\n });\n return {\n data: data.map((item) => convertItemToConversationMessage(item)),\n nextToken,\n errors,\n };\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,0BAA0B,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,wBAAwB,EAAE,YAAY,KAAK,OAAO,KAAK,KAAK;AACnJ,IAAI,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,YAAY,CAAC,CAAC;AACjG,IAAI,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC;AACnD,QAAQ,GAAG,KAAK;AAChB,QAAQ,MAAM,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE;AAC1D,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,gCAAgC,CAAC,IAAI,CAAC,CAAC;AACxE,QAAQ,SAAS;AACjB,QAAQ,MAAM;AACd,KAAK,CAAC;AACN;;;;"}
@@ -0,0 +1,3 @@
1
+ import type { Conversation } from '../../../ai/ConversationType';
2
+ import type { BaseClient, ClientInternalsGetter, ModelIntrospectionSchema } from '../../bridge-types';
3
+ export declare const createOnMessageFunction: (client: BaseClient, modelIntrospection: ModelIntrospectionSchema, conversationId: string, conversationRouteName: string, getInternals: ClientInternalsGetter) => Conversation['onMessage'];
@@ -0,0 +1,20 @@
1
+ import { customOpFactory } from '../operations/custom.mjs';
2
+ import { convertItemToConversationMessage } from './convertItemToConversationMessage.mjs';
3
+
4
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ // SPDX-License-Identifier: Apache-2.0
6
+ const createOnMessageFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => (handler) => {
7
+ const { conversations } = modelIntrospection;
8
+ // Safe guard for standalone function. When called as part of client generation, this should never be falsy.
9
+ if (!conversations) {
10
+ return {};
11
+ }
12
+ const subscribeSchema = conversations[conversationRouteName].message.subscribe;
13
+ const subscribeOperation = customOpFactory(client, modelIntrospection, 'subscription', subscribeSchema, false, getInternals);
14
+ return subscribeOperation({ conversationId }).subscribe((data) => {
15
+ handler(convertItemToConversationMessage(data));
16
+ });
17
+ };
18
+
19
+ export { createOnMessageFunction };
20
+ //# sourceMappingURL=createOnMessageFunction.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createOnMessageFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createOnMessageFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { customOpFactory } from '../operations/custom';\nimport { convertItemToConversationMessage } from './convertItemToConversationMessage';\nexport const createOnMessageFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => (handler) => {\n const { conversations } = modelIntrospection;\n // Safe guard for standalone function. When called as part of client generation, this should never be falsy.\n if (!conversations) {\n return {};\n }\n const subscribeSchema = conversations[conversationRouteName].message.subscribe;\n const subscribeOperation = customOpFactory(client, modelIntrospection, 'subscription', subscribeSchema, false, getInternals);\n return subscribeOperation({ conversationId }).subscribe((data) => {\n handler(convertItemToConversationMessage(data));\n });\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,uBAAuB,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,KAAK,CAAC,OAAO,KAAK;AACzI,IAAI,MAAM,EAAE,aAAa,EAAE,GAAG,kBAAkB,CAAC;AACjD;AACA,IAAI,IAAI,CAAC,aAAa,EAAE;AACxB,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,eAAe,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;AACnF,IAAI,MAAM,kBAAkB,GAAG,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;AACjI,IAAI,OAAO,kBAAkB,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK;AACtE,QAAQ,OAAO,CAAC,gCAAgC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxD,KAAK,CAAC,CAAC;AACP;;;;"}
@@ -0,0 +1,3 @@
1
+ import type { Conversation } from '../../../ai/ConversationType';
2
+ import type { BaseClient, ClientInternalsGetter, ModelIntrospectionSchema } from '../../bridge-types';
3
+ export declare const createSendMessageFunction: (client: BaseClient, modelIntrospection: ModelIntrospectionSchema, conversationId: string, conversationRouteName: string, getInternals: ClientInternalsGetter) => Conversation['sendMessage'];
@@ -0,0 +1,30 @@
1
+ import { customOpFactory } from '../operations/custom.mjs';
2
+ import { convertItemToConversationMessage } from './convertItemToConversationMessage.mjs';
3
+ import { serializeContent, serializeAiContext, serializeToolConfiguration } from './conversationMessageSerializers.mjs';
4
+
5
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
+ // SPDX-License-Identifier: Apache-2.0
7
+ const createSendMessageFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => async ({ aiContext, content, toolConfiguration }) => {
8
+ const { conversations } = modelIntrospection;
9
+ // Safe guard for standalone function. When called as part of client generation, this should never be falsy.
10
+ if (!conversations) {
11
+ return {};
12
+ }
13
+ const sendSchema = conversations[conversationRouteName].message.send;
14
+ const sendOperation = customOpFactory(client, modelIntrospection, 'mutation', sendSchema, false, getInternals);
15
+ const { data, errors } = await sendOperation({
16
+ conversationId,
17
+ content: serializeContent(content),
18
+ ...(aiContext && { aiContext: serializeAiContext(aiContext) }),
19
+ ...(toolConfiguration && {
20
+ toolConfiguration: serializeToolConfiguration(toolConfiguration),
21
+ }),
22
+ });
23
+ return {
24
+ data: data ? convertItemToConversationMessage(data) : data,
25
+ errors,
26
+ };
27
+ };
28
+
29
+ export { createSendMessageFunction };
30
+ //# sourceMappingURL=createSendMessageFunction.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSendMessageFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createSendMessageFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { customOpFactory } from '../operations/custom';\nimport { convertItemToConversationMessage } from './convertItemToConversationMessage';\nimport { serializeAiContext, serializeContent, serializeToolConfiguration, } from './conversationMessageSerializers';\nexport const createSendMessageFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => async ({ aiContext, content, toolConfiguration }) => {\n const { conversations } = modelIntrospection;\n // Safe guard for standalone function. When called as part of client generation, this should never be falsy.\n if (!conversations) {\n return {};\n }\n const sendSchema = conversations[conversationRouteName].message.send;\n const sendOperation = customOpFactory(client, modelIntrospection, 'mutation', sendSchema, false, getInternals);\n const { data, errors } = await sendOperation({\n conversationId,\n content: serializeContent(content),\n ...(aiContext && { aiContext: serializeAiContext(aiContext) }),\n ...(toolConfiguration && {\n toolConfiguration: serializeToolConfiguration(toolConfiguration),\n }),\n });\n return {\n data: data ? convertItemToConversationMessage(data) : data,\n errors,\n };\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,yBAAyB,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,KAAK,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB,EAAE,KAAK;AACnL,IAAI,MAAM,EAAE,aAAa,EAAE,GAAG,kBAAkB,CAAC;AACjD;AACA,IAAI,IAAI,CAAC,aAAa,EAAE;AACxB,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,UAAU,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;AACzE,IAAI,MAAM,aAAa,GAAG,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;AACnH,IAAI,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC;AACjD,QAAQ,cAAc;AACtB,QAAQ,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC;AAC1C,QAAQ,IAAI,SAAS,IAAI,EAAE,SAAS,EAAE,kBAAkB,CAAC,SAAS,CAAC,EAAE;AACrE,QAAQ,IAAI,iBAAiB,IAAI;AACjC,YAAY,iBAAiB,EAAE,0BAA0B,CAAC,iBAAiB,CAAC;AAC5E,SAAS;AACT,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,IAAI,GAAG,gCAAgC,CAAC,IAAI,CAAC,GAAG,IAAI;AAClE,QAAQ,MAAM;AACd,KAAK,CAAC;AACN;;;;"}
@@ -1,4 +1,6 @@
1
1
  export { generateCustomMutationsProperty, generateCustomQueriesProperty, generateCustomSubscriptionsProperty, } from './generateCustomOperationsProperty';
2
+ export { generateConversationsProperty } from './utils/clientProperties/generateConversationsProperty';
3
+ export { generateGenerationsProperty } from './utils/clientProperties/generateGenerationsProperty';
2
4
  export { generateEnumsProperty } from './utils/clientProperties/generateEnumsProperty';
3
5
  export { generateModelsProperty } from './utils/clientProperties/generateModelsProperty';
4
6
  export { isGraphQLResponseWithErrors } from './utils/runtimeTypeGuards/isGraphQLResponseWithErrors';
@@ -1,4 +1,6 @@
1
1
  export { generateCustomMutationsProperty, generateCustomQueriesProperty, generateCustomSubscriptionsProperty } from './generateCustomOperationsProperty.mjs';
2
+ export { generateConversationsProperty } from './utils/clientProperties/generateConversationsProperty.mjs';
3
+ export { generateGenerationsProperty } from './utils/clientProperties/generateGenerationsProperty.mjs';
2
4
  export { generateEnumsProperty } from './utils/clientProperties/generateEnumsProperty.mjs';
3
5
  export { generateModelsProperty } from './utils/clientProperties/generateModelsProperty.mjs';
4
6
  export { isGraphQLResponseWithErrors } from './utils/runtimeTypeGuards/isGraphQLResponseWithErrors.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -57,5 +57,5 @@ type OpArgs = [AmplifyServer.ContextSpec, QueryArgs, CustomOperationOptions] | [
57
57
  * @param useContext Whether the function needs to accept an SSR context.
58
58
  * @returns The operation function to attach to query, mutations, etc.
59
59
  */
60
- export declare function customOpFactory(client: BaseClient, modelIntrospection: ModelIntrospectionSchema, operationType: 'query' | 'mutation' | 'subscription', operation: CustomOperation, useContext: boolean, getInternals: ClientInternalsGetter): (...args: OpArgs) => Promise<unknown> | import("rxjs").Observable<any>;
60
+ export declare function customOpFactory(client: BaseClient, modelIntrospection: ModelIntrospectionSchema, operationType: 'query' | 'mutation' | 'subscription', operation: CustomOperation, useContext: boolean, getInternals: ClientInternalsGetter): (...args: OpArgs) => import("rxjs").Observable<any> | Promise<unknown>;
61
61
  export {};
@@ -117,18 +117,25 @@ function customOpFactory(client, modelIntrospection, operationType, operation, u
117
117
  function hasStringField(o, field) {
118
118
  return typeof o[field] === 'string';
119
119
  }
120
+ function isEnumType(type) {
121
+ return type instanceof Object && 'enum' in type;
122
+ }
123
+ function isInputType(type) {
124
+ return type instanceof Object && 'input' in type;
125
+ }
120
126
  /**
121
127
  * @param argDef A single argument definition from a custom operation
122
128
  * @returns A string naming the base type including the `!` if the arg is required.
123
129
  */
124
- function argumentBaseTypeString(argDef) {
125
- const requiredFlag = argDef.isRequired ? '!' : '';
126
- if (argDef.type instanceof Object && 'enum' in argDef.type) {
127
- return argDef.type.enum + requiredFlag;
130
+ function argumentBaseTypeString({ type, isRequired }) {
131
+ const requiredFlag = isRequired ? '!' : '';
132
+ if (isEnumType(type)) {
133
+ return `${type.enum}${requiredFlag}`;
128
134
  }
129
- else {
130
- return argDef.type + requiredFlag;
135
+ if (isInputType(type)) {
136
+ return `${type.input}${requiredFlag}`;
131
137
  }
138
+ return `${type}${requiredFlag}`;
132
139
  }
133
140
  /**
134
141
  * Generates "outer" arguments string for a custom operation. For example,
@@ -154,10 +161,10 @@ function outerArguments(operation) {
154
161
  return '';
155
162
  }
156
163
  const args = Object.entries(operation.arguments)
157
- .map(([k, v]) => {
158
- const baseType = argumentBaseTypeString(v);
159
- const finalType = v.isArray
160
- ? `[${baseType}]${v.isArrayNullable ? '' : '!'}`
164
+ .map(([k, argument]) => {
165
+ const baseType = argumentBaseTypeString(argument);
166
+ const finalType = argument.isArray
167
+ ? `[${baseType}]${argument.isArrayNullable ? '' : '!'}`
161
168
  : baseType;
162
169
  return `$${k}: ${finalType}`;
163
170
  })