@aws-amplify/data-schema 1.25.2 → 1.25.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/cjs/CombineSchema.js.map +1 -1
  2. package/dist/cjs/ModelRelationshipField.js.map +1 -1
  3. package/dist/cjs/RefType.js.map +1 -1
  4. package/dist/cjs/ai/ConversationSchemaProcessor.js +28 -4
  5. package/dist/cjs/ai/ConversationSchemaProcessor.js.map +1 -1
  6. package/dist/cjs/ai/ModelType.js +3 -0
  7. package/dist/cjs/ai/ModelType.js.map +1 -1
  8. package/dist/cjs/runtime/internals/APIClient.js +0 -5
  9. package/dist/cjs/runtime/internals/APIClient.js.map +1 -1
  10. package/dist/cjs/runtime/internals/operations/indexQuery.js +2 -0
  11. package/dist/cjs/runtime/internals/operations/indexQuery.js.map +1 -1
  12. package/dist/esm/CombineSchema.d.ts +2 -2
  13. package/dist/esm/CombineSchema.mjs.map +1 -1
  14. package/dist/esm/ModelRelationshipField.d.ts +2 -2
  15. package/dist/esm/ModelRelationshipField.mjs.map +1 -1
  16. package/dist/esm/RefType.d.ts +2 -2
  17. package/dist/esm/RefType.mjs.map +1 -1
  18. package/dist/esm/ai/ConversationSchemaProcessor.mjs +28 -4
  19. package/dist/esm/ai/ConversationSchemaProcessor.mjs.map +1 -1
  20. package/dist/esm/ai/ModelType.d.ts +2 -0
  21. package/dist/esm/ai/ModelType.mjs +3 -0
  22. package/dist/esm/ai/ModelType.mjs.map +1 -1
  23. package/dist/esm/runtime/internals/APIClient.mjs +0 -5
  24. package/dist/esm/runtime/internals/APIClient.mjs.map +1 -1
  25. package/dist/esm/runtime/internals/operations/indexQuery.mjs +2 -0
  26. package/dist/esm/runtime/internals/operations/indexQuery.mjs.map +1 -1
  27. package/dist/meta/cjs.tsbuildinfo +1 -1
  28. package/package.json +4 -4
  29. package/src/CombineSchema.ts +2 -2
  30. package/src/ModelRelationshipField.ts +4 -4
  31. package/src/RefType.ts +2 -2
  32. package/src/ai/ConversationSchemaProcessor.ts +37 -4
  33. package/src/ai/ModelType.ts +3 -0
  34. package/src/runtime/internals/APIClient.ts +0 -5
  35. package/src/runtime/internals/operations/indexQuery.ts +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/data-schema",
3
- "version": "1.25.2",
3
+ "version": "1.25.4",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,12 +11,12 @@
11
11
  "types": "./dist/esm/index.d.ts",
12
12
  "scripts": {
13
13
  "build:esm-cjs": "rollup -c rollup.config.mjs",
14
- "build": "npm run clean && npm run build:esm-cjs",
15
- "build:watch": "npm run build:esm-cjs -- --watch",
14
+ "build": "yarn clean && yarn build:esm-cjs",
15
+ "build:watch": "yarn build:esm-cjs -- --watch",
16
16
  "clean": "rimraf dist",
17
17
  "docs": "api-extractor run && api-documenter markdown --input-folder temp --output-folder docs",
18
18
  "docs:temp": "api-extractor run && api-documenter markdown --input-folder temp --output-folder temp/docs",
19
- "check:api": "rimraf temp && npm run docs:temp && tsx ../../scripts/shallow-dir-diff.ts docs temp/docs",
19
+ "check:api": "rimraf temp && yarn docs:temp && tsx ../../scripts/shallow-dir-diff.ts docs temp/docs",
20
20
  "lint": "eslint .",
21
21
  "test": "jest --coverage"
22
22
  },
@@ -1,10 +1,10 @@
1
1
  import { GenericModelSchema } from './ModelSchema';
2
2
  import { brand, Brand, IndexLimitUnion } from './util';
3
3
 
4
- const COMBINED_SCHEMA_LIMIT = 50;
4
+ const _COMBINED_SCHEMA_LIMIT = 50;
5
5
 
6
6
  export type CombinedSchemaIndexesUnion = IndexLimitUnion<
7
- typeof COMBINED_SCHEMA_LIMIT
7
+ typeof _COMBINED_SCHEMA_LIMIT
8
8
  >[number];
9
9
 
10
10
  const CombinedSchemaBrandName = 'CombinedSchema';
@@ -7,7 +7,7 @@ import { AllowModifier, Authorization, allow } from './Authorization';
7
7
  */
8
8
  export const __auth = Symbol('__auth');
9
9
 
10
- const brandName = 'modelRelationshipField';
10
+ const _brandName = 'modelRelationshipField';
11
11
 
12
12
  /**
13
13
  * Model relationship types
@@ -86,7 +86,7 @@ export type ModelRelationshipField<
86
86
  > = Omit<ModelRelationshipFieldFunctions<T, RM, K>, K> & {
87
87
  // This is a lie. This property is never set at runtime. It's just used to smuggle auth types through.
88
88
  [__auth]?: Auth;
89
- } & Brand<typeof brandName>;
89
+ } & Brand<typeof _brandName>;
90
90
 
91
91
  /**
92
92
  * Internal representation of Model Field that exposes the `data` property.
@@ -100,7 +100,7 @@ export type InternalRelationshipField = ModelRelationshipField<
100
100
  data: ModelRelationshipFieldData;
101
101
  };
102
102
 
103
- const relationshipModifiers = [
103
+ const _relationshipModifiers = [
104
104
  'required',
105
105
  'valueRequired',
106
106
  'authorization',
@@ -108,7 +108,7 @@ const relationshipModifiers = [
108
108
 
109
109
  const relationModifierMap: Record<
110
110
  `${ModelRelationshipTypes}`,
111
- (typeof relationshipModifiers)[number][]
111
+ (typeof _relationshipModifiers)[number][]
112
112
  > = {
113
113
  belongsTo: ['authorization'],
114
114
  hasMany: ['valueRequired', 'authorization'],
package/src/RefType.ts CHANGED
@@ -3,7 +3,7 @@ import { Brand } from './util';
3
3
  import { AllowModifier, Authorization, allow } from './Authorization';
4
4
  import { __auth } from './ModelField';
5
5
 
6
- const brandName = 'ref';
6
+ const _brandName = 'ref';
7
7
 
8
8
  type RefTypeData = {
9
9
  type: 'ref';
@@ -72,7 +72,7 @@ export type RefType<
72
72
  > & {
73
73
  // This is a lie. This property is never set at runtime. It's just used to smuggle auth types through.
74
74
  [__auth]?: Auth;
75
- } & Brand<typeof brandName>;
75
+ } & Brand<typeof _brandName>;
76
76
 
77
77
  function brandedBuilder<T extends RefTypeParamShape>(
78
78
  builder: Record<keyof RefType<T> & string, any>,
@@ -6,12 +6,14 @@ import type {
6
6
  InternalConversationType,
7
7
  DataToolDefinition,
8
8
  } from './ConversationType';
9
+ import type { InferenceConfiguration } from './ModelType';
9
10
 
10
11
  export const createConversationField = (
11
12
  typeDef: InternalConversationType,
12
13
  typeName: string,
13
14
  ): { field: string; functionHandler: LambdaFunctionDefinition } => {
14
- const { aiModel, systemPrompt, handler, tools } = typeDef;
15
+ const { aiModel, systemPrompt, inferenceConfiguration, handler, tools } =
16
+ typeDef;
15
17
  const { strategy, provider } = extractAuthorization(typeDef, typeName);
16
18
 
17
19
  const args: Record<string, string> = {
@@ -28,9 +30,21 @@ export const createConversationField = (
28
30
  systemPrompt: systemPrompt.replace(/\r?\n/g, '\\n'),
29
31
  };
30
32
 
31
- const argsString = Object.entries(args)
32
- .map(([key, value]) => `${key}: "${value}"`)
33
- .join(', ');
33
+ // Add each arg with quotes (aiModel and systemPrompt)
34
+ const argsParts = [];
35
+ for (const [key, value] of Object.entries(args)) {
36
+ argsParts.push(`${key}: "${value}"`);
37
+ }
38
+
39
+ // Add inferenceConfiguration (do nothing if it doesn't exist or is empty)
40
+ const formattedInferenceConfig = formatInferenceConfig(
41
+ inferenceConfiguration,
42
+ );
43
+ if (formattedInferenceConfig) {
44
+ argsParts.push(`inferenceConfiguration: ${formattedInferenceConfig}`);
45
+ }
46
+
47
+ const argsString = argsParts.join(', ');
34
48
 
35
49
  const authString = `, auth: { strategy: ${strategy}, provider: ${provider} }`;
36
50
  const functionHandler: LambdaFunctionDefinition = {};
@@ -52,6 +66,25 @@ export const createConversationField = (
52
66
  return { field, functionHandler };
53
67
  };
54
68
 
69
+ /**
70
+ * Format inferenceConfiguration as GraphQL input syntax.
71
+ * Returns null if config is undefined or has no valid properties.
72
+ */
73
+ const formatInferenceConfig = (
74
+ config: InferenceConfiguration | undefined,
75
+ ): string | null => {
76
+ if (!config) return null;
77
+
78
+ const parts: string[] = [];
79
+ if (config.temperature !== undefined)
80
+ parts.push(`temperature: ${config.temperature}`);
81
+ if (config.maxTokens !== undefined)
82
+ parts.push(`maxTokens: ${config.maxTokens}`);
83
+ if (config.topP !== undefined) parts.push(`topP: ${config.topP}`);
84
+
85
+ return parts.length > 0 ? `{ ${parts.join(', ')} }` : null;
86
+ };
87
+
55
88
  const isRef = (query: unknown): query is { data: InternalRef['data'] } =>
56
89
  (query as any)?.data?.type === 'ref';
57
90
 
@@ -22,6 +22,9 @@ const supportedModelsLookup = {
22
22
  'Claude Haiku 4.5': 'global.anthropic.claude-haiku-4-5-20251001-v1:0',
23
23
  'Claude Sonnet 4.5': 'global.anthropic.claude-sonnet-4-5-20250929-v1:0',
24
24
  'Claude Opus 4.5': 'global.anthropic.claude-opus-4-5-20251101-v1:0',
25
+ // Claude 4.6 models (require global inference profiles)
26
+ 'Claude Sonnet 4.6': 'global.anthropic.claude-sonnet-4-6',
27
+ 'Claude Opus 4.6': 'global.anthropic.claude-opus-4-6-v1',
25
28
  // Cohere models
26
29
  'Cohere Command R': 'cohere.command-r-v1:0',
27
30
  'Cohere Command R+': 'cohere.command-r-plus-v1:0',
@@ -239,7 +239,6 @@ export function initializeModel(
239
239
  case connectionType.BELONGS_TO: {
240
240
  const sortKeyValues = relatedModelSKFieldNames.reduce(
241
241
  // TODO(Eslint): is this implementation correct?
242
- // eslint-disable-next-line array-callback-return
243
242
  (acc: Record<string, any>, curVal) => {
244
243
  if (record[curVal]) {
245
244
  acc[curVal] = record[curVal];
@@ -1042,12 +1041,10 @@ export function generateGraphQLDocument(
1042
1041
  });
1043
1042
  graphQLOperationType ?? (graphQLOperationType = 'mutation');
1044
1043
  // TODO(Eslint): this this case clause correct without the break statement?
1045
- // eslint-disable-next-line no-fallthrough
1046
1044
  case 'GET':
1047
1045
  graphQLArguments ?? (graphQLArguments = getPkArgs);
1048
1046
  graphQLSelectionSet ?? (graphQLSelectionSet = selectionSetFields);
1049
1047
  // TODO(Eslint): this this case clause correct without the break statement?
1050
- // eslint-disable-next-line no-fallthrough
1051
1048
  case 'LIST':
1052
1049
  graphQLArguments ??
1053
1050
  (graphQLArguments = {
@@ -1066,7 +1063,6 @@ export function generateGraphQLDocument(
1066
1063
  graphQLSelectionSet ??
1067
1064
  (graphQLSelectionSet = `items { ${selectionSetFields} } nextToken __typename`);
1068
1065
  // TODO(Eslint): this this case clause correct without the break statement?
1069
- // eslint-disable-next-line no-fallthrough
1070
1066
  case 'INDEX_QUERY':
1071
1067
  graphQLArguments ??
1072
1068
  (graphQLArguments = {
@@ -1080,7 +1076,6 @@ export function generateGraphQLDocument(
1080
1076
  graphQLSelectionSet ??
1081
1077
  (graphQLSelectionSet = `items { ${selectionSetFields} } nextToken __typename`);
1082
1078
  // TODO(Eslint): this this case clause correct without the break statement?
1083
- // eslint-disable-next-line no-fallthrough
1084
1079
  case 'ONCREATE':
1085
1080
  case 'ONUPDATE':
1086
1081
  case 'ONDELETE':
@@ -213,6 +213,7 @@ function _indexQuery(
213
213
  ? flattenedResult
214
214
  : modelInitializer(flattenedResult),
215
215
  nextToken: data[key]?.nextToken,
216
+ errors,
216
217
  };
217
218
  }
218
219
  }
@@ -221,6 +222,7 @@ function _indexQuery(
221
222
  return {
222
223
  data: data[key],
223
224
  nextToken: data[key]?.nextToken,
225
+ errors,
224
226
  };
225
227
  } else {
226
228
  // `data` is `null` or an empty object: