@aws-amplify/data-schema 1.9.1 → 1.9.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/data-schema",
3
- "version": "1.9.1",
3
+ "version": "1.9.2",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1442,7 +1442,9 @@ const schemaPreprocessor = (
1442
1442
  }
1443
1443
  } else if (isConversationRoute(typeDef)) {
1444
1444
  // TODO: add inferenceConfiguration values to directive.
1445
- customMutations.push(createConversationField(typeDef, typeName));
1445
+ const { field, functionHandler } = createConversationField(typeDef, typeName);
1446
+ customMutations.push(field);
1447
+ Object.assign(lambdaFunctions, functionHandler);
1446
1448
  shouldAddConversationTypes = true;
1447
1449
  }
1448
1450
  } else if (staticSchema) {
@@ -1,3 +1,4 @@
1
+ import { LambdaFunctionDefinition } from '@aws-amplify/data-schema-types';
1
2
  import { InternalRef } from '../RefType';
2
3
  import { capitalize } from '../runtime/utils';
3
4
  import type {
@@ -8,7 +9,7 @@ import type {
8
9
  export const createConversationField = (
9
10
  typeDef: InternalConversationType,
10
11
  typeName: string,
11
- ): string => {
12
+ ): { field: string, functionHandler: LambdaFunctionDefinition } => {
12
13
  const { aiModel, systemPrompt, handler, tools } = typeDef;
13
14
 
14
15
  const args: Record<string, string> = {
@@ -25,12 +26,11 @@ export const createConversationField = (
25
26
  systemPrompt: systemPrompt.replace(/\r?\n/g, '\\n'),
26
27
  };
27
28
 
29
+ const functionHandler: LambdaFunctionDefinition = {};
28
30
  if (handler) {
29
- if (typeof handler === 'string') {
30
- args['functionName'] = handler;
31
- } else if (typeof handler.getInstance === 'function') {
32
- args['functionName'] = `Fn${capitalize(typeName)}`;
33
- }
31
+ const functionName = `Fn${capitalize(typeName)}`;
32
+ args['functionName'] = functionName;
33
+ functionHandler[functionName] = handler;
34
34
  }
35
35
 
36
36
  const argsString = Object.entries(args)
@@ -43,7 +43,8 @@ export const createConversationField = (
43
43
 
44
44
  const conversationDirective = `@conversation(${argsString}${toolsString})`;
45
45
 
46
- return `${typeName}(conversationId: ID!, content: [ContentBlockInput], aiContext: AWSJSON, toolConfiguration: ToolConfigurationInput): ConversationMessage ${conversationDirective} @aws_cognito_user_pools`;
46
+ const field = `${typeName}(conversationId: ID!, content: [ContentBlockInput], aiContext: AWSJSON, toolConfiguration: ToolConfigurationInput): ConversationMessage ${conversationDirective} @aws_cognito_user_pools`;
47
+ return { field, functionHandler };
47
48
  };
48
49
 
49
50
  const isRef = (query: unknown): query is { data: InternalRef['data'] } =>
@@ -125,7 +125,7 @@ export interface ConversationInput {
125
125
  systemPrompt: string;
126
126
  inferenceConfiguration?: InferenceConfiguration;
127
127
  tools?: ToolDefinition[];
128
- handler?: DefineFunction | string;
128
+ handler?: DefineFunction;
129
129
  }
130
130
 
131
131
  export interface InternalConversationType