@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.
- 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 +35 -19
- 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 +82 -23
- 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,60 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { SingularReturnValue } from '../..';
|
|
5
|
+
import type {
|
|
6
|
+
Conversation,
|
|
7
|
+
ConversationMessage,
|
|
8
|
+
} from '../../../ai/ConversationType';
|
|
9
|
+
import type {
|
|
10
|
+
BaseClient,
|
|
11
|
+
ClientInternalsGetter,
|
|
12
|
+
ModelIntrospectionSchema,
|
|
13
|
+
} from '../../bridge-types';
|
|
14
|
+
import { customOpFactory } from '../operations/custom';
|
|
15
|
+
import { convertItemToConversationMessage } from './convertItemToConversationMessage';
|
|
16
|
+
import {
|
|
17
|
+
serializeAiContext,
|
|
18
|
+
serializeContent,
|
|
19
|
+
serializeToolConfiguration,
|
|
20
|
+
} from './conversationMessageSerializers';
|
|
21
|
+
|
|
22
|
+
export const createSendMessageFunction =
|
|
23
|
+
(
|
|
24
|
+
client: BaseClient,
|
|
25
|
+
modelIntrospection: ModelIntrospectionSchema,
|
|
26
|
+
conversationId: string,
|
|
27
|
+
conversationRouteName: string,
|
|
28
|
+
getInternals: ClientInternalsGetter,
|
|
29
|
+
): Conversation['sendMessage'] =>
|
|
30
|
+
async ({ aiContext, content, toolConfiguration }) => {
|
|
31
|
+
const { conversations } = modelIntrospection;
|
|
32
|
+
|
|
33
|
+
// Safe guard for standalone function. When called as part of client generation, this should never be falsy.
|
|
34
|
+
if (!conversations) {
|
|
35
|
+
return {} as SingularReturnValue<ConversationMessage>;
|
|
36
|
+
}
|
|
37
|
+
const sendSchema = conversations[conversationRouteName].message.send;
|
|
38
|
+
const sendOperation = customOpFactory(
|
|
39
|
+
client,
|
|
40
|
+
modelIntrospection,
|
|
41
|
+
'mutation',
|
|
42
|
+
sendSchema,
|
|
43
|
+
false,
|
|
44
|
+
getInternals,
|
|
45
|
+
) as (
|
|
46
|
+
args?: Record<string, any>,
|
|
47
|
+
) => SingularReturnValue<ConversationMessage>;
|
|
48
|
+
const { data, errors } = await sendOperation({
|
|
49
|
+
conversationId,
|
|
50
|
+
content: serializeContent(content),
|
|
51
|
+
...(aiContext && { aiContext: serializeAiContext(aiContext) }),
|
|
52
|
+
...(toolConfiguration && {
|
|
53
|
+
toolConfiguration: serializeToolConfiguration(toolConfiguration),
|
|
54
|
+
}),
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
data: data ? convertItemToConversationMessage(data) : data,
|
|
58
|
+
errors,
|
|
59
|
+
};
|
|
60
|
+
};
|
|
@@ -5,6 +5,8 @@ export {
|
|
|
5
5
|
generateCustomQueriesProperty,
|
|
6
6
|
generateCustomSubscriptionsProperty,
|
|
7
7
|
} from './generateCustomOperationsProperty';
|
|
8
|
+
export { generateConversationsProperty } from './utils/clientProperties/generateConversationsProperty';
|
|
9
|
+
export { generateGenerationsProperty } from './utils/clientProperties/generateGenerationsProperty';
|
|
8
10
|
export { generateEnumsProperty } from './utils/clientProperties/generateEnumsProperty';
|
|
9
11
|
export { generateModelsProperty } from './utils/clientProperties/generateModelsProperty';
|
|
10
12
|
export { isGraphQLResponseWithErrors } from './utils/runtimeTypeGuards/isGraphQLResponseWithErrors';
|
|
@@ -13,6 +13,10 @@ import {
|
|
|
13
13
|
ListArgs,
|
|
14
14
|
QueryArgs,
|
|
15
15
|
ModelIntrospectionSchema,
|
|
16
|
+
CustomOperationArgument,
|
|
17
|
+
InputFieldType,
|
|
18
|
+
EnumType,
|
|
19
|
+
InputType,
|
|
16
20
|
} from '../../bridge-types';
|
|
17
21
|
|
|
18
22
|
import { map } from 'rxjs';
|
|
@@ -194,19 +198,27 @@ function hasStringField<Field extends string>(
|
|
|
194
198
|
return typeof o[field] === 'string';
|
|
195
199
|
}
|
|
196
200
|
|
|
201
|
+
function isEnumType(type: InputFieldType): type is EnumType {
|
|
202
|
+
return type instanceof Object && 'enum' in type;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function isInputType(type: InputFieldType): type is InputType {
|
|
206
|
+
return type instanceof Object && 'input' in type;
|
|
207
|
+
}
|
|
208
|
+
|
|
197
209
|
/**
|
|
198
210
|
* @param argDef A single argument definition from a custom operation
|
|
199
211
|
* @returns A string naming the base type including the `!` if the arg is required.
|
|
200
212
|
*/
|
|
201
|
-
function argumentBaseTypeString(
|
|
202
|
-
|
|
203
|
-
) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
return argDef.type + requiredFlag;
|
|
213
|
+
function argumentBaseTypeString({ type, isRequired }: CustomOperationArgument) {
|
|
214
|
+
const requiredFlag = isRequired ? '!' : '';
|
|
215
|
+
if (isEnumType(type)) {
|
|
216
|
+
return `${type.enum}${requiredFlag}`;
|
|
217
|
+
}
|
|
218
|
+
if (isInputType(type)) {
|
|
219
|
+
return `${type.input}${requiredFlag}`;
|
|
209
220
|
}
|
|
221
|
+
return `${type}${requiredFlag}`;
|
|
210
222
|
}
|
|
211
223
|
|
|
212
224
|
/**
|
|
@@ -233,10 +245,10 @@ function outerArguments(operation: CustomOperation): string {
|
|
|
233
245
|
return '';
|
|
234
246
|
}
|
|
235
247
|
const args = Object.entries(operation.arguments)
|
|
236
|
-
.map(([k,
|
|
237
|
-
const baseType = argumentBaseTypeString(
|
|
238
|
-
const finalType =
|
|
239
|
-
? `[${baseType}]${
|
|
248
|
+
.map(([k, argument]) => {
|
|
249
|
+
const baseType = argumentBaseTypeString(argument);
|
|
250
|
+
const finalType = argument.isArray
|
|
251
|
+
? `[${baseType}]${argument.isArrayNullable ? '' : '!'}`
|
|
240
252
|
: baseType;
|
|
241
253
|
|
|
242
254
|
return `$${k}: ${finalType}`;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ConversationRoute } from '../../../../ai/ConversationType';
|
|
5
|
+
import {
|
|
6
|
+
BaseClient,
|
|
7
|
+
ClientInternalsGetter,
|
|
8
|
+
GraphQLProviderConfig,
|
|
9
|
+
ModelIntrospectionSchema,
|
|
10
|
+
} from '../../../bridge-types';
|
|
11
|
+
import { createCreateConversationFunction } from '../../ai/createCreateConversationFunction';
|
|
12
|
+
import { createGetConversationFunction } from '../../ai/createGetConversationFunction';
|
|
13
|
+
import { createListConversationsFunction } from '../../ai/createListConversationsFunction';
|
|
14
|
+
|
|
15
|
+
export function generateConversationsProperty(
|
|
16
|
+
client: BaseClient,
|
|
17
|
+
apiGraphQLConfig: GraphQLProviderConfig['GraphQL'],
|
|
18
|
+
getInternals: ClientInternalsGetter,
|
|
19
|
+
): Record<string, ConversationRoute> {
|
|
20
|
+
const modelIntrospection: ModelIntrospectionSchema | undefined =
|
|
21
|
+
apiGraphQLConfig?.modelIntrospection;
|
|
22
|
+
|
|
23
|
+
// conversations will be absent from model intro schema if no conversation routes
|
|
24
|
+
// are present on the source schema.
|
|
25
|
+
if (!modelIntrospection?.conversations) {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const conversations: Record<string, ConversationRoute> = {};
|
|
30
|
+
|
|
31
|
+
for (const {
|
|
32
|
+
name,
|
|
33
|
+
conversation,
|
|
34
|
+
message,
|
|
35
|
+
models,
|
|
36
|
+
nonModels,
|
|
37
|
+
enums,
|
|
38
|
+
} of Object.values(modelIntrospection.conversations)) {
|
|
39
|
+
const conversationModel = models[conversation.modelName];
|
|
40
|
+
const conversationMessageModel = models[message.modelName];
|
|
41
|
+
|
|
42
|
+
if (!conversationModel || !conversationMessageModel) {
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const conversationModelIntrospection: ModelIntrospectionSchema = {
|
|
47
|
+
...modelIntrospection,
|
|
48
|
+
models: {
|
|
49
|
+
...modelIntrospection.models,
|
|
50
|
+
...models,
|
|
51
|
+
},
|
|
52
|
+
nonModels: {
|
|
53
|
+
...modelIntrospection.nonModels,
|
|
54
|
+
...nonModels,
|
|
55
|
+
},
|
|
56
|
+
enums: {
|
|
57
|
+
...modelIntrospection.enums,
|
|
58
|
+
...enums,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
conversations[name] = {
|
|
63
|
+
create: createCreateConversationFunction(
|
|
64
|
+
client,
|
|
65
|
+
conversationModelIntrospection,
|
|
66
|
+
name,
|
|
67
|
+
conversationModel,
|
|
68
|
+
conversationMessageModel,
|
|
69
|
+
getInternals,
|
|
70
|
+
),
|
|
71
|
+
get: createGetConversationFunction(
|
|
72
|
+
client,
|
|
73
|
+
conversationModelIntrospection,
|
|
74
|
+
name,
|
|
75
|
+
conversationModel,
|
|
76
|
+
conversationMessageModel,
|
|
77
|
+
getInternals,
|
|
78
|
+
),
|
|
79
|
+
list: createListConversationsFunction(
|
|
80
|
+
client,
|
|
81
|
+
conversationModelIntrospection,
|
|
82
|
+
name,
|
|
83
|
+
conversationModel,
|
|
84
|
+
conversationMessageModel,
|
|
85
|
+
getInternals,
|
|
86
|
+
),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return conversations;
|
|
91
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
BaseClient,
|
|
6
|
+
ClientInternalsGetter,
|
|
7
|
+
GraphQLProviderConfig,
|
|
8
|
+
ModelIntrospectionSchema,
|
|
9
|
+
} from '../../../bridge-types';
|
|
10
|
+
import { CustomQueries } from '../../../client';
|
|
11
|
+
import { customOpFactory } from '../../operations/custom';
|
|
12
|
+
|
|
13
|
+
export function generateGenerationsProperty<T extends Record<any, any>>(
|
|
14
|
+
client: BaseClient,
|
|
15
|
+
apiGraphQLConfig: GraphQLProviderConfig['GraphQL'],
|
|
16
|
+
getInternals: ClientInternalsGetter,
|
|
17
|
+
): CustomQueries<T> {
|
|
18
|
+
const modelIntrospection: ModelIntrospectionSchema | undefined =
|
|
19
|
+
apiGraphQLConfig?.modelIntrospection;
|
|
20
|
+
|
|
21
|
+
// generations will be absent from model intro schema if no generation routes
|
|
22
|
+
// are present on the source schema.
|
|
23
|
+
if (!modelIntrospection?.generations) {
|
|
24
|
+
return {} as CustomQueries<T>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const generations: Record<string, any> = {};
|
|
28
|
+
|
|
29
|
+
for (const generation of Object.values(modelIntrospection.generations)) {
|
|
30
|
+
generations[generation.name] = customOpFactory(
|
|
31
|
+
client,
|
|
32
|
+
modelIntrospection,
|
|
33
|
+
'query',
|
|
34
|
+
generation,
|
|
35
|
+
false,
|
|
36
|
+
getInternals,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return generations as CustomQueries<T>;
|
|
41
|
+
}
|