Skip to content

Commit 79297bb

Browse files
author
awstools
committed
feat(client-b2bi): This release adds a GenerateMapping API to allow generation of JSONata or XSLT transformer code based on input and output samples.
1 parent b46415d commit 79297bb

File tree

8 files changed

+374
-2
lines changed

8 files changed

+374
-2
lines changed

clients/client-b2bi/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,14 @@ DeleteTransformer
284284

285285
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/b2bi/command/DeleteTransformerCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-b2bi/Interface/DeleteTransformerCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-b2bi/Interface/DeleteTransformerCommandOutput/)
286286

287+
</details>
288+
<details>
289+
<summary>
290+
GenerateMapping
291+
</summary>
292+
293+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/b2bi/command/GenerateMappingCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-b2bi/Interface/GenerateMappingCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-b2bi/Interface/GenerateMappingCommandOutput/)
294+
287295
</details>
288296
<details>
289297
<summary>

clients/client-b2bi/src/B2bi.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ import {
4848
DeleteTransformerCommandInput,
4949
DeleteTransformerCommandOutput,
5050
} from "./commands/DeleteTransformerCommand";
51+
import {
52+
GenerateMappingCommand,
53+
GenerateMappingCommandInput,
54+
GenerateMappingCommandOutput,
55+
} from "./commands/GenerateMappingCommand";
5156
import {
5257
GetCapabilityCommand,
5358
GetCapabilityCommandInput,
@@ -143,6 +148,7 @@ const commands = {
143148
DeletePartnershipCommand,
144149
DeleteProfileCommand,
145150
DeleteTransformerCommand,
151+
GenerateMappingCommand,
146152
GetCapabilityCommand,
147153
GetPartnershipCommand,
148154
GetProfileCommand,
@@ -307,6 +313,20 @@ export interface B2bi {
307313
cb: (err: any, data?: DeleteTransformerCommandOutput) => void
308314
): void;
309315

316+
/**
317+
* @see {@link GenerateMappingCommand}
318+
*/
319+
generateMapping(
320+
args: GenerateMappingCommandInput,
321+
options?: __HttpHandlerOptions
322+
): Promise<GenerateMappingCommandOutput>;
323+
generateMapping(args: GenerateMappingCommandInput, cb: (err: any, data?: GenerateMappingCommandOutput) => void): void;
324+
generateMapping(
325+
args: GenerateMappingCommandInput,
326+
options: __HttpHandlerOptions,
327+
cb: (err: any, data?: GenerateMappingCommandOutput) => void
328+
): void;
329+
310330
/**
311331
* @see {@link GetCapabilityCommand}
312332
*/

clients/client-b2bi/src/B2biClient.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import { DeleteCapabilityCommandInput, DeleteCapabilityCommandOutput } from "./c
6565
import { DeletePartnershipCommandInput, DeletePartnershipCommandOutput } from "./commands/DeletePartnershipCommand";
6666
import { DeleteProfileCommandInput, DeleteProfileCommandOutput } from "./commands/DeleteProfileCommand";
6767
import { DeleteTransformerCommandInput, DeleteTransformerCommandOutput } from "./commands/DeleteTransformerCommand";
68+
import { GenerateMappingCommandInput, GenerateMappingCommandOutput } from "./commands/GenerateMappingCommand";
6869
import { GetCapabilityCommandInput, GetCapabilityCommandOutput } from "./commands/GetCapabilityCommand";
6970
import { GetPartnershipCommandInput, GetPartnershipCommandOutput } from "./commands/GetPartnershipCommand";
7071
import { GetProfileCommandInput, GetProfileCommandOutput } from "./commands/GetProfileCommand";
@@ -115,6 +116,7 @@ export type ServiceInputTypes =
115116
| DeletePartnershipCommandInput
116117
| DeleteProfileCommandInput
117118
| DeleteTransformerCommandInput
119+
| GenerateMappingCommandInput
118120
| GetCapabilityCommandInput
119121
| GetPartnershipCommandInput
120122
| GetProfileCommandInput
@@ -149,6 +151,7 @@ export type ServiceOutputTypes =
149151
| DeletePartnershipCommandOutput
150152
| DeleteProfileCommandOutput
151153
| DeleteTransformerCommandOutput
154+
| GenerateMappingCommandOutput
152155
| GetCapabilityCommandOutput
153156
| GetPartnershipCommandOutput
154157
| GetProfileCommandOutput
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
// smithy-typescript generated code
2+
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
3+
import { getSerdePlugin } from "@smithy/middleware-serde";
4+
import { Command as $Command } from "@smithy/smithy-client";
5+
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
6+
7+
import { B2biClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../B2biClient";
8+
import { commonParams } from "../endpoint/EndpointParameters";
9+
import { GenerateMappingRequest, GenerateMappingResponse } from "../models/models_0";
10+
import { de_GenerateMappingCommand, se_GenerateMappingCommand } from "../protocols/Aws_json1_0";
11+
12+
/**
13+
* @public
14+
*/
15+
export type { __MetadataBearer };
16+
export { $Command };
17+
/**
18+
* @public
19+
*
20+
* The input for {@link GenerateMappingCommand}.
21+
*/
22+
export interface GenerateMappingCommandInput extends GenerateMappingRequest {}
23+
/**
24+
* @public
25+
*
26+
* The output of {@link GenerateMappingCommand}.
27+
*/
28+
export interface GenerateMappingCommandOutput extends GenerateMappingResponse, __MetadataBearer {}
29+
30+
/**
31+
* <p>Takes sample input and output documents and uses Amazon Bedrock to generate a mapping automatically. Depending on the accuracy and other factors, you can then edit the mapping for your needs.</p>
32+
* <note>
33+
* <p>Before you can use the AI-assisted feature for Amazon Web Services B2B Data Interchange you must enable models in Amazon Bedrock. For details, see <a href="https://docs.aws.amazon.com/b2bi/latest/userguide/ai-assisted-mapping.html#ai-assist-prereq">AI-assisted template mapping prerequisites</a> in
34+
* the <i>Amazon Web Services B2B Data Interchange User guide</i>.</p>
35+
* </note>
36+
* @example
37+
* Use a bare-bones client and the command you need to make an API call.
38+
* ```javascript
39+
* import { B2biClient, GenerateMappingCommand } from "@aws-sdk/client-b2bi"; // ES Modules import
40+
* // const { B2biClient, GenerateMappingCommand } = require("@aws-sdk/client-b2bi"); // CommonJS import
41+
* const client = new B2biClient(config);
42+
* const input = { // GenerateMappingRequest
43+
* inputFileContent: "STRING_VALUE", // required
44+
* outputFileContent: "STRING_VALUE", // required
45+
* mappingType: "JSONATA" || "XSLT", // required
46+
* };
47+
* const command = new GenerateMappingCommand(input);
48+
* const response = await client.send(command);
49+
* // { // GenerateMappingResponse
50+
* // mappingTemplate: "STRING_VALUE", // required
51+
* // mappingAccuracy: Number("float"),
52+
* // };
53+
*
54+
* ```
55+
*
56+
* @param GenerateMappingCommandInput - {@link GenerateMappingCommandInput}
57+
* @returns {@link GenerateMappingCommandOutput}
58+
* @see {@link GenerateMappingCommandInput} for command's `input` shape.
59+
* @see {@link GenerateMappingCommandOutput} for command's `response` shape.
60+
* @see {@link B2biClientResolvedConfig | config} for B2biClient's `config` shape.
61+
*
62+
* @throws {@link AccessDeniedException} (client fault)
63+
* <p>You do not have sufficient access to perform this action.</p>
64+
*
65+
* @throws {@link InternalServerException} (server fault)
66+
* <p>This exception is thrown when an error occurs in the Amazon Web Services B2B Data Interchange service.</p>
67+
*
68+
* @throws {@link ThrottlingException} (client fault)
69+
* <p>The request was denied due to throttling: the data speed and rendering may be limited depending on various parameters and conditions.</p>
70+
*
71+
* @throws {@link ValidationException} (client fault)
72+
* <p>Occurs when a B2BI object cannot be validated against a request from another object.</p>
73+
*
74+
* @throws {@link B2biServiceException}
75+
* <p>Base exception class for all service exceptions from B2bi service.</p>
76+
*
77+
* @public
78+
* @example Sample GenerateMapping call
79+
* ```javascript
80+
* //
81+
* const input = {
82+
* "inputFileContent": "Sample input file content",
83+
* "mappingType": "JSONATA",
84+
* "outputFileContent": "Sample output file content"
85+
* };
86+
* const command = new GenerateMappingCommand(input);
87+
* const response = await client.send(command);
88+
* /* response ==
89+
* {
90+
* "mappingAccuracy": 0.95,
91+
* "mappingTemplate": "Sample mapping content"
92+
* }
93+
* *\/
94+
* // example id: example-1
95+
* ```
96+
*
97+
*/
98+
export class GenerateMappingCommand extends $Command
99+
.classBuilder<
100+
GenerateMappingCommandInput,
101+
GenerateMappingCommandOutput,
102+
B2biClientResolvedConfig,
103+
ServiceInputTypes,
104+
ServiceOutputTypes
105+
>()
106+
.ep(commonParams)
107+
.m(function (this: any, Command: any, cs: any, config: B2biClientResolvedConfig, o: any) {
108+
return [
109+
getSerdePlugin(config, this.serialize, this.deserialize),
110+
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
111+
];
112+
})
113+
.s("B2BI", "GenerateMapping", {})
114+
.n("B2biClient", "GenerateMappingCommand")
115+
.f(void 0, void 0)
116+
.ser(se_GenerateMappingCommand)
117+
.de(de_GenerateMappingCommand)
118+
.build() {
119+
/** @internal type navigation helper, not in runtime. */
120+
protected declare static __types: {
121+
api: {
122+
input: GenerateMappingRequest;
123+
output: GenerateMappingResponse;
124+
};
125+
sdk: {
126+
input: GenerateMappingCommandInput;
127+
output: GenerateMappingCommandOutput;
128+
};
129+
};
130+
}

clients/client-b2bi/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export * from "./DeleteCapabilityCommand";
88
export * from "./DeletePartnershipCommand";
99
export * from "./DeleteProfileCommand";
1010
export * from "./DeleteTransformerCommand";
11+
export * from "./GenerateMappingCommand";
1112
export * from "./GetCapabilityCommand";
1213
export * from "./GetPartnershipCommand";
1314
export * from "./GetProfileCommand";

clients/client-b2bi/src/models/models_0.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,47 @@ export interface CreateStarterMappingTemplateResponse {
902902
mappingTemplate: string | undefined;
903903
}
904904

905+
/**
906+
* @public
907+
*/
908+
export interface GenerateMappingRequest {
909+
/**
910+
* <p>Provide the contents of a sample X12 EDI file (for inbound EDI) or JSON/XML file (for outbound EDI) to use as a starting point for the mapping.</p>
911+
* @public
912+
*/
913+
inputFileContent: string | undefined;
914+
915+
/**
916+
* <p>Provide the contents of a sample X12 EDI file (for outbound EDI) or JSON/XML file (for inbound EDI) to use as a target for the mapping.</p>
917+
* @public
918+
*/
919+
outputFileContent: string | undefined;
920+
921+
/**
922+
* <p>Specify the mapping type: either <code>JSONATA</code> or <code>XSLT.</code>
923+
* </p>
924+
* @public
925+
*/
926+
mappingType: MappingType | undefined;
927+
}
928+
929+
/**
930+
* @public
931+
*/
932+
export interface GenerateMappingResponse {
933+
/**
934+
* <p>Returns a mapping template based on your inputs.</p>
935+
* @public
936+
*/
937+
mappingTemplate: string | undefined;
938+
939+
/**
940+
* <p>Returns a percentage that estimates the accuracy of the generated mapping.</p>
941+
* @public
942+
*/
943+
mappingAccuracy?: number | undefined;
944+
}
945+
905946
/**
906947
* @public
907948
*/
@@ -3006,7 +3047,7 @@ export interface UpdateTransformerRequest {
30063047
name?: string | undefined;
30073048

30083049
/**
3009-
* <p>Specifies the transformer's status. You can update the state of the transformer, from <code>active</code> to <code>inactive</code>, or <code>inactive</code> to <code>active</code>.</p>
3050+
* <p>Specifies the transformer's status. You can update the state of the transformer from <code>inactive</code> to <code>active</code>.</p>
30103051
* @public
30113052
*/
30123053
status?: TransformerStatus | undefined;

clients/client-b2bi/src/protocols/Aws_json1_0.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
decorateServiceException as __decorateServiceException,
1313
expectNonNull as __expectNonNull,
1414
expectString as __expectString,
15+
limitedParseFloat32 as __limitedParseFloat32,
1516
parseRfc3339DateTimeWithOffset as __parseRfc3339DateTimeWithOffset,
1617
take,
1718
withBaseException,
@@ -36,6 +37,7 @@ import { DeleteCapabilityCommandInput, DeleteCapabilityCommandOutput } from "../
3637
import { DeletePartnershipCommandInput, DeletePartnershipCommandOutput } from "../commands/DeletePartnershipCommand";
3738
import { DeleteProfileCommandInput, DeleteProfileCommandOutput } from "../commands/DeleteProfileCommand";
3839
import { DeleteTransformerCommandInput, DeleteTransformerCommandOutput } from "../commands/DeleteTransformerCommand";
40+
import { GenerateMappingCommandInput, GenerateMappingCommandOutput } from "../commands/GenerateMappingCommand";
3941
import { GetCapabilityCommandInput, GetCapabilityCommandOutput } from "../commands/GetCapabilityCommand";
4042
import { GetPartnershipCommandInput, GetPartnershipCommandOutput } from "../commands/GetPartnershipCommand";
4143
import { GetProfileCommandInput, GetProfileCommandOutput } from "../commands/GetProfileCommand";
@@ -88,6 +90,8 @@ import {
8890
EdiConfiguration,
8991
EdiType,
9092
FormatOptions,
93+
GenerateMappingRequest,
94+
GenerateMappingResponse,
9195
GetCapabilityRequest,
9296
GetCapabilityResponse,
9397
GetPartnershipRequest,
@@ -264,6 +268,19 @@ export const se_DeleteTransformerCommand = async (
264268
return buildHttpRpcRequest(context, headers, "/", undefined, body);
265269
};
266270

271+
/**
272+
* serializeAws_json1_0GenerateMappingCommand
273+
*/
274+
export const se_GenerateMappingCommand = async (
275+
input: GenerateMappingCommandInput,
276+
context: __SerdeContext
277+
): Promise<__HttpRequest> => {
278+
const headers: __HeaderBag = sharedHeaders("GenerateMapping");
279+
let body: any;
280+
body = JSON.stringify(_json(input));
281+
return buildHttpRpcRequest(context, headers, "/", undefined, body);
282+
};
283+
267284
/**
268285
* serializeAws_json1_0GetCapabilityCommand
269286
*/
@@ -692,6 +709,26 @@ export const de_DeleteTransformerCommand = async (
692709
return response;
693710
};
694711

712+
/**
713+
* deserializeAws_json1_0GenerateMappingCommand
714+
*/
715+
export const de_GenerateMappingCommand = async (
716+
output: __HttpResponse,
717+
context: __SerdeContext
718+
): Promise<GenerateMappingCommandOutput> => {
719+
if (output.statusCode >= 300) {
720+
return de_CommandError(output, context);
721+
}
722+
const data: any = await parseBody(output.body, context);
723+
let contents: any = {};
724+
contents = de_GenerateMappingResponse(data, context);
725+
const response: GenerateMappingCommandOutput = {
726+
$metadata: deserializeMetadata(output),
727+
...contents,
728+
};
729+
return response;
730+
};
731+
695732
/**
696733
* deserializeAws_json1_0GetCapabilityCommand
697734
*/
@@ -1320,6 +1357,8 @@ const se_CreateTransformerRequest = (input: CreateTransformerRequest, context: _
13201357

13211358
// se_FormatOptions omitted.
13221359

1360+
// se_GenerateMappingRequest omitted.
1361+
13231362
// se_GetCapabilityRequest omitted.
13241363

13251364
// se_GetPartnershipRequest omitted.
@@ -1526,6 +1565,16 @@ const de_CreateTransformerResponse = (output: any, context: __SerdeContext): Cre
15261565

15271566
// de_FormatOptions omitted.
15281567

1568+
/**
1569+
* deserializeAws_json1_0GenerateMappingResponse
1570+
*/
1571+
const de_GenerateMappingResponse = (output: any, context: __SerdeContext): GenerateMappingResponse => {
1572+
return take(output, {
1573+
mappingAccuracy: __limitedParseFloat32,
1574+
mappingTemplate: __expectString,
1575+
}) as any;
1576+
};
1577+
15291578
/**
15301579
* deserializeAws_json1_0GetCapabilityResponse
15311580
*/

0 commit comments

Comments
 (0)