@aws-amplify/data-schema 1.4.1 → 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.
- package/dist/cjs/ClientSchema/ai/ClientConversation.js +6 -0
- package/dist/cjs/ClientSchema/ai/ClientConversation.js.map +1 -0
- package/dist/cjs/CustomOperation.js +22 -2
- package/dist/cjs/CustomOperation.js.map +1 -1
- package/dist/cjs/SchemaProcessor.js +41 -5
- package/dist/cjs/SchemaProcessor.js.map +1 -1
- package/dist/cjs/a.js +9 -1
- package/dist/cjs/a.js.map +1 -1
- package/dist/cjs/ai/ConversationSchemaTypes.js +210 -0
- package/dist/cjs/ai/ConversationSchemaTypes.js.map +1 -0
- package/dist/cjs/ai/ConversationType.js +27 -0
- package/dist/cjs/ai/ConversationType.js.map +1 -0
- package/dist/cjs/ai/ModelType.js +37 -0
- package/dist/cjs/ai/ModelType.js.map +1 -0
- package/dist/cjs/ai/types/ConversationMessageContent.js +6 -0
- package/dist/cjs/ai/types/ConversationMessageContent.js.map +1 -0
- package/dist/cjs/ai/types/ToolConfiguration.js +6 -0
- package/dist/cjs/ai/types/ToolConfiguration.js.map +1 -0
- package/dist/cjs/ai/types/ToolResultContent.js +6 -0
- package/dist/cjs/ai/types/ToolResultContent.js.map +1 -0
- package/dist/cjs/ai/types/contentBlocks.js +6 -0
- package/dist/cjs/ai/types/contentBlocks.js.map +1 -0
- package/dist/cjs/runtime/addSchemaToClient.js +2 -0
- package/dist/cjs/runtime/addSchemaToClient.js.map +1 -1
- package/dist/cjs/runtime/internals/APIClient.js +3 -3
- package/dist/cjs/runtime/internals/APIClient.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/conversationMessageDeserializers.js +54 -0
- package/dist/cjs/runtime/internals/ai/conversationMessageDeserializers.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/conversationMessageSerializers.js +58 -0
- package/dist/cjs/runtime/internals/ai/conversationMessageSerializers.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/convertItemToConversation.js +22 -0
- package/dist/cjs/runtime/internals/ai/convertItemToConversation.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/convertItemToConversationMessage.js +16 -0
- package/dist/cjs/runtime/internals/ai/convertItemToConversationMessage.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/createCreateConversationFunction.js +18 -0
- package/dist/cjs/runtime/internals/ai/createCreateConversationFunction.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/createGetConversationFunction.js +20 -0
- package/dist/cjs/runtime/internals/ai/createGetConversationFunction.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/createListConversationsFunction.js +21 -0
- package/dist/cjs/runtime/internals/ai/createListConversationsFunction.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/createListMessagesFunction.js +22 -0
- package/dist/cjs/runtime/internals/ai/createListMessagesFunction.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/createOnMessageFunction.js +22 -0
- package/dist/cjs/runtime/internals/ai/createOnMessageFunction.js.map +1 -0
- package/dist/cjs/runtime/internals/ai/createSendMessageFunction.js +32 -0
- package/dist/cjs/runtime/internals/ai/createSendMessageFunction.js.map +1 -0
- package/dist/cjs/runtime/internals/index.js +5 -1
- package/dist/cjs/runtime/internals/index.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/custom.js +17 -10
- package/dist/cjs/runtime/internals/operations/custom.js.map +1 -1
- package/dist/cjs/runtime/internals/utils/clientProperties/generateConversationsProperty.js +48 -0
- package/dist/cjs/runtime/internals/utils/clientProperties/generateConversationsProperty.js.map +1 -0
- package/dist/cjs/runtime/internals/utils/clientProperties/generateGenerationsProperty.js +22 -0
- package/dist/cjs/runtime/internals/utils/clientProperties/generateGenerationsProperty.js.map +1 -0
- package/dist/esm/ClientSchema/Core/ClientSchemaProperty.d.ts +1 -1
- package/dist/esm/ClientSchema/ai/ClientConversation.d.ts +7 -0
- package/dist/esm/ClientSchema/ai/ClientConversation.mjs +2 -0
- package/dist/esm/ClientSchema/ai/ClientConversation.mjs.map +1 -0
- package/dist/esm/ClientSchema/index.d.ts +12 -2
- package/dist/esm/CustomOperation.d.ts +33 -2
- package/dist/esm/CustomOperation.mjs +21 -2
- package/dist/esm/CustomOperation.mjs.map +1 -1
- package/dist/esm/ModelSchema.d.ts +3 -1
- package/dist/esm/SchemaProcessor.d.ts +1 -1
- package/dist/esm/SchemaProcessor.mjs +41 -5
- package/dist/esm/SchemaProcessor.mjs.map +1 -1
- package/dist/esm/a.d.ts +7 -2
- package/dist/esm/a.mjs +9 -1
- package/dist/esm/a.mjs.map +1 -1
- package/dist/esm/ai/ConversationSchemaTypes.d.ts +3 -0
- package/dist/esm/ai/ConversationSchemaTypes.mjs +208 -0
- package/dist/esm/ai/ConversationSchemaTypes.mjs.map +1 -0
- package/dist/esm/ai/ConversationType.d.ts +102 -0
- package/dist/esm/ai/ConversationType.mjs +25 -0
- package/dist/esm/ai/ConversationType.mjs.map +1 -0
- package/dist/esm/ai/ModelType.d.ts +30 -0
- package/dist/esm/ai/ModelType.mjs +34 -0
- package/dist/esm/ai/ModelType.mjs.map +1 -0
- package/dist/esm/ai/types/ConversationMessageContent.d.ts +27 -0
- package/dist/esm/ai/types/ConversationMessageContent.mjs +2 -0
- package/dist/esm/ai/types/ConversationMessageContent.mjs.map +1 -0
- package/dist/esm/ai/types/ToolConfiguration.d.ts +18 -0
- package/dist/esm/ai/types/ToolConfiguration.mjs +2 -0
- package/dist/esm/ai/types/ToolConfiguration.mjs.map +1 -0
- package/dist/esm/ai/types/ToolResultContent.d.ts +18 -0
- package/dist/esm/ai/types/ToolResultContent.mjs +2 -0
- package/dist/esm/ai/types/ToolResultContent.mjs.map +1 -0
- package/dist/esm/ai/types/contentBlocks.d.ts +19 -0
- package/dist/esm/ai/types/contentBlocks.mjs +2 -0
- package/dist/esm/ai/types/contentBlocks.mjs.map +1 -0
- package/dist/esm/runtime/addSchemaToClient.mjs +4 -0
- package/dist/esm/runtime/addSchemaToClient.mjs.map +1 -1
- package/dist/esm/runtime/addSchemaToClientWithInstance.mjs +2 -1
- package/dist/esm/runtime/addSchemaToClientWithInstance.mjs.map +1 -1
- package/dist/esm/runtime/bridge-types.d.ts +29 -3
- package/dist/esm/runtime/client/index.d.ts +8 -1
- package/dist/esm/runtime/internals/APIClient.mjs +3 -3
- package/dist/esm/runtime/internals/APIClient.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/conversationMessageDeserializers.d.ts +2 -0
- package/dist/esm/runtime/internals/ai/conversationMessageDeserializers.mjs +52 -0
- package/dist/esm/runtime/internals/ai/conversationMessageDeserializers.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/conversationMessageSerializers.d.ts +37 -0
- package/dist/esm/runtime/internals/ai/conversationMessageSerializers.mjs +54 -0
- package/dist/esm/runtime/internals/ai/conversationMessageSerializers.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/convertItemToConversation.d.ts +3 -0
- package/dist/esm/runtime/internals/ai/convertItemToConversation.mjs +20 -0
- package/dist/esm/runtime/internals/ai/convertItemToConversation.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/convertItemToConversationMessage.d.ts +7 -0
- package/dist/esm/runtime/internals/ai/convertItemToConversationMessage.mjs +14 -0
- package/dist/esm/runtime/internals/ai/convertItemToConversationMessage.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/createCreateConversationFunction.d.ts +3 -0
- package/dist/esm/runtime/internals/ai/createCreateConversationFunction.mjs +16 -0
- package/dist/esm/runtime/internals/ai/createCreateConversationFunction.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/createGetConversationFunction.d.ts +3 -0
- package/dist/esm/runtime/internals/ai/createGetConversationFunction.mjs +18 -0
- package/dist/esm/runtime/internals/ai/createGetConversationFunction.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/createListConversationsFunction.d.ts +3 -0
- package/dist/esm/runtime/internals/ai/createListConversationsFunction.mjs +19 -0
- package/dist/esm/runtime/internals/ai/createListConversationsFunction.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/createListMessagesFunction.d.ts +3 -0
- package/dist/esm/runtime/internals/ai/createListMessagesFunction.mjs +20 -0
- package/dist/esm/runtime/internals/ai/createListMessagesFunction.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/createOnMessageFunction.d.ts +3 -0
- package/dist/esm/runtime/internals/ai/createOnMessageFunction.mjs +20 -0
- package/dist/esm/runtime/internals/ai/createOnMessageFunction.mjs.map +1 -0
- package/dist/esm/runtime/internals/ai/createSendMessageFunction.d.ts +3 -0
- package/dist/esm/runtime/internals/ai/createSendMessageFunction.mjs +30 -0
- package/dist/esm/runtime/internals/ai/createSendMessageFunction.mjs.map +1 -0
- package/dist/esm/runtime/internals/index.d.ts +2 -0
- package/dist/esm/runtime/internals/index.mjs +2 -0
- package/dist/esm/runtime/internals/index.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/custom.d.ts +1 -1
- package/dist/esm/runtime/internals/operations/custom.mjs +17 -10
- package/dist/esm/runtime/internals/operations/custom.mjs.map +1 -1
- package/dist/esm/runtime/internals/utils/clientProperties/generateConversationsProperty.d.ts +3 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateConversationsProperty.mjs +46 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateConversationsProperty.mjs.map +1 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateGenerationsProperty.d.ts +3 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateGenerationsProperty.mjs +20 -0
- package/dist/esm/runtime/internals/utils/clientProperties/generateGenerationsProperty.mjs.map +1 -0
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +3 -1
- package/src/ClientSchema/Core/ClientSchemaProperty.ts +3 -1
- package/src/ClientSchema/ai/ClientConversation.ts +15 -0
- package/src/ClientSchema/index.ts +15 -1
- package/src/CustomOperation.ts +48 -5
- package/src/ModelSchema.ts +4 -1
- package/src/SchemaProcessor.ts +73 -8
- package/src/a.ts +10 -1
- package/src/ai/ConversationSchemaTypes.ts +253 -0
- package/src/ai/ConversationType.ts +135 -0
- package/src/ai/ModelType.ts +43 -0
- package/src/ai/types/ConversationMessageContent.ts +43 -0
- package/src/ai/types/ToolConfiguration.ts +24 -0
- package/src/ai/types/ToolResultContent.ts +28 -0
- package/src/ai/types/contentBlocks.ts +26 -0
- package/src/runtime/addSchemaToClient.ts +12 -0
- package/src/runtime/bridge-types.ts +41 -4
- package/src/runtime/client/index.ts +17 -1
- package/src/runtime/internals/APIClient.ts +3 -4
- package/src/runtime/internals/ai/conversationMessageDeserializers.ts +62 -0
- package/src/runtime/internals/ai/conversationMessageSerializers.ts +68 -0
- package/src/runtime/internals/ai/convertItemToConversation.ts +53 -0
- package/src/runtime/internals/ai/convertItemToConversationMessage.ts +18 -0
- package/src/runtime/internals/ai/createCreateConversationFunction.ts +44 -0
- package/src/runtime/internals/ai/createGetConversationFunction.ts +48 -0
- package/src/runtime/internals/ai/createListConversationsFunction.ts +46 -0
- package/src/runtime/internals/ai/createListMessagesFunction.ts +42 -0
- package/src/runtime/internals/ai/createOnMessageFunction.ts +41 -0
- package/src/runtime/internals/ai/createSendMessageFunction.ts +60 -0
- package/src/runtime/internals/index.ts +2 -0
- package/src/runtime/internals/operations/custom.ts +24 -12
- package/src/runtime/internals/utils/clientProperties/generateConversationsProperty.ts +91 -0
- package/src/runtime/internals/utils/clientProperties/generateGenerationsProperty.ts +41 -0
|
@@ -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,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
+
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) =>
|
|
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(
|
|
125
|
-
const requiredFlag =
|
|
126
|
-
if (
|
|
127
|
-
return
|
|
130
|
+
function argumentBaseTypeString({ type, isRequired }) {
|
|
131
|
+
const requiredFlag = isRequired ? '!' : '';
|
|
132
|
+
if (isEnumType(type)) {
|
|
133
|
+
return `${type.enum}${requiredFlag}`;
|
|
128
134
|
}
|
|
129
|
-
|
|
130
|
-
return
|
|
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,
|
|
158
|
-
const baseType = argumentBaseTypeString(
|
|
159
|
-
const finalType =
|
|
160
|
-
? `[${baseType}]${
|
|
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
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom.mjs","sources":["../../../../../src/runtime/internals/operations/custom.ts"],"sourcesContent":["import { map } from 'rxjs';\nimport { authModeParams, getDefaultSelectionSetForNonModelWithIR, generateSelectionSet, getCustomHeaders, initializeModel, selectionSetIRToString, } from '../APIClient';\nimport { handleSingularGraphQlError } from './utils';\nimport { selfAwareAsync } from '../../utils';\nimport { extendCancellability } from '../cancellation';\n/**\n * Type guard for checking whether a Custom Operation argument is a contextSpec object\n */\nconst argIsContextSpec = (arg) => {\n return typeof arg?.token?.value === 'symbol';\n};\n/**\n * Builds an operation function, embedded with all client and context data, that\n * can be attached to a client as a custom query or mutation.\n *\n * If we have this source schema:\n *\n * ```typescript\n * a.schema({\n * echo: a.query()\n * .arguments({input: a.string().required()})\n * .returns(a.string())\n * })\n * ```\n *\n * Our model intro schema will contain an entry like this:\n *\n * ```ts\n * {\n * queries: {\n * echo: {\n * name: \"echo\",\n * isArray: false,\n * type: 'String',\n * isRequired: false,\n * arguments: {\n * input: {\n * name: 'input',\n * isArray: false,\n * type: String,\n * isRequired: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * The `echo` object is used to build the `echo' method that goes here:\n *\n * ```typescript\n * const client = generateClent()\n * const { data } = await client.queries.echo({input: 'a string'});\n * // ^\n * // |\n * // +-- This one right here.\n * //\n * ```\n *\n *\n * @param client The client to run graphql queries through.\n * @param modelIntrospection The model introspection schema the op comes from.\n * @param operationType The broad category of graphql operation.\n * @param operation The operation definition from the introspection schema.\n * @param useContext Whether the function needs to accept an SSR context.\n * @returns The operation function to attach to query, mutations, etc.\n */\nexport function customOpFactory(client, modelIntrospection, operationType, operation, useContext, getInternals) {\n // .arguments() are defined for the custom operation in the schema builder\n // and are present in the model introspection schema\n const argsDefined = operation.arguments !== undefined;\n const op = (...args) => {\n // options is always the last argument\n const options = args[args.length - 1];\n let contextSpec;\n let arg;\n if (useContext) {\n if (argIsContextSpec(args[0])) {\n contextSpec = args[0];\n }\n else {\n throw new Error(`Invalid first argument passed to ${operation.name}. Expected contextSpec`);\n }\n }\n if (argsDefined) {\n if (useContext) {\n arg = args[1];\n }\n else {\n arg = args[0];\n }\n }\n if (operationType === 'subscription') {\n return _opSubscription(\n // subscriptions are only enabled on the clientside\n client, modelIntrospection, operation, getInternals, arg, options);\n }\n return _op(client, modelIntrospection, operationType, operation, getInternals, arg, options, contextSpec);\n };\n return op;\n}\n/**\n * Runtime test and type guard to check whether `o[field]` is a `String`.\n *\n * ```typescript\n * if (hasStringField(o, 'prop')) {\n * const s = o.prop;\n * // ^? const s: string\n * }\n * ```\n *\n * @param o Object to inspect\n * @param field Field to look for\n * @returns Boolean: `true` if the `o[field]` is a `string`\n */\nfunction hasStringField(o, field) {\n return typeof o[field] === 'string';\n}\n/**\n * @param argDef A single argument definition from a custom operation\n * @returns A string naming the base type including the `!` if the arg is required.\n */\nfunction argumentBaseTypeString(argDef) {\n const requiredFlag = argDef.isRequired ? '!' : '';\n if (argDef.type instanceof Object && 'enum' in argDef.type) {\n return argDef.type.enum + requiredFlag;\n }\n else {\n return argDef.type + requiredFlag;\n }\n}\n/**\n * Generates \"outer\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the top/outer level arguments as a string:\n *\n * ```json\n * \"InputString: String!\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction outerArguments(operation) {\n if (operation.arguments === undefined) {\n return '';\n }\n const args = Object.entries(operation.arguments)\n .map(([k, v]) => {\n const baseType = argumentBaseTypeString(v);\n const finalType = v.isArray\n ? `[${baseType}]${v.isArrayNullable ? '' : '!'}`\n : baseType;\n return `$${k}: ${finalType}`;\n })\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates \"inner\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the inner arguments as a string:\n *\n * ```json\n * \"InputString: $InputString\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction innerArguments(operation) {\n if (operation.arguments === undefined) {\n return '';\n }\n const args = Object.keys(operation.arguments)\n .map((k) => `${k}: $${k}`)\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates the selection set string for a custom operation. This is slightly\n * different than the selection set generation for models. If the custom op returns\n * a primitive or enum types, it doesn't require a selection set at all.\n *\n * E.g., the graphql might look like this:\n *\n * ```graphql\n * query MyQuery {\n * echoString(inputString: \"whatever\")\n * }\n * # ^\n * # |\n * # +-- no selection set\n * ```\n *\n * Non-primitive return type selection set generation will be similar to other\n * model operations.\n *\n * @param modelIntrospection The full code-generated introspection schema.\n * @param operation The operation object from the schema.\n * @returns The selection set as a string.\n */\nfunction operationSelectionSet(modelIntrospection, operation) {\n if (hasStringField(operation, 'type') ||\n hasStringField(operation.type, 'enum')) {\n return '';\n }\n else if (hasStringField(operation.type, 'nonModel')) {\n const nonModel = modelIntrospection.nonModels[operation.type.nonModel];\n return `{${selectionSetIRToString(getDefaultSelectionSetForNonModelWithIR(nonModel, modelIntrospection))}}`;\n }\n else if (hasStringField(operation.type, 'model')) {\n return `{${generateSelectionSet(modelIntrospection, operation.type.model)}}`;\n }\n else {\n return '';\n }\n}\n/**\n * Maps an arguments objec to graphql variables, removing superfluous args and\n * screaming loudly when required args are missing.\n *\n * @param operation The operation to construct graphql request variables for.\n * @param args The arguments to map variables from.\n * @returns The graphql variables object.\n */\nfunction operationVariables(operation, args = {}) {\n const variables = {};\n if (operation.arguments === undefined) {\n return variables;\n }\n for (const argDef of Object.values(operation.arguments)) {\n if (typeof args[argDef.name] !== 'undefined') {\n variables[argDef.name] = args[argDef.name];\n }\n else if (argDef.isRequired) {\n // At this point, the variable is both required and missing: We don't need\n // to continue. The operation is expected to fail.\n throw new Error(`${operation.name} requires arguments '${argDef.name}'`);\n }\n }\n return variables;\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operationType The high level graphql operation type.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @param context SSR context if relevant.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context) {\n return selfAwareAsync(async (resultPromise) => {\n const { name: operationName } = operation;\n const auth = authModeParams(client, getInternals, options);\n const headers = getCustomHeaders(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n try {\n const basePromise = context\n ? client.graphql(context, {\n ...auth,\n query,\n variables,\n }, headers)\n : client.graphql({\n ...auth,\n query,\n variables,\n }, headers);\n const extendedPromise = extendCancellability(basePromise, resultPromise);\n const { data, extensions } = await extendedPromise;\n // flatten response\n if (data) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? initializeModel(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n extensions,\n };\n }\n else {\n return { data: null, extensions };\n }\n }\n catch (error) {\n /**\n * The `data` type returned by `error` here could be:\n * 1) `null`\n * 2) an empty object\n * 3) \"populated\" but with a `null` value `{ getPost: null }`\n * 4) an actual record `{ getPost: { id: '1', title: 'Hello, World!' } }`\n */\n const { data, errors } = error;\n /**\n * `data` is not `null`, and is not an empty object:\n */\n if (data && Object.keys(data).length !== 0 && errors) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n /**\n * `flattenedResult` could be `null` here (e.g. `data: { getPost: null }`)\n * if `flattenedResult`, result is an actual record:\n */\n if (flattenedResult) {\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? initializeModel(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n errors,\n };\n }\n else {\n // was `data: { getPost: null }`)\n return handleSingularGraphQlError(error);\n }\n }\n else {\n // `data` is `null`:\n return handleSingularGraphQlError(error);\n }\n }\n });\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _opSubscription(client, modelIntrospection, operation, getInternals, args, options) {\n const operationType = 'subscription';\n const { name: operationName } = operation;\n const auth = authModeParams(client, getInternals, options);\n const headers = getCustomHeaders(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n const observable = client.graphql({\n ...auth,\n query,\n variables,\n }, headers);\n return observable.pipe(map((value) => {\n const [key] = Object.keys(value.data);\n const data = value.data[key];\n const [initialized] = returnTypeModelName\n ? initializeModel(client, returnTypeModelName, [data], modelIntrospection, auth.authMode, auth.authToken)\n : [data];\n return initialized;\n }));\n}\n"],"names":[],"mappings":";;;;;;AAKA;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,GAAG,KAAK;AAClC,IAAI,OAAO,OAAO,GAAG,EAAE,KAAK,EAAE,KAAK,KAAK,QAAQ,CAAC;AACjD,CAAC,CAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE;AAChH;AACA;AACA,IAAI,MAAM,WAAW,GAAG,SAAS,CAAC,SAAS,KAAK,SAAS,CAAC;AAC1D,IAAI,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KAAK;AAC5B;AACA,QAAQ,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9C,QAAQ,IAAI,WAAW,CAAC;AACxB,QAAQ,IAAI,GAAG,CAAC;AAChB,QAAQ,IAAI,UAAU,EAAE;AACxB,YAAY,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;AAC3C,gBAAgB,WAAW,GAAG,IAAI,CAAC,CAAC,C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CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC9C,QAAQ,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACrC,QAAQ,MAAM,CAAC,WAAW,CAAC,GAAG,mBAAmB;AACjD,cAAc,eAAe,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC,IAAI,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;AACrH,cAAc,CAAC,IAAI,CAAC,CAAC;AACrB,QAAQ,OAAO,WAAW,CAAC;AAC3B,KAAK,CAAC,CAAC,CAAC;AACR;;;;"}
|
|
1
|
+
{"version":3,"file":"custom.mjs","sources":["../../../../../src/runtime/internals/operations/custom.ts"],"sourcesContent":["import { map } from 'rxjs';\nimport { authModeParams, getDefaultSelectionSetForNonModelWithIR, generateSelectionSet, getCustomHeaders, initializeModel, selectionSetIRToString, } from '../APIClient';\nimport { handleSingularGraphQlError } from './utils';\nimport { selfAwareAsync } from '../../utils';\nimport { extendCancellability } from '../cancellation';\n/**\n * Type guard for checking whether a Custom Operation argument is a contextSpec object\n */\nconst argIsContextSpec = (arg) => {\n return typeof arg?.token?.value === 'symbol';\n};\n/**\n * Builds an operation function, embedded with all client and context data, that\n * can be attached to a client as a custom query or mutation.\n *\n * If we have this source schema:\n *\n * ```typescript\n * a.schema({\n * echo: a.query()\n * .arguments({input: a.string().required()})\n * .returns(a.string())\n * })\n * ```\n *\n * Our model intro schema will contain an entry like this:\n *\n * ```ts\n * {\n * queries: {\n * echo: {\n * name: \"echo\",\n * isArray: false,\n * type: 'String',\n * isRequired: false,\n * arguments: {\n * input: {\n * name: 'input',\n * isArray: false,\n * type: String,\n * isRequired: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * The `echo` object is used to build the `echo' method that goes here:\n *\n * ```typescript\n * const client = generateClent()\n * const { data } = await client.queries.echo({input: 'a string'});\n * // ^\n * // |\n * // +-- This one right here.\n * //\n * ```\n *\n *\n * @param client The client to run graphql queries through.\n * @param modelIntrospection The model introspection schema the op comes from.\n * @param operationType The broad category of graphql operation.\n * @param operation The operation definition from the introspection schema.\n * @param useContext Whether the function needs to accept an SSR context.\n * @returns The operation function to attach to query, mutations, etc.\n */\nexport function customOpFactory(client, modelIntrospection, operationType, operation, useContext, getInternals) {\n // .arguments() are defined for the custom operation in the schema builder\n // and are present in the model introspection schema\n const argsDefined = operation.arguments !== undefined;\n const op = (...args) => {\n // options is always the last argument\n const options = args[args.length - 1];\n let contextSpec;\n let arg;\n if (useContext) {\n if (argIsContextSpec(args[0])) {\n contextSpec = args[0];\n }\n else {\n throw new Error(`Invalid first argument passed to ${operation.name}. Expected contextSpec`);\n }\n }\n if (argsDefined) {\n if (useContext) {\n arg = args[1];\n }\n else {\n arg = args[0];\n }\n }\n if (operationType === 'subscription') {\n return _opSubscription(\n // subscriptions are only enabled on the clientside\n client, modelIntrospection, operation, getInternals, arg, options);\n }\n return _op(client, modelIntrospection, operationType, operation, getInternals, arg, options, contextSpec);\n };\n return op;\n}\n/**\n * Runtime test and type guard to check whether `o[field]` is a `String`.\n *\n * ```typescript\n * if (hasStringField(o, 'prop')) {\n * const s = o.prop;\n * // ^? const s: string\n * }\n * ```\n *\n * @param o Object to inspect\n * @param field Field to look for\n * @returns Boolean: `true` if the `o[field]` is a `string`\n */\nfunction hasStringField(o, field) {\n return typeof o[field] === 'string';\n}\nfunction isEnumType(type) {\n return type instanceof Object && 'enum' in type;\n}\nfunction isInputType(type) {\n return type instanceof Object && 'input' in type;\n}\n/**\n * @param argDef A single argument definition from a custom operation\n * @returns A string naming the base type including the `!` if the arg is required.\n */\nfunction argumentBaseTypeString({ type, isRequired }) {\n const requiredFlag = isRequired ? '!' : '';\n if (isEnumType(type)) {\n return `${type.enum}${requiredFlag}`;\n }\n if (isInputType(type)) {\n return `${type.input}${requiredFlag}`;\n }\n return `${type}${requiredFlag}`;\n}\n/**\n * Generates \"outer\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the top/outer level arguments as a string:\n *\n * ```json\n * \"InputString: String!\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction outerArguments(operation) {\n if (operation.arguments === undefined) {\n return '';\n }\n const args = Object.entries(operation.arguments)\n .map(([k, argument]) => {\n const baseType = argumentBaseTypeString(argument);\n const finalType = argument.isArray\n ? `[${baseType}]${argument.isArrayNullable ? '' : '!'}`\n : baseType;\n return `$${k}: ${finalType}`;\n })\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates \"inner\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the inner arguments as a string:\n *\n * ```json\n * \"InputString: $InputString\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction innerArguments(operation) {\n if (operation.arguments === undefined) {\n return '';\n }\n const args = Object.keys(operation.arguments)\n .map((k) => `${k}: $${k}`)\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates the selection set string for a custom operation. This is slightly\n * different than the selection set generation for models. If the custom op returns\n * a primitive or enum types, it doesn't require a selection set at all.\n *\n * E.g., the graphql might look like this:\n *\n * ```graphql\n * query MyQuery {\n * echoString(inputString: \"whatever\")\n * }\n * # ^\n * # |\n * # +-- no selection set\n * ```\n *\n * Non-primitive return type selection set generation will be similar to other\n * model operations.\n *\n * @param modelIntrospection The full code-generated introspection schema.\n * @param operation The operation object from the schema.\n * @returns The selection set as a string.\n */\nfunction operationSelectionSet(modelIntrospection, operation) {\n if (hasStringField(operation, 'type') ||\n hasStringField(operation.type, 'enum')) {\n return '';\n }\n else if (hasStringField(operation.type, 'nonModel')) {\n const nonModel = modelIntrospection.nonModels[operation.type.nonModel];\n return `{${selectionSetIRToString(getDefaultSelectionSetForNonModelWithIR(nonModel, modelIntrospection))}}`;\n }\n else if (hasStringField(operation.type, 'model')) {\n return `{${generateSelectionSet(modelIntrospection, operation.type.model)}}`;\n }\n else {\n return '';\n }\n}\n/**\n * Maps an arguments objec to graphql variables, removing superfluous args and\n * screaming loudly when required args are missing.\n *\n * @param operation The operation to construct graphql request variables for.\n * @param args The arguments to map variables from.\n * @returns The graphql variables object.\n */\nfunction operationVariables(operation, args = {}) {\n const variables = {};\n if (operation.arguments === undefined) {\n return variables;\n }\n for (const argDef of Object.values(operation.arguments)) {\n if (typeof args[argDef.name] !== 'undefined') {\n variables[argDef.name] = args[argDef.name];\n }\n else if (argDef.isRequired) {\n // At this point, the variable is both required and missing: We don't need\n // to continue. The operation is expected to fail.\n throw new Error(`${operation.name} requires arguments '${argDef.name}'`);\n }\n }\n return variables;\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operationType The high level graphql operation type.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @param context SSR context if relevant.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context) {\n return selfAwareAsync(async (resultPromise) => {\n const { name: operationName } = operation;\n const auth = authModeParams(client, getInternals, options);\n const headers = getCustomHeaders(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n try {\n const basePromise = context\n ? client.graphql(context, {\n ...auth,\n query,\n variables,\n }, headers)\n : client.graphql({\n ...auth,\n query,\n variables,\n }, headers);\n const extendedPromise = extendCancellability(basePromise, resultPromise);\n const { data, extensions } = await extendedPromise;\n // flatten response\n if (data) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? initializeModel(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n extensions,\n };\n }\n else {\n return { data: null, extensions };\n }\n }\n catch (error) {\n /**\n * The `data` type returned by `error` here could be:\n * 1) `null`\n * 2) an empty object\n * 3) \"populated\" but with a `null` value `{ getPost: null }`\n * 4) an actual record `{ getPost: { id: '1', title: 'Hello, World!' } }`\n */\n const { data, errors } = error;\n /**\n * `data` is not `null`, and is not an empty object:\n */\n if (data && Object.keys(data).length !== 0 && errors) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n /**\n * `flattenedResult` could be `null` here (e.g. `data: { getPost: null }`)\n * if `flattenedResult`, result is an actual record:\n */\n if (flattenedResult) {\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? initializeModel(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n errors,\n };\n }\n else {\n // was `data: { getPost: null }`)\n return handleSingularGraphQlError(error);\n }\n }\n else {\n // `data` is `null`:\n return handleSingularGraphQlError(error);\n }\n }\n });\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _opSubscription(client, modelIntrospection, operation, getInternals, args, options) {\n const operationType = 'subscription';\n const { name: operationName } = operation;\n const auth = authModeParams(client, getInternals, options);\n const headers = getCustomHeaders(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n const observable = client.graphql({\n ...auth,\n query,\n variables,\n }, headers);\n return observable.pipe(map((value) => {\n const [key] = Object.keys(value.data);\n const data = value.data[key];\n const [initialized] = returnTypeModelName\n ? initializeModel(client, returnTypeModelName, [data], modelIntrospection, auth.authMode, auth.authToken)\n : [data];\n return initialized;\n }));\n}\n"],"names":[],"mappings":";;;;;;AAKA;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,GAAG,KAAK;AAClC,IAAI,OAAO,OAAO,GAAG,EAAE,KAAK,EAAE,KAAK,KAAK,QAAQ,CAAC;AACjD,CAAC,CAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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AAQ,MAAM,CAAC,WAAW,CAAC,GAAG,mBAAmB;AACjD,cAAc,eAAe,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC,IAAI,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;AACrH,cAAc,CAAC,IAAI,CAAC,CAAC;AACrB,QAAQ,OAAO,WAAW,CAAC;AAC3B,KAAK,CAAC,CAAC,CAAC;AACR;;;;"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ConversationRoute } from '../../../../ai/ConversationType';
|
|
2
|
+
import { BaseClient, ClientInternalsGetter, GraphQLProviderConfig } from '../../../bridge-types';
|
|
3
|
+
export declare function generateConversationsProperty(client: BaseClient, apiGraphQLConfig: GraphQLProviderConfig['GraphQL'], getInternals: ClientInternalsGetter): Record<string, ConversationRoute>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createCreateConversationFunction } from '../../ai/createCreateConversationFunction.mjs';
|
|
2
|
+
import { createGetConversationFunction } from '../../ai/createGetConversationFunction.mjs';
|
|
3
|
+
import { createListConversationsFunction } from '../../ai/createListConversationsFunction.mjs';
|
|
4
|
+
|
|
5
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
function generateConversationsProperty(client, apiGraphQLConfig, getInternals) {
|
|
8
|
+
const modelIntrospection = apiGraphQLConfig?.modelIntrospection;
|
|
9
|
+
// conversations will be absent from model intro schema if no conversation routes
|
|
10
|
+
// are present on the source schema.
|
|
11
|
+
if (!modelIntrospection?.conversations) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
const conversations = {};
|
|
15
|
+
for (const { name, conversation, message, models, nonModels, enums, } of Object.values(modelIntrospection.conversations)) {
|
|
16
|
+
const conversationModel = models[conversation.modelName];
|
|
17
|
+
const conversationMessageModel = models[message.modelName];
|
|
18
|
+
if (!conversationModel || !conversationMessageModel) {
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
const conversationModelIntrospection = {
|
|
22
|
+
...modelIntrospection,
|
|
23
|
+
models: {
|
|
24
|
+
...modelIntrospection.models,
|
|
25
|
+
...models,
|
|
26
|
+
},
|
|
27
|
+
nonModels: {
|
|
28
|
+
...modelIntrospection.nonModels,
|
|
29
|
+
...nonModels,
|
|
30
|
+
},
|
|
31
|
+
enums: {
|
|
32
|
+
...modelIntrospection.enums,
|
|
33
|
+
...enums,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
conversations[name] = {
|
|
37
|
+
create: createCreateConversationFunction(client, conversationModelIntrospection, name, conversationModel, conversationMessageModel, getInternals),
|
|
38
|
+
get: createGetConversationFunction(client, conversationModelIntrospection, name, conversationModel, conversationMessageModel, getInternals),
|
|
39
|
+
list: createListConversationsFunction(client, conversationModelIntrospection, name, conversationModel, conversationMessageModel, getInternals),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return conversations;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { generateConversationsProperty };
|
|
46
|
+
//# sourceMappingURL=generateConversationsProperty.mjs.map
|
package/dist/esm/runtime/internals/utils/clientProperties/generateConversationsProperty.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateConversationsProperty.mjs","sources":["../../../../../../src/runtime/internals/utils/clientProperties/generateConversationsProperty.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createCreateConversationFunction } from '../../ai/createCreateConversationFunction';\nimport { createGetConversationFunction } from '../../ai/createGetConversationFunction';\nimport { createListConversationsFunction } from '../../ai/createListConversationsFunction';\nexport function generateConversationsProperty(client, apiGraphQLConfig, getInternals) {\n const modelIntrospection = apiGraphQLConfig?.modelIntrospection;\n // conversations will be absent from model intro schema if no conversation routes\n // are present on the source schema.\n if (!modelIntrospection?.conversations) {\n return {};\n }\n const conversations = {};\n for (const { name, conversation, message, models, nonModels, enums, } of Object.values(modelIntrospection.conversations)) {\n const conversationModel = models[conversation.modelName];\n const conversationMessageModel = models[message.modelName];\n if (!conversationModel || !conversationMessageModel) {\n return {};\n }\n const conversationModelIntrospection = {\n ...modelIntrospection,\n models: {\n ...modelIntrospection.models,\n ...models,\n },\n nonModels: {\n ...modelIntrospection.nonModels,\n ...nonModels,\n },\n enums: {\n ...modelIntrospection.enums,\n ...enums,\n },\n };\n conversations[name] = {\n create: createCreateConversationFunction(client, conversationModelIntrospection, name, conversationModel, conversationMessageModel, getInternals),\n get: createGetConversationFunction(client, conversationModelIntrospection, name, conversationModel, conversationMessageModel, getInternals),\n list: createListConversationsFunction(client, conversationModelIntrospection, name, conversationModel, conversationMessageModel, getInternals),\n };\n }\n return conversations;\n}\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIO,SAAS,6BAA6B,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE;AACtF,IAAI,MAAM,kBAAkB,GAAG,gBAAgB,EAAE,kBAAkB,CAAC;AACpE;AACA;AACA,IAAI,IAAI,CAAC,kBAAkB,EAAE,aAAa,EAAE;AAC5C,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,aAAa,GAAG,EAAE,CAAC;AAC7B,IAAI,KAAK,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,aAAa,CAAC,EAAE;AAC9H,QAAQ,MAAM,iBAAiB,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;AACjE,QAAQ,MAAM,wBAAwB,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AACnE,QAAQ,IAAI,CAAC,iBAAiB,IAAI,CAAC,wBAAwB,EAAE;AAC7D,YAAY,OAAO,EAAE,C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