@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,208 @@
1
+ import { capitalize } from '../runtime/utils/stringTransformation.mjs';
2
+
3
+ const createConversationField = (typeDef, typeName) => {
4
+ const { aiModel, systemPrompt, handler, tools } = typeDef;
5
+ const args = {
6
+ aiModel: aiModel.resourcePath,
7
+ systemPrompt,
8
+ };
9
+ if (handler) {
10
+ if (typeof handler === 'string') {
11
+ args['functionName'] = handler;
12
+ }
13
+ else if (typeof handler.getInstance === 'function') {
14
+ args['functionName'] = `Fn${capitalize(typeName)}`;
15
+ }
16
+ }
17
+ const argsString = Object.entries(args)
18
+ .map(([key, value]) => `${key}: "${value}"`)
19
+ .join(', ');
20
+ const toolsString = tools?.length
21
+ ? `, tools: [${getConversationToolsString(tools)}]`
22
+ : '';
23
+ const conversationDirective = `@conversation(${argsString}${toolsString})`;
24
+ return `${typeName}(conversationId: ID!, content: [ContentBlockInput], aiContext: AWSJSON, toolConfiguration: ToolConfigurationInput): ConversationMessage ${conversationDirective} @aws_cognito_user_pools`;
25
+ };
26
+ const isRef = (query) => query?.data?.type === 'ref';
27
+ const getConversationToolsString = (tools) => tools
28
+ .map((tool) => {
29
+ const { query, description } = tool;
30
+ if (!isRef(query)) {
31
+ throw new Error(`Unexpected query was found in tool ${tool}.`);
32
+ }
33
+ // TODO: add validation for query / auth (cup) / etc
34
+ const queryName = query.data.link;
35
+ return `{ name: "${queryName}", description: "${description}" }`;
36
+ })
37
+ .join(', ');
38
+ const ConversationParticipantRole = `enum ConversationParticipantRole {
39
+ user
40
+ assistant
41
+ }`;
42
+ const ConversationMessage = `interface ConversationMessage {
43
+ id: ID!
44
+ conversationId: ID!
45
+ role: ConversationParticipantRole
46
+ content: [ContentBlock]
47
+ aiContext: AWSJSON
48
+ toolConfiguration: ToolConfiguration
49
+ createdAt: AWSDateTime
50
+ updatedAt: AWSDateTime
51
+ owner: String
52
+ }`;
53
+ const DocumentBlockSourceInput = `input DocumentBlockSourceInput {
54
+ bytes: String
55
+ }`;
56
+ const DocumentBlockInput = `input DocumentBlockInput {
57
+ format: String!
58
+ name: String!
59
+ source: DocumentBlockSourceInput!
60
+ }`;
61
+ const ImageBlockSourceInput = `input ImageBlockSourceInput {
62
+ bytes: String
63
+ }`;
64
+ const ImageBlockInput = `input ImageBlockInput {
65
+ format: String!
66
+ source: ImageBlockSourceInput!
67
+ }`;
68
+ const ToolResultContentBlockInput = `input ToolResultContentBlockInput {
69
+ document: DocumentBlockInput
70
+ image: ImageBlockInput
71
+ json: AWSJSON
72
+ text: String
73
+ }`;
74
+ const ToolResultBlockInput = `input ToolResultBlockInput {
75
+ content: [ToolResultContentBlockInput!]!
76
+ toolUseId: String!
77
+ status: String
78
+ }`;
79
+ const DocumentBlockSource = `type DocumentBlockSource {
80
+ bytes: String
81
+ }
82
+ `;
83
+ const DocumentBlock = `type DocumentBlock {
84
+ format: String!
85
+ name: String!
86
+ source: DocumentBlockSource!
87
+ }`;
88
+ const ImageBlock = `type ImageBlock {
89
+ format: String!
90
+ source: ImageBlockSource!
91
+ }`;
92
+ const ImageBlockSource = `type ImageBlockSource {
93
+ bytes: String
94
+ }`;
95
+ const ToolUseBlockInput = `input ToolUseBlockInput {
96
+ toolUseId: String!
97
+ name: String!
98
+ input: AWSJSON!
99
+ }`;
100
+ const ToolUseBlock = `type ToolUseBlock {
101
+ toolUseId: String!
102
+ name: String!
103
+ input: AWSJSON!
104
+ }`;
105
+ const ToolResultContentBlock = `type ToolResultContentBlock {
106
+ document: DocumentBlock
107
+ image: ImageBlock
108
+ json: AWSJSON
109
+ text: String
110
+ }`;
111
+ const ToolResultBlock = `type ToolResultBlock {
112
+ content: [ToolResultContentBlock!]!
113
+ toolUseId: String!
114
+ status: String
115
+ }`;
116
+ const ContentBlockText = `type ContentBlockText {
117
+ text: String
118
+ }`;
119
+ const ContentBlockImage = `type ContentBlockImage {
120
+ image: ImageBlock
121
+ }`;
122
+ const ContentBlockDocument = `type ContentBlockDocument {
123
+ document: DocumentBlock
124
+ }`;
125
+ const ContentBlockToolUse = `type ContentBlockToolUse {
126
+ toolUse: ToolUseBlock
127
+ }`;
128
+ const ContentBlockToolResult = `type ContentBlockToolResult {
129
+ toolResult: ToolResultBlock
130
+ }`;
131
+ const ContentBlockInput = `input ContentBlockInput {
132
+ text: String
133
+ document: DocumentBlockInput
134
+ image: ImageBlockInput
135
+ toolResult: ToolResultBlockInput
136
+ toolUse: ToolUseBlockInput
137
+ }`;
138
+ const ContentBlock = `type ContentBlock {
139
+ text: String
140
+ document: DocumentBlock
141
+ image: ImageBlock
142
+ toolResult: ToolResultBlock
143
+ toolUse: ToolUseBlock
144
+ }`;
145
+ const ToolConfigurationInput = `input ToolConfigurationInput {
146
+ tools: [ToolInput]
147
+ }`;
148
+ const ToolInput = `input ToolInput {
149
+ toolSpec: ToolSpecificationInput
150
+ }`;
151
+ const ToolSpecificationInput = `input ToolSpecificationInput {
152
+ name: String!
153
+ description: String
154
+ inputSchema: ToolInputSchemaInput!
155
+ }`;
156
+ const ToolInputSchemaInput = `input ToolInputSchemaInput {
157
+ json: AWSJSON
158
+ }`;
159
+ const ToolConfiguration = `type ToolConfiguration {
160
+ tools: [Tool]
161
+ }`;
162
+ const Tool = `type Tool {
163
+ toolSpec: ToolSpecification
164
+ }`;
165
+ const ToolSpecification = `type ToolSpecification {
166
+ name: String!
167
+ description: String
168
+ inputSchema: ToolInputSchema!
169
+ }`;
170
+ const ToolInputSchema = `type ToolInputSchema {
171
+ json: AWSJSON
172
+ }`;
173
+ const conversationTypes = [
174
+ ConversationParticipantRole,
175
+ ConversationMessage,
176
+ DocumentBlockSourceInput,
177
+ DocumentBlockInput,
178
+ ImageBlockSourceInput,
179
+ ImageBlockInput,
180
+ ToolUseBlockInput,
181
+ ToolResultContentBlockInput,
182
+ ToolResultBlockInput,
183
+ DocumentBlockSource,
184
+ DocumentBlock,
185
+ ImageBlock,
186
+ ImageBlockSource,
187
+ ToolUseBlock,
188
+ ToolResultContentBlock,
189
+ ToolResultBlock,
190
+ ContentBlockText,
191
+ ContentBlockImage,
192
+ ContentBlockDocument,
193
+ ContentBlockToolUse,
194
+ ContentBlockToolResult,
195
+ ContentBlockInput,
196
+ ContentBlock,
197
+ ToolConfigurationInput,
198
+ ToolInput,
199
+ ToolSpecificationInput,
200
+ ToolInputSchemaInput,
201
+ ToolConfiguration,
202
+ Tool,
203
+ ToolSpecification,
204
+ ToolInputSchema,
205
+ ];
206
+
207
+ export { conversationTypes, createConversationField };
208
+ //# sourceMappingURL=ConversationSchemaTypes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConversationSchemaTypes.mjs","sources":["../../../src/ai/ConversationSchemaTypes.ts"],"sourcesContent":["import { capitalize } from '../runtime/utils';\nexport const createConversationField = (typeDef, typeName) => {\n const { aiModel, systemPrompt, handler, tools } = typeDef;\n const args = {\n aiModel: aiModel.resourcePath,\n systemPrompt,\n };\n if (handler) {\n if (typeof handler === 'string') {\n args['functionName'] = handler;\n }\n else if (typeof handler.getInstance === 'function') {\n args['functionName'] = `Fn${capitalize(typeName)}`;\n }\n }\n const argsString = Object.entries(args)\n .map(([key, value]) => `${key}: \"${value}\"`)\n .join(', ');\n const toolsString = tools?.length\n ? `, tools: [${getConversationToolsString(tools)}]`\n : '';\n const conversationDirective = `@conversation(${argsString}${toolsString})`;\n return `${typeName}(conversationId: ID!, content: [ContentBlockInput], aiContext: AWSJSON, toolConfiguration: ToolConfigurationInput): ConversationMessage ${conversationDirective} @aws_cognito_user_pools`;\n};\nconst isRef = (query) => query?.data?.type === 'ref';\nconst getConversationToolsString = (tools) => tools\n .map((tool) => {\n const { query, description } = tool;\n if (!isRef(query)) {\n throw new Error(`Unexpected query was found in tool ${tool}.`);\n }\n // TODO: add validation for query / auth (cup) / etc\n const queryName = query.data.link;\n return `{ name: \"${queryName}\", description: \"${description}\" }`;\n})\n .join(', ');\nconst ConversationParticipantRole = `enum ConversationParticipantRole {\n user\n assistant\n}`;\nconst ConversationMessage = `interface ConversationMessage {\n id: ID!\n conversationId: ID!\n role: ConversationParticipantRole\n content: [ContentBlock]\n aiContext: AWSJSON\n toolConfiguration: ToolConfiguration\n createdAt: AWSDateTime\n updatedAt: AWSDateTime\n owner: String\n}`;\nconst DocumentBlockSourceInput = `input DocumentBlockSourceInput {\n bytes: String\n}`;\nconst DocumentBlockInput = `input DocumentBlockInput {\n format: String!\n name: String!\n source: DocumentBlockSourceInput!\n}`;\nconst ImageBlockSourceInput = `input ImageBlockSourceInput {\n bytes: String\n}`;\nconst ImageBlockInput = `input ImageBlockInput {\n format: String!\n source: ImageBlockSourceInput!\n}`;\nconst ToolResultContentBlockInput = `input ToolResultContentBlockInput {\n document: DocumentBlockInput\n image: ImageBlockInput\n json: AWSJSON\n text: String\n}`;\nconst ToolResultBlockInput = `input ToolResultBlockInput {\n content: [ToolResultContentBlockInput!]!\n toolUseId: String!\n status: String\n}`;\nconst DocumentBlockSource = `type DocumentBlockSource {\n bytes: String\n}\n`;\nconst DocumentBlock = `type DocumentBlock {\n format: String!\n name: String!\n source: DocumentBlockSource!\n}`;\nconst ImageBlock = `type ImageBlock {\n format: String!\n source: ImageBlockSource!\n}`;\nconst ImageBlockSource = `type ImageBlockSource {\n bytes: String\n}`;\nconst ToolUseBlockInput = `input ToolUseBlockInput {\n toolUseId: String!\n name: String!\n input: AWSJSON!\n}`;\nconst ToolUseBlock = `type ToolUseBlock {\n toolUseId: String!\n name: String!\n input: AWSJSON!\n}`;\nconst ToolResultContentBlock = `type ToolResultContentBlock {\n document: DocumentBlock\n image: ImageBlock\n json: AWSJSON\n text: String\n}`;\nconst ToolResultBlock = `type ToolResultBlock {\n content: [ToolResultContentBlock!]!\n toolUseId: String!\n status: String\n}`;\nconst ContentBlockText = `type ContentBlockText {\n text: String\n}`;\nconst ContentBlockImage = `type ContentBlockImage {\n image: ImageBlock\n}`;\nconst ContentBlockDocument = `type ContentBlockDocument {\n document: DocumentBlock\n}`;\nconst ContentBlockToolUse = `type ContentBlockToolUse {\n toolUse: ToolUseBlock\n}`;\nconst ContentBlockToolResult = `type ContentBlockToolResult {\n toolResult: ToolResultBlock\n}`;\nconst ContentBlockInput = `input ContentBlockInput {\n text: String\n document: DocumentBlockInput\n image: ImageBlockInput\n toolResult: ToolResultBlockInput\n toolUse: ToolUseBlockInput\n}`;\nconst ContentBlock = `type ContentBlock {\n text: String\n document: DocumentBlock\n image: ImageBlock\n toolResult: ToolResultBlock\n toolUse: ToolUseBlock\n}`;\nconst ToolConfigurationInput = `input ToolConfigurationInput {\n tools: [ToolInput]\n}`;\nconst ToolInput = `input ToolInput {\n toolSpec: ToolSpecificationInput\n}`;\nconst ToolSpecificationInput = `input ToolSpecificationInput {\n name: String!\n description: String\n inputSchema: ToolInputSchemaInput!\n}`;\nconst ToolInputSchemaInput = `input ToolInputSchemaInput {\n json: AWSJSON\n}`;\nconst ToolConfiguration = `type ToolConfiguration {\n tools: [Tool]\n}`;\nconst Tool = `type Tool {\n toolSpec: ToolSpecification\n}`;\nconst ToolSpecification = `type ToolSpecification {\n name: String!\n description: String\n inputSchema: ToolInputSchema!\n}`;\nconst ToolInputSchema = `type ToolInputSchema {\n json: AWSJSON\n}`;\nexport const conversationTypes = [\n ConversationParticipantRole,\n ConversationMessage,\n DocumentBlockSourceInput,\n DocumentBlockInput,\n ImageBlockSourceInput,\n ImageBlockInput,\n ToolUseBlockInput,\n ToolResultContentBlockInput,\n ToolResultBlockInput,\n DocumentBlockSource,\n DocumentBlock,\n ImageBlock,\n ImageBlockSource,\n ToolUseBlock,\n ToolResultContentBlock,\n ToolResultBlock,\n ContentBlockText,\n ContentBlockImage,\n ContentBlockDocument,\n ContentBlockToolUse,\n ContentBlockToolResult,\n ContentBlockInput,\n ContentBlock,\n ToolConfigurationInput,\n ToolInput,\n ToolSpecificationInput,\n ToolInputSchemaInput,\n ToolConfiguration,\n Tool,\n ToolSpecification,\n ToolInputSchema,\n];\n"],"names":[],"mappings":";;AACY,MAAC,uBAAuB,GA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ACd;AACA,CAAC,CAAC,CAAC;AACH,MAAM,iBAAiB,GAAG,CAAC;AAC3B;AACA;AACA;AACA,CAAC,CAAC,CAAC;AACH,MAAM,eAAe,GAAG,CAAC;AACzB;AACA,CAAC,CAAC,CAAC;AACS,MAAC,iBAAiB,GAAG;AACjC,IAAI,2BAA2B;AAC/B,IAAI,mBAAmB;AACvB,IAAI,wBAAwB;AAC5B,IAAI,kBAAkB;AACtB,IAAI,qBAAqB;AACzB,IAAI,eAAe;AACnB,IAAI,iBAAiB;AACrB,IAAI,2BAA2B;AAC/B,IAAI,oBAAoB;AACxB,IAAI,mBAAmB;AACvB,IAAI,aAAa;AACjB,IAAI,UAAU;AACd,IAAI,gBAAgB;AACpB,IAAI,YAAY;AAChB,IAAI,sBAAsB;AAC1B,IAAI,eAAe;AACnB,IAAI,gBAAgB;AACpB,IAAI,iBAAiB;AACrB,IAAI,oBAAoB;AACxB,IAAI,mBAAmB;AACvB,IAAI,sBAAsB;AAC1B,IAAI,iBAAiB;AACrB,IAAI,YAAY;AAChB,IAAI,sBAAsB;AAC1B,IAAI,SAAS;AACb,IAAI,sBAAsB;AAC1B,IAAI,oBAAoB;AACxB,IAAI,iBAAiB;AACrB,IAAI,IAAI;AACR,IAAI,iBAAiB;AACrB,IAAI,eAAe;AACnB;;;;"}
@@ -0,0 +1,102 @@
1
+ import type { Subscription } from 'rxjs';
2
+ import type { DefineFunction } from '@aws-amplify/data-schema-types';
3
+ import type { ListReturnValue, SingularReturnValue } from '../runtime/client';
4
+ import { type Brand } from '../util';
5
+ import type { RefType } from '../RefType';
6
+ import { AiModel, InferenceConfiguration } from './ModelType';
7
+ import { ConversationMessageContent, ConversationSendMessageInputContent } from './types/ConversationMessageContent';
8
+ import { ToolConfiguration } from './types/ToolConfiguration';
9
+ export declare const brandName = "conversationCustomOperation";
10
+ export interface ConversationMessage {
11
+ content: ConversationMessageContent[];
12
+ conversationId: string;
13
+ createdAt: string;
14
+ id: string;
15
+ role: 'user' | 'assistant';
16
+ }
17
+ interface ConversationRouteGetInput {
18
+ id: string;
19
+ }
20
+ interface ConversationRouteListInput {
21
+ limit?: number;
22
+ nextToken?: string | null;
23
+ }
24
+ export interface ConversationRoute {
25
+ /**
26
+ * @experimental
27
+ *
28
+ * Creates a {@link Conversation} from the current conversation route.
29
+ */
30
+ create: () => SingularReturnValue<Conversation>;
31
+ /**
32
+ * @experimental
33
+ *
34
+ * Gets an existing {@link Conversation} based on ID.
35
+ */
36
+ get: (input: ConversationRouteGetInput) => SingularReturnValue<Conversation>;
37
+ /**
38
+ * @experimental
39
+ *
40
+ * Lists all existing {@link Conversation}s on the current conversation route.
41
+ */
42
+ list: (input?: ConversationRouteListInput) => ListReturnValue<Conversation>;
43
+ }
44
+ interface ConversationSendMessageInput {
45
+ content: ConversationSendMessageInputContent[];
46
+ aiContext?: string | Record<string, any>;
47
+ toolConfiguration?: ToolConfiguration;
48
+ }
49
+ interface ConversationListMessagesInput {
50
+ limit?: number;
51
+ nextToken?: string | null;
52
+ }
53
+ type ConversationOnMessageHandler = (message: ConversationMessage) => void;
54
+ export interface Conversation {
55
+ id: string;
56
+ /**
57
+ * @experimental
58
+ *
59
+ * Sends a message to the current conversation.
60
+ */
61
+ sendMessage: (input: ConversationSendMessageInput) => SingularReturnValue<ConversationMessage>;
62
+ /**
63
+ * @experimental
64
+ *
65
+ * Lists all existing messages for the current conversation.
66
+ */
67
+ listMessages: (input?: ConversationListMessagesInput) => ListReturnValue<ConversationMessage>;
68
+ /**
69
+ * @experimental
70
+ *
71
+ * Subscribes to new messages on the current conversation.
72
+ */
73
+ onMessage: (handler: ConversationOnMessageHandler) => Subscription;
74
+ }
75
+ export interface ToolDefinition {
76
+ query: RefType<any>;
77
+ description: string;
78
+ }
79
+ export interface ConversationInput {
80
+ aiModel: AiModel;
81
+ systemPrompt: string;
82
+ inferenceConfiguration?: InferenceConfiguration;
83
+ tools?: ToolDefinition[];
84
+ handler?: DefineFunction | string;
85
+ }
86
+ export interface InternalConversationType extends ConversationType, ConversationInput {
87
+ }
88
+ export interface ConversationType extends Brand<typeof brandName> {
89
+ }
90
+ /**
91
+ * @experimental
92
+ *
93
+ * Define an AI conversation route which enables multi-turn conversation APIs for interacting with specified AI model.
94
+ * @example
95
+ * realtorChat: a.conversation({
96
+ * aiModel: { resourcePath },
97
+ * systemPrompt: 'You are a helpful real estate assistant',
98
+ * })
99
+ * @returns a conversation route definition
100
+ */
101
+ export declare function conversation(input: ConversationInput): ConversationType;
102
+ export {};
@@ -0,0 +1,25 @@
1
+ import { brand } from '../util/Brand.mjs';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ const brandName = 'conversationCustomOperation';
6
+ function _conversation(input) {
7
+ return { ...brand(brandName), ...input };
8
+ }
9
+ /**
10
+ * @experimental
11
+ *
12
+ * Define an AI conversation route which enables multi-turn conversation APIs for interacting with specified AI model.
13
+ * @example
14
+ * realtorChat: a.conversation({
15
+ * aiModel: { resourcePath },
16
+ * systemPrompt: 'You are a helpful real estate assistant',
17
+ * })
18
+ * @returns a conversation route definition
19
+ */
20
+ function conversation(input) {
21
+ return _conversation(input);
22
+ }
23
+
24
+ export { brandName, conversation };
25
+ //# sourceMappingURL=ConversationType.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConversationType.mjs","sources":["../../../src/ai/ConversationType.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { brand } from '../util';\nexport const brandName = 'conversationCustomOperation';\nfunction _conversation(input) {\n return { ...brand(brandName), ...input };\n}\n/**\n * @experimental\n *\n * Define an AI conversation route which enables multi-turn conversation APIs for interacting with specified AI model.\n * @example\n * realtorChat: a.conversation({\n * aiModel: { resourcePath },\n * systemPrompt: 'You are a helpful real estate assistant',\n * })\n * @returns a conversation route definition\n */\nexport function conversation(input) {\n return _conversation(input);\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,SAAS,GAAG,8BAA8B;AACvD,SAAS,aAAa,CAAC,KAAK,EAAE;AAC9B,IAAI,OAAO,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;AAC7C,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,YAAY,CAAC,KAAK,EAAE;AACpC,IAAI,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;AAChC;;;;"}
@@ -0,0 +1,30 @@
1
+ declare const supportedModelsLookup: {
2
+ readonly 'Claude 3 Haiku': "anthropic.claude-3-haiku-20240307-v1:0";
3
+ readonly 'Claude 3 Opus': "anthropic.claude-3-opus-20240229-v1:0";
4
+ readonly 'Claude 3 Sonnet': "anthropic.claude-3-sonnet-20240229-v1:0";
5
+ readonly 'Claude 3.5 Sonnet': "anthropic.claude-3-5-sonnet-20240620-v1:0";
6
+ readonly 'Cohere Command R': "cohere.command-r-v1:0";
7
+ readonly 'Cohere Command R+': "cohere.command-r-plus-v1:0";
8
+ readonly 'Llama 3.1 8B Instruct': "meta.llama3-1-8b-instruct-v1:0";
9
+ readonly 'Llama 3.1 70B Instruct': "meta.llama3-1-70b-instruct-v1:0";
10
+ readonly 'Llama 3.1 405B Instruct': "meta.llama3-1-405b-instruct-v1:0";
11
+ readonly 'Mistral Large': "mistral.mistral-large-2402-v1:0";
12
+ readonly 'Mistral Large 2': "mistral.mistral-large-2407-v1:0";
13
+ readonly 'Mistral Small': "mistral.mistral-small-2402-v1:0";
14
+ };
15
+ export interface AiModel {
16
+ resourcePath: string;
17
+ }
18
+ export interface InferenceConfiguration {
19
+ topP?: number;
20
+ temperature?: number;
21
+ maxTokens?: number;
22
+ }
23
+ /**
24
+ * @experimental
25
+ *
26
+ * Bedrock models currently supporting Converse API and Tool use
27
+ * @see {@link https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html#conversation-inference-supported-models-features}
28
+ */
29
+ export declare function model(modelName: keyof typeof supportedModelsLookup): AiModel;
30
+ export {};
@@ -0,0 +1,34 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ const supportedModelsLookup = {
4
+ // Anthropic models
5
+ 'Claude 3 Haiku': 'anthropic.claude-3-haiku-20240307-v1:0',
6
+ 'Claude 3 Opus': 'anthropic.claude-3-opus-20240229-v1:0',
7
+ 'Claude 3 Sonnet': 'anthropic.claude-3-sonnet-20240229-v1:0',
8
+ 'Claude 3.5 Sonnet': 'anthropic.claude-3-5-sonnet-20240620-v1:0',
9
+ // Cohere models
10
+ 'Cohere Command R': 'cohere.command-r-v1:0',
11
+ 'Cohere Command R+': 'cohere.command-r-plus-v1:0',
12
+ // Meta models
13
+ 'Llama 3.1 8B Instruct': 'meta.llama3-1-8b-instruct-v1:0',
14
+ 'Llama 3.1 70B Instruct': 'meta.llama3-1-70b-instruct-v1:0',
15
+ 'Llama 3.1 405B Instruct': 'meta.llama3-1-405b-instruct-v1:0',
16
+ // Mistral AI models
17
+ 'Mistral Large': 'mistral.mistral-large-2402-v1:0',
18
+ 'Mistral Large 2': 'mistral.mistral-large-2407-v1:0',
19
+ 'Mistral Small': 'mistral.mistral-small-2402-v1:0',
20
+ };
21
+ /**
22
+ * @experimental
23
+ *
24
+ * Bedrock models currently supporting Converse API and Tool use
25
+ * @see {@link https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html#conversation-inference-supported-models-features}
26
+ */
27
+ function model(modelName) {
28
+ return {
29
+ resourcePath: supportedModelsLookup[modelName],
30
+ };
31
+ }
32
+
33
+ export { model };
34
+ //# sourceMappingURL=ModelType.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelType.mjs","sources":["../../../src/ai/ModelType.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst supportedModelsLookup = {\n // Anthropic models\n 'Claude 3 Haiku': 'anthropic.claude-3-haiku-20240307-v1:0',\n 'Claude 3 Opus': 'anthropic.claude-3-opus-20240229-v1:0',\n 'Claude 3 Sonnet': 'anthropic.claude-3-sonnet-20240229-v1:0',\n 'Claude 3.5 Sonnet': 'anthropic.claude-3-5-sonnet-20240620-v1:0',\n // Cohere models\n 'Cohere Command R': 'cohere.command-r-v1:0',\n 'Cohere Command R+': 'cohere.command-r-plus-v1:0',\n // Meta models\n 'Llama 3.1 8B Instruct': 'meta.llama3-1-8b-instruct-v1:0',\n 'Llama 3.1 70B Instruct': 'meta.llama3-1-70b-instruct-v1:0',\n 'Llama 3.1 405B Instruct': 'meta.llama3-1-405b-instruct-v1:0',\n // Mistral AI models\n 'Mistral Large': 'mistral.mistral-large-2402-v1:0',\n 'Mistral Large 2': 'mistral.mistral-large-2407-v1:0',\n 'Mistral Small': 'mistral.mistral-small-2402-v1:0',\n};\n/**\n * @experimental\n *\n * Bedrock models currently supporting Converse API and Tool use\n * @see {@link https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html#conversation-inference-supported-models-features}\n */\nexport function model(modelName) {\n return {\n resourcePath: supportedModelsLookup[modelName],\n };\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA,MAAM,qBAAqB,GAAG;AAC9B;AACA,IAAI,gBAAgB,EAAE,wCAAwC;AAC9D,IAAI,eAAe,EAAE,uCAAuC;AAC5D,IAAI,iBAAiB,EAAE,yCAAyC;AAChE,IAAI,mBAAmB,EAAE,2CAA2C;AACpE;AACA,IAAI,kBAAkB,EAAE,uBAAuB;AAC/C,IAAI,mBAAmB,EAAE,4BAA4B;AACrD;AACA,IAAI,uBAAuB,EAAE,gCAAgC;AAC7D,IAAI,wBAAwB,EAAE,iCAAiC;AAC/D,IAAI,yBAAyB,EAAE,kCAAkC;AACjE;AACA,IAAI,eAAe,EAAE,iCAAiC;AACtD,IAAI,iBAAiB,EAAE,iCAAiC;AACxD,IAAI,eAAe,EAAE,iCAAiC;AACtD,CAAC,CAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,KAAK,CAAC,SAAS,EAAE;AACjC,IAAI,OAAO;AACX,QAAQ,YAAY,EAAE,qBAAqB,CAAC,SAAS,CAAC;AACtD,KAAK,CAAC;AACN;;;;"}
@@ -0,0 +1,27 @@
1
+ import { ImageBlock, ToolResultBlock, ToolUseBlock } from './contentBlocks';
2
+ export interface ConversationMessageTextContent {
3
+ text: string;
4
+ image?: never;
5
+ toolUse?: never;
6
+ toolResult?: never;
7
+ }
8
+ export interface ConversationMessageImageContent {
9
+ text?: never;
10
+ image: ImageBlock;
11
+ toolUse?: never;
12
+ toolResult?: never;
13
+ }
14
+ export interface ConversationMessageToolUseContent {
15
+ text?: never;
16
+ image?: never;
17
+ toolUse: ToolUseBlock;
18
+ toolResult?: never;
19
+ }
20
+ export interface ConversationMessageToolResultContent {
21
+ text?: never;
22
+ image?: never;
23
+ toolUse?: never;
24
+ toolResult: ToolResultBlock;
25
+ }
26
+ export type ConversationMessageContent = ConversationMessageTextContent | ConversationMessageImageContent | ConversationMessageToolUseContent | ConversationMessageToolResultContent;
27
+ export type ConversationSendMessageInputContent = Omit<ConversationMessageTextContent, 'toolUse'> | Omit<ConversationMessageImageContent, 'toolUse'> | Omit<ConversationMessageToolResultContent, 'toolUse'>;
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=ConversationMessageContent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConversationMessageContent.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ import type { JSONSchema4 } from 'json-schema';
2
+ interface ObjectTypedJSONSchema4 extends JSONSchema4 {
3
+ type: 'object';
4
+ }
5
+ interface ToolJsonInputSchema {
6
+ /**
7
+ * The schema for the tool. The top level schema type must be object.
8
+ */
9
+ json: ObjectTypedJSONSchema4;
10
+ }
11
+ export interface Tool {
12
+ inputSchema: ToolJsonInputSchema;
13
+ description?: string;
14
+ }
15
+ export interface ToolConfiguration {
16
+ tools: Record<string, Tool>;
17
+ }
18
+ export {};
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=ToolConfiguration.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolConfiguration.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ import type { DocumentType } from '../../runtime/bridge-types';
2
+ import { ImageBlock } from './contentBlocks';
3
+ export interface ToolResultTextContent {
4
+ text: string;
5
+ image?: never;
6
+ json?: never;
7
+ }
8
+ export interface ToolResultImageContent {
9
+ text?: never;
10
+ image: ImageBlock;
11
+ json?: never;
12
+ }
13
+ export interface ToolResultJsonContent {
14
+ text?: never;
15
+ image?: never;
16
+ json: DocumentType;
17
+ }
18
+ export type ToolResultContent = ToolResultTextContent | ToolResultImageContent | ToolResultJsonContent;
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=ToolResultContent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolResultContent.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import type { DocumentType } from '../../runtime/bridge-types';
2
+ import type { ToolResultContent } from './ToolResultContent';
3
+ interface BytesImageSource {
4
+ bytes: Uint8Array;
5
+ }
6
+ export interface ImageBlock {
7
+ format: 'gif' | 'jpeg' | 'png' | 'webp';
8
+ source: BytesImageSource;
9
+ }
10
+ export interface ToolUseBlock {
11
+ toolUseId: string;
12
+ name: string;
13
+ input: DocumentType;
14
+ }
15
+ export interface ToolResultBlock {
16
+ toolUseId: string;
17
+ content: ToolResultContent[];
18
+ }
19
+ export {};
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=contentBlocks.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contentBlocks.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,4 +1,6 @@
1
1
  import { generateCustomQueriesProperty, generateCustomMutationsProperty, generateCustomSubscriptionsProperty } from './internals/generateCustomOperationsProperty.mjs';
2
+ import { generateConversationsProperty } from './internals/utils/clientProperties/generateConversationsProperty.mjs';
3
+ import { generateGenerationsProperty } from './internals/utils/clientProperties/generateGenerationsProperty.mjs';
2
4
  import { generateEnumsProperty } from './internals/utils/clientProperties/generateEnumsProperty.mjs';
3
5
  import { generateModelsProperty } from './internals/utils/clientProperties/generateModelsProperty.mjs';
4
6
  import { upgradeClientCancellation } from './internals/cancellation.mjs';
@@ -12,6 +14,8 @@ function addSchemaToClient(client, apiGraphqlConfig, getInternals) {
12
14
  client.queries = generateCustomQueriesProperty(client, apiGraphqlConfig, getInternals);
13
15
  client.mutations = generateCustomMutationsProperty(client, apiGraphqlConfig, getInternals);
14
16
  client.subscriptions = generateCustomSubscriptionsProperty(client, apiGraphqlConfig, getInternals);
17
+ client.conversations = generateConversationsProperty(client, apiGraphqlConfig, getInternals);
18
+ client.generations = generateGenerationsProperty(client, apiGraphqlConfig, getInternals);
15
19
  return client;
16
20
  }
17
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"addSchemaToClient.mjs","sources":["../../../src/runtime/addSchemaToClient.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { generateCustomQueriesProperty, generateCustomMutationsProperty, generateCustomSubscriptionsProperty, generateEnumsProperty, generateModelsProperty, upgradeClientCancellation, } from './internals';\nexport function addSchemaToClient(client, apiGraphqlConfig, getInternals) {\n upgradeClientCancellation(client);\n client.models = generateModelsProperty(client, apiGraphqlConfig, getInternals);\n client.enums = generateEnumsProperty(apiGraphqlConfig);\n client.queries = generateCustomQueriesProperty(client, apiGraphqlConfig, getInternals);\n client.mutations = generateCustomMutationsProperty(client, apiGraphqlConfig, getInternals);\n client.subscriptions = generateCustomSubscriptionsProperty(client, apiGraphqlConfig, getInternals);\n return client;\n}\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAEO,SAAS,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE;AAC1E,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;AACtC,IAAI,MAAM,CAAC,MAAM,GAAG,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AACnF,IAAI,MAAM,CAAC,KAAK,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;AAC3D,IAAI,MAAM,CAAC,OAAO,GAAG,6BAA6B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAC3F,IAAI,MAAM,CAAC,SAAS,GAAG,+BAA+B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAC/F,IAAI,MAAM,CAAC,aAAa,GAAG,mCAAmC,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AACvG,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
1
+ {"version":3,"file":"addSchemaToClient.mjs","sources":["../../../src/runtime/addSchemaToClient.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { generateConversationsProperty, generateCustomQueriesProperty, generateCustomMutationsProperty, generateCustomSubscriptionsProperty, generateEnumsProperty, generateGenerationsProperty, generateModelsProperty, upgradeClientCancellation, } from './internals';\nexport function addSchemaToClient(client, apiGraphqlConfig, getInternals) {\n upgradeClientCancellation(client);\n client.models = generateModelsProperty(client, apiGraphqlConfig, getInternals);\n client.enums = generateEnumsProperty(apiGraphqlConfig);\n client.queries = generateCustomQueriesProperty(client, apiGraphqlConfig, getInternals);\n client.mutations = generateCustomMutationsProperty(client, apiGraphqlConfig, getInternals);\n client.subscriptions = generateCustomSubscriptionsProperty(client, apiGraphqlConfig, getInternals);\n client.conversations = generateConversationsProperty(client, apiGraphqlConfig, getInternals);\n client.generations = generateGenerationsProperty(client, apiGraphqlConfig, getInternals);\n return client;\n}\n"],"names":[],"mappings":";;;;;;;AAAA;AACA;AAEO,SAAS,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE;AAC1E,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;AACtC,IAAI,MAAM,CAAC,MAAM,GAAG,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AACnF,IAAI,MAAM,CAAC,KAAK,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;AAC3D,IAAI,MAAM,CAAC,OAAO,GAAG,6BAA6B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAC3F,IAAI,MAAM,CAAC,SAAS,GAAG,+BAA+B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAC/F,IAAI,MAAM,CAAC,aAAa,GAAG,mCAAmC,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AACvG,IAAI,MAAM,CAAC,aAAa,GAAG,6BAA6B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AACjG,IAAI,MAAM,CAAC,WAAW,GAAG,2BAA2B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAC7F,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
@@ -1,8 +1,9 @@
1
1
  import { isApiGraphQLConfig } from './internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.mjs';
2
2
  import { generateCustomQueriesProperty, generateCustomMutationsProperty } from './internals/generateCustomOperationsProperty.mjs';
3
- import { generateEnumsProperty } from './internals/utils/clientProperties/generateEnumsProperty.mjs';
4
3
  import { upgradeClientCancellation } from './internals/cancellation.mjs';
4
+ import '@smithy/util-base64';
5
5
  import 'rxjs';
6
+ import { generateEnumsProperty } from './internals/utils/clientProperties/generateEnumsProperty.mjs';
6
7
  import { generateModelsProperty } from './internals/server/generateModelsProperty.mjs';
7
8
 
8
9
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -1 +1 @@
1
- {"version":3,"file":"addSchemaToClientWithInstance.mjs","sources":["../../../src/runtime/addSchemaToClientWithInstance.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { isApiGraphQLConfig } from './internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig';\nimport { generateCustomQueriesProperty, generateCustomMutationsProperty, generateEnumsProperty, upgradeClientCancellation, } from './internals';\nimport { generateModelsProperty as generateModelsPropertyServer } from './internals/server';\n// TODO: separate import path\nexport function addSchemaToClientWithInstance(client, params, getInternals) {\n const apiGraphqlConfig = params.config?.API?.GraphQL;\n if (isApiGraphQLConfig(apiGraphqlConfig)) {\n upgradeClientCancellation(client);\n client.models = generateModelsPropertyServer(client, params, getInternals);\n client.enums = generateEnumsProperty(apiGraphqlConfig);\n client.queries = generateCustomQueriesProperty(client, apiGraphqlConfig, getInternals);\n client.mutations = generateCustomMutationsProperty(client, apiGraphqlConfig, getInternals);\n }\n return client;\n}\n"],"names":["generateModelsPropertyServer"],"mappings":";;;;;;;AAAA;AACA;AAIA;AACO,SAAS,6BAA6B,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE;AAC5E,IAAI,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC;AACzD,IAAI,IAAI,kBAAkB,CAAC,gBAAgB,CAAC,EAAE;AAC9C,QAAQ,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAC1C,QAAQ,MAAM,CAAC,MAAM,GAAGA,sBAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACnF,QAAQ,MAAM,CAAC,KAAK,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;AAC/D,QAAQ,MAAM,CAAC,OAAO,GAAG,6BAA6B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAC/F,QAAQ,MAAM,CAAC,SAAS,GAAG,+BAA+B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AACnG,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
1
+ {"version":3,"file":"addSchemaToClientWithInstance.mjs","sources":["../../../src/runtime/addSchemaToClientWithInstance.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { isApiGraphQLConfig } from './internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig';\nimport { generateCustomQueriesProperty, generateCustomMutationsProperty, generateEnumsProperty, upgradeClientCancellation, } from './internals';\nimport { generateModelsProperty as generateModelsPropertyServer } from './internals/server';\n// TODO: separate import path\nexport function addSchemaToClientWithInstance(client, params, getInternals) {\n const apiGraphqlConfig = params.config?.API?.GraphQL;\n if (isApiGraphQLConfig(apiGraphqlConfig)) {\n upgradeClientCancellation(client);\n client.models = generateModelsPropertyServer(client, params, getInternals);\n client.enums = generateEnumsProperty(apiGraphqlConfig);\n client.queries = generateCustomQueriesProperty(client, apiGraphqlConfig, getInternals);\n client.mutations = generateCustomMutationsProperty(client, apiGraphqlConfig, getInternals);\n }\n return client;\n}\n"],"names":["generateModelsPropertyServer"],"mappings":";;;;;;;;AAAA;AACA;AAIA;AACO,SAAS,6BAA6B,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE;AAC5E,IAAI,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC;AACzD,IAAI,IAAI,kBAAkB,CAAC,gBAAgB,CAAC,EAAE;AAC9C,QAAQ,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAC1C,QAAQ,MAAM,CAAC,MAAM,GAAGA,sBAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACnF,QAAQ,MAAM,CAAC,KAAK,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;AAC/D,QAAQ,MAAM,CAAC,OAAO,GAAG,6BAA6B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAC/F,QAAQ,MAAM,CAAC,SAAS,GAAG,+BAA+B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AACnG,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}