AWS.B2BI reference
Capability
Section titled “Capability”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.
Capability: Creating a Capability
Section titled “Capability: Creating a Capability”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, }, },});CreateStarterMappingTemplate
Section titled “CreateStarterMappingTemplate”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 argumentconst createStarterMappingTemplate = yield* AWS.B2BI.CreateStarterMappingTemplate();
// runtimeconst result = yield* createStarterMappingTemplate({ mappingType: "JSONATA", templateDetails: { x12: { transactionSet: "X12_850", version: "VERSION_4010" }, },});// result.mappingTemplate — the generated starter templateGenerateMapping
Section titled “GenerateMapping”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).
GenerateMapping: Generating Mappings
Section titled “GenerateMapping: Generating Mappings”// init — account-level, no resource argumentconst generateMapping = yield* AWS.B2BI.GenerateMapping();
// runtimeconst result = yield* generateMapping({ inputFileContent: JSON.stringify({ customer: "acme" }), outputFileContent: JSON.stringify({ name: "acme" }), mappingType: "JSONATA",});// result.mappingTemplate, result.mappingAccuracyGetTransformerJob
Section titled “GetTransformerJob”Source:
src/AWS/B2BI/GetTransformerJob.ts
Runtime binding for b2bi:GetTransformerJob.
Polls the status of an asynchronous transformer job started with
StartTransformerJob — status 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 transformerconst getTransformerJob = yield* AWS.B2BI.GetTransformerJob(transformer);
// runtimeconst job = yield* getTransformerJob({ transformerJobId }).pipe( Effect.repeat({ schedule: Schedule.spaced("2 seconds"), until: (job) => job.status !== "running", times: 30, }),);Partnership
Section titled “Partnership”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.
Partnership: Creating a Partnership
Section titled “Partnership: Creating a Partnership”const partnership = yield* B2BI.Partnership("AcmeToPartner", { profileId: profile.profileId, name: "acme-partner", email: "edi@partner.example", capabilities: [capability.capabilityId],});Profile
Section titled “Profile”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.
Profile: Creating a Profile
Section titled “Profile: Creating a Profile”const profile = yield* B2BI.Profile("Acme", { name: "Acme Trading", businessName: "Acme Corp", phone: "+15555550100", email: "edi@acme.example",});Profile: Disabling CloudWatch Logging
Section titled “Profile: Disabling CloudWatch Logging”const profile = yield* B2BI.Profile("Acme", { name: "Acme Trading", businessName: "Acme Corp", phone: "+15555550100", logging: "DISABLED",});StartTransformerJob
Section titled “StartTransformerJob”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 transformerconst startTransformerJob = yield* AWS.B2BI.StartTransformerJob(transformer);
// runtimeconst { transformerJobId } = yield* startTransformerJob({ inputFile: { bucketName: "my-edi-bucket", key: "inbound/order.edi" }, outputLocation: { bucketName: "my-edi-bucket", key: "output/" },});TestConversion
Section titled “TestConversion”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 argumentconst testConversion = yield* AWS.B2BI.TestConversion();
// runtimeconst result = yield* testConversion({ source: { fileFormat: "JSON", inputFile: { fileContent } }, target: { fileFormat: "X12", formatDetails: { x12: { transactionSet: "X12_850", version: "VERSION_4010" }, }, },});// result.convertedFileContent — the generated X12 documentTestMapping
Section titled “TestMapping”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).
TestMapping: Testing Mappings
Section titled “TestMapping: Testing Mappings”// init — account-level, no resource argumentconst testMapping = yield* AWS.B2BI.TestMapping();
// runtimeconst result = yield* testMapping({ inputFileContent: JSON.stringify({ customer: "acme" }), mappingTemplate: '{ "name": customer }', fileFormat: "JSON",});// result.mappedFileContent === '{"name":"acme"}'TestParsing
Section titled “TestParsing”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).
TestParsing: Parsing EDI Documents
Section titled “TestParsing: Parsing EDI Documents”// init — account-level, no resource argumentconst testParsing = yield* AWS.B2BI.TestParsing();
// runtimeconst 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 fileTransformer
Section titled “Transformer”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.
Transformer: Creating a Transformer
Section titled “Transformer: Creating a Transformer”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 }", },});