Skip to content

AWS.B2BI reference

Source: src/AWS/B2BI/Capability.ts

An AWS B2B Data Interchange (B2BI) capability. A capability contains the information required to transform incoming or outgoing EDI documents: the X12 transaction set, a transformer, and the S3 input/output locations.

const capability = yield* B2BI.Capability("Orders", {
name: "inbound-orders",
configuration: {
edi: {
capabilityDirection: "INBOUND",
type: { x12Details: { transactionSet: "X12_850", version: "VERSION_4010" } },
inputLocation: { bucketName: bucket.bucketName, key: "inbound/" },
outputLocation: { bucketName: bucket.bucketName, key: "processed/" },
transformerId: transformer.transformerId,
},
},
});

Source: src/AWS/B2BI/CreateStarterMappingTemplate.ts

Runtime binding for b2bi:CreateStarterMappingTemplate.

Generates a starter mapping template (JSONATA or XSLT) for a given X12 transaction set — a scaffold covering every field of the transaction that can be edited down to the desired mapping. Optionally writes the template to S3 via outputSampleLocation. Provide the implementation with Effect.provide(AWS.B2BI.CreateStarterMappingTemplateHttp).

CreateStarterMappingTemplate: Generating Mappings

Section titled “CreateStarterMappingTemplate: Generating Mappings”
// init — account-level, no resource argument
const createStarterMappingTemplate =
yield* AWS.B2BI.CreateStarterMappingTemplate();
// runtime
const result = yield* createStarterMappingTemplate({
mappingType: "JSONATA",
templateDetails: {
x12: { transactionSet: "X12_850", version: "VERSION_4010" },
},
});
// result.mappingTemplate — the generated starter template

Source: src/AWS/B2BI/GenerateMapping.ts

Runtime binding for b2bi:GenerateMapping.

Generates a mapping template (JSONATA or XSLT) from a sample input and desired output document using AI-assisted mapping — useful for building self-service EDI onboarding flows where trading partners supply sample documents. mappingAccuracy reports the model’s confidence. Provide the implementation with Effect.provide(AWS.B2BI.GenerateMappingHttp).

// init — account-level, no resource argument
const generateMapping = yield* AWS.B2BI.GenerateMapping();
// runtime
const result = yield* generateMapping({
inputFileContent: JSON.stringify({ customer: "acme" }),
outputFileContent: JSON.stringify({ name: "acme" }),
mappingType: "JSONATA",
});
// result.mappingTemplate, result.mappingAccuracy

Source: src/AWS/B2BI/GetTransformerJob.ts

Runtime binding for b2bi:GetTransformerJob.

Polls the status of an asynchronous transformer job started with StartTransformerJobstatus progresses from running to succeeded (with outputFiles) or failed (with message). Provide the implementation with Effect.provide(AWS.B2BI.GetTransformerJobHttp).

GetTransformerJob: Running Transformer Jobs

Section titled “GetTransformerJob: Running Transformer Jobs”
// init — grants b2bi:GetTransformerJob on the transformer
const getTransformerJob = yield* AWS.B2BI.GetTransformerJob(transformer);
// runtime
const job = yield* getTransformerJob({ transformerJobId }).pipe(
Effect.repeat({
schedule: Schedule.spaced("2 seconds"),
until: (job) => job.status !== "running",
times: 30,
}),
);

Source: src/AWS/B2BI/Partnership.ts

An AWS B2B Data Interchange (B2BI) partnership. A partnership connects a customer Profile to a trading partner and enables a set of capabilities for exchanging EDI documents.

const partnership = yield* B2BI.Partnership("AcmeToPartner", {
profileId: profile.profileId,
name: "acme-partner",
email: "edi@partner.example",
capabilities: [capability.capabilityId],
});

Source: src/AWS/B2BI/Profile.ts

An AWS B2B Data Interchange (B2BI) customer profile. A profile is the mechanism used to model a distinct private network; you can have up to five profiles per account. Profiles are credential-free and fully self-service, so their lifecycle is directly testable.

const profile = yield* B2BI.Profile("Acme", {
name: "Acme Trading",
businessName: "Acme Corp",
phone: "+15555550100",
email: "edi@acme.example",
});
const profile = yield* B2BI.Profile("Acme", {
name: "Acme Trading",
businessName: "Acme Corp",
phone: "+15555550100",
logging: "DISABLED",
});

Source: src/AWS/B2BI/StartTransformerJob.ts

Runtime binding for b2bi:StartTransformerJob.

Runs an asynchronous transformer job against an EDI document in S3 — the bound Transformer (which must be active) parses and maps the inputFile and writes the result to outputLocation. Poll the returned transformerJobId with GetTransformerJob. B2BI accesses the S3 locations with its service principal, so the buckets need a bucket policy granting b2bi.amazonaws.com read/write access. Provide the implementation with Effect.provide(AWS.B2BI.StartTransformerJobHttp).

StartTransformerJob: Running Transformer Jobs

Section titled “StartTransformerJob: Running Transformer Jobs”
// init — grants b2bi:StartTransformerJob on the transformer
const startTransformerJob = yield* AWS.B2BI.StartTransformerJob(transformer);
// runtime
const { transformerJobId } = yield* startTransformerJob({
inputFile: { bucketName: "my-edi-bucket", key: "inbound/order.edi" },
outputLocation: { bucketName: "my-edi-bucket", key: "output/" },
});

Source: src/AWS/B2BI/TestConversion.ts

Runtime binding for b2bi:TestConversion.

Synchronously converts an inline JSON or XML document into an outbound X12 EDI document — the inline counterpart of an outbound transformer’s conversion step. Provide the implementation with Effect.provide(AWS.B2BI.TestConversionHttp).

TestConversion: Converting Documents to EDI

Section titled “TestConversion: Converting Documents to EDI”
// init — account-level, no resource argument
const testConversion = yield* AWS.B2BI.TestConversion();
// runtime
const result = yield* testConversion({
source: { fileFormat: "JSON", inputFile: { fileContent } },
target: {
fileFormat: "X12",
formatDetails: {
x12: { transactionSet: "X12_850", version: "VERSION_4010" },
},
},
});
// result.convertedFileContent — the generated X12 document

Source: src/AWS/B2BI/TestMapping.ts

Runtime binding for b2bi:TestMapping.

Synchronously maps sample content with a mapping template (JSONATA or XSLT) — the inline counterpart of a transformer’s mapping step, useful for validating templates or transforming small documents on the fly without a deployed transformer. Provide the implementation with Effect.provide(AWS.B2BI.TestMappingHttp).

// init — account-level, no resource argument
const testMapping = yield* AWS.B2BI.TestMapping();
// runtime
const result = yield* testMapping({
inputFileContent: JSON.stringify({ customer: "acme" }),
mappingTemplate: '{ "name": customer }',
fileFormat: "JSON",
});
// result.mappedFileContent === '{"name":"acme"}'

Source: src/AWS/B2BI/TestParsing.ts

Runtime binding for b2bi:TestParsing.

Synchronously parses an EDI document in S3 (e.g. an X12 file) into the JSON or XML representation B2BI’s mapping step consumes. B2BI reads the inputFile with its service principal, so the bucket needs a bucket policy granting b2bi.amazonaws.com read access. Provide the implementation with Effect.provide(AWS.B2BI.TestParsingHttp).

// init — account-level, no resource argument
const testParsing = yield* AWS.B2BI.TestParsing();
// runtime
const result = yield* testParsing({
inputFile: { bucketName: "my-edi-bucket", key: "inbound/order.edi" },
fileFormat: "JSON",
ediType: {
x12Details: { transactionSet: "X12_850", version: "VERSION_4010" },
},
});
// result.parsedFileContent — the JSON representation of the EDI file

Source: src/AWS/B2BI/Transformer.ts

An AWS B2B Data Interchange (B2BI) transformer. A transformer describes how to convert inbound EDI documents to a target format (or the reverse) using a mapping template. Transformers are credential-free and testable.

Activation is one-way: B2BI rejects every update to an active transformer, including a status-only deactivation, so changing the configuration, name, or status of an active transformer replaces it (delete-first). Deletion works regardless of status.

const transformer = yield* B2BI.Transformer("X12ToJson", {
name: "x12-to-json",
status: "active",
inputConversion: {
fromFormat: "X12",
formatOptions: { x12: { transactionSet: "X12_850", version: "VERSION_4010" } },
},
mapping: {
templateLanguage: "JSONATA",
template: "{ \"orderId\": transactionSets[0].St.transactionSetControlNumber }",
},
});