Skip to content

Commit bf16475

Browse files
committed
feat: Add backend-function data config with runtime support
1 parent f83d6d5 commit bf16475

File tree

25 files changed

+478
-154
lines changed

25 files changed

+478
-154
lines changed

.changeset/brave-cheetahs-repeat.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@aws-amplify/backend': patch
3+
'@aws-amplify/backend-function': patch
4+
---
5+
6+
feat: Add backend-function runtime behavior to get the data config

package-lock.json

Lines changed: 29 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/ai-constructs/CHANGELOG.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
# @aws-amplify/ai-constructs
22

3-
## 1.0.0
4-
5-
### Major Changes
6-
7-
- bbd6add: GA release of backend AI features
8-
9-
### Patch Changes
10-
11-
- fd8759d: Fix a case when Bedrock throws validation error if tool input is not persisted in history
12-
133
## 0.8.2
144

155
### Patch Changes

packages/ai-constructs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aws-amplify/ai-constructs",
3-
"version": "1.0.0",
3+
"version": "0.8.2",
44
"type": "commonjs",
55
"publishConfig": {
66
"access": "public"

packages/ai-constructs/src/conversation/runtime/bedrock_converse_adapter.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,8 @@ void describe('Bedrock converse adapter', () => {
901901
assert.strictEqual(responseText, 'finalResponse');
902902

903903
assert.strictEqual(toolExecuteMock.mock.calls.length, 2);
904-
assert.deepStrictEqual(toolExecuteMock.mock.calls[0].arguments[0], {});
905-
assert.deepStrictEqual(toolExecuteMock.mock.calls[1].arguments[0], {});
904+
assert.strictEqual(toolExecuteMock.mock.calls[0].arguments[0], undefined);
905+
assert.strictEqual(toolExecuteMock.mock.calls[1].arguments[0], undefined);
906906
});
907907

908908
void it('throws if tool is duplicated', () => {

packages/ai-constructs/src/conversation/runtime/bedrock_converse_adapter.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,6 @@ export class BedrockConverseAdapter {
252252
if (toolUseBlock) {
253253
if (toolUseInput) {
254254
toolUseBlock.toolUse.input = JSON.parse(toolUseInput);
255-
} else {
256-
// Bedrock API requires tool input to be non-null in message history.
257-
// Therefore, falling back to empty object.
258-
toolUseBlock.toolUse.input = {};
259255
}
260256
accumulatedAssistantMessage.content?.push(toolUseBlock);
261257
if (

packages/backend-ai/CHANGELOG.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
# @aws-amplify/backend-ai
22

3-
## 1.0.0
4-
5-
### Major Changes
6-
7-
- bbd6add: GA release of backend AI features
8-
9-
### Patch Changes
10-
11-
- Updated dependencies [fd8759d]
12-
- Updated dependencies [bbd6add]
13-
- @aws-amplify/ai-constructs@1.0.0
14-
153
## 0.3.5
164

175
### Patch Changes

packages/backend-ai/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aws-amplify/backend-ai",
3-
"version": "1.0.0",
3+
"version": "0.3.5",
44
"type": "module",
55
"publishConfig": {
66
"access": "public"
@@ -22,7 +22,7 @@
2222
},
2323
"license": "Apache-2.0",
2424
"dependencies": {
25-
"@aws-amplify/ai-constructs": "^1.0.0",
25+
"@aws-amplify/ai-constructs": "^0.8.0",
2626
"@aws-amplify/backend-output-schemas": "^1.4.0",
2727
"@aws-amplify/backend-output-storage": "^1.1.3",
2828
"@aws-amplify/data-schema-types": "^1.2.0",

packages/backend-function/API.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,23 @@ import { ConstructFactory } from '@aws-amplify/plugin-types';
99
import { FunctionResources } from '@aws-amplify/plugin-types';
1010
import { ResourceAccessAcceptorFactory } from '@aws-amplify/plugin-types';
1111
import { ResourceProvider } from '@aws-amplify/plugin-types';
12+
import { S3Client } from '@aws-sdk/client-s3';
1213
import { StackProvider } from '@aws-amplify/plugin-types';
1314

15+
declare namespace __export__runtime {
16+
export {
17+
getAmplifyDataClientConfig,
18+
DataClientConfig,
19+
DataClientEnv,
20+
DataClientError,
21+
DataClientReturn,
22+
InvalidConfig,
23+
LibraryOptions,
24+
ResourceConfig
25+
}
26+
}
27+
export { __export__runtime }
28+
1429
// @public (undocumented)
1530
export type AddEnvironmentFactory = {
1631
addEnvironment: (key: string, value: string | BackendSecret) => void;
@@ -19,6 +34,32 @@ export type AddEnvironmentFactory = {
1934
// @public (undocumented)
2035
export type CronSchedule = `${string} ${string} ${string} ${string} ${string}` | `${string} ${string} ${string} ${string} ${string} ${string}`;
2136

37+
// @public (undocumented)
38+
type DataClientConfig = {
39+
resourceConfig: ResourceConfig;
40+
libraryOptions: LibraryOptions;
41+
};
42+
43+
// @public (undocumented)
44+
type DataClientEnv = {
45+
AMPLIFY_DATA_GRAPHQL_ENDPOINT: string;
46+
AMPLIFY_DATA_MODEL_INTROSPECTION_SCHEMA_BUCKET_NAME: string;
47+
AMPLIFY_DATA_MODEL_INTROSPECTION_SCHEMA_KEY: string;
48+
AWS_ACCESS_KEY_ID: string;
49+
AWS_SECRET_ACCESS_KEY: string;
50+
AWS_SESSION_TOKEN: string;
51+
AWS_REGION: string;
52+
};
53+
54+
// @public (undocumented)
55+
type DataClientError = {
56+
resourceConfig: InvalidConfig;
57+
libraryOptions: InvalidConfig;
58+
};
59+
60+
// @public (undocumented)
61+
type DataClientReturn<T> = T extends DataClientEnv ? DataClientConfig : DataClientError;
62+
2263
// @public
2364
export const defineFunction: (props?: FunctionProps) => ConstructFactory<ResourceProvider<FunctionResources> & ResourceAccessAcceptorFactory & AddEnvironmentFactory & StackProvider>;
2465

@@ -43,9 +84,45 @@ export type FunctionProps = {
4384
// @public (undocumented)
4485
export type FunctionSchedule = TimeInterval | CronSchedule;
4586

87+
// @public
88+
const getAmplifyDataClientConfig: <T>(env: T, s3Client?: S3Client) => Promise<DataClientReturn<T>>;
89+
90+
// @public (undocumented)
91+
type InvalidConfig = unknown & {
92+
invalidType: 'This function needs to be granted `authorization((allow) => [allow.resource(fcn)])` on the data schema.';
93+
};
94+
95+
// @public (undocumented)
96+
type LibraryOptions = {
97+
Auth: {
98+
credentialsProvider: {
99+
getCredentialsAndIdentityId: () => Promise<{
100+
credentials: {
101+
accessKeyId: string;
102+
secretAccessKey: string;
103+
sessionToken: string;
104+
};
105+
}>;
106+
clearCredentialsAndIdentityId: () => void;
107+
};
108+
};
109+
};
110+
46111
// @public (undocumented)
47112
export type NodeVersion = 16 | 18 | 20;
48113

114+
// @public (undocumented)
115+
type ResourceConfig = {
116+
API: {
117+
GraphQL: {
118+
endpoint: string;
119+
region: string;
120+
defaultAuthMode: string;
121+
modelIntrospection: any;
122+
};
123+
};
124+
};
125+
49126
// @public (undocumented)
50127
export type TimeInterval = `every ${number}m` | `every ${number}h` | `every day` | `every week` | `every month` | `every year`;
51128

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"extends": "../../api-extractor.base.json"
2+
"extends": "../../api-extractor.base.json",
3+
"mainEntryPointFilePath": "<projectFolder>/lib/index.internal.d.ts"
34
}

0 commit comments

Comments
 (0)