Repository navigation
Update FTP and EDI samples for the latest connector APIs - #62
Closed
niveathika wants to merge 4 commits into
Closed
niveathika wants to merge 4 commits into
niveathika wants to merge 4 commits into
Conversation
The ftp-edi-message-to-salesforce-opportunity sample no longer compiled.
EDIFACT D03A renamed its generated types (EDI_REQOTE_REQOTE,
Group_N_GType, lowercase group_N fields) and made several segment fields
optional and nilable, so the whole REQOTE transformation was dead code.
Take the FTP additions while here: getText() replaces the hand-rolled
byte-stream-to-string helper, and move() finally uses ftpProcessedQuotesPath,
which was configurable but unused despite the README promising the files
get moved.
Also fix breakage that predates these library changes:
- transformQuoteRequest was duplicated in main.bal and transformer.bal,
a redeclared symbol since e9a6b73
- sf:ConnectionConfig is no longer a subtype of anydata, so it cannot be
a configurable; split into salesforceBaseUrl and salesforceAuth
- a hardcoded pricebook ID shadowed the salesforcePriceBookId
configurable in the PricebookEntry query and on Opportunity
- .devcontainer.json had a trailing comma
Bump distribution to 2201.13.4 across all three samples. The EDI codegen
and libgen samples themselves needed no code changes; both were verified
against edi tool 2.2.1.
Anything dropped into the new-quotes folder was fed to the EDI parser. The published snippet on ballerina.io already guards this; the sample did not.
build-edi has been failing on main at the first build step: `bal build ./edi-code-generation/edi.bal` points at a file inside a package, which the compiler now rejects with "invalid source provided". Build the package instead. Everything after that step had been skipped, so libgen, pack, push, and the edi_service build had not run in a long time; all four pass once the first step is unblocked. ftp-edi-message-to-salesforce-opportunity was commented out of the build-packages matrix, which is how it stayed broken since e9a6b73. It compiles again, so put it back. Also stop the matrix from cancelling itself. gdrive-files-to-microsoft- onedrive-files fails against microsoft.onedrive 3.0.2 (DriveItemData and uploadFileToFolderByPath are gone), and fail-fast turned that one genuine failure into ~30 cancelled jobs, hiding the real status of every other sample. That sample still needs its own fix.
working_with_json and kafka_salesforce_integration hold sub-projects rather than being packages themselves, so `bal build` on them fails with "invalid source provided" — the same mistake as the edi-code-generation step, not a problem with the samples. All three sub-packages build clean.
Author
|
Closing this as we need full overhaul of examples |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
The
ftp-edi-message-to-salesforce-opportunitysample does not compile against current libraries. Two things happened since it was last touched:ballerinax/edifact.d03a.retail1.0.1 renamed the record types and fields the sample's transformer is built on, and made several segment fields both optional and nilable.ballerina/ftpgrew convenience APIs (getText,move,getBytes,getJson, …) that make part of the sample's hand-rolled plumbing unnecessary.While fixing those, three older breakages surfaced that also block compilation — see Approach.
The two EDI samples (
edi-code-generation,edi-package-generation) needed no code changes; only their staledistributionvalues.Goals
Get all three samples compiling and running against the current distribution, without restructuring them.
Approach
EDIFACT type renames in
transformer.bal:EDI_REQOTE_Request_for_quote_messageEDI_REQOTE_REQOTESegment_group_N_GTypeGroup_N_GTypequote.Segment_group_1quote.group_1ref.REFERENCE.REFERENCEref.Reference?.REFERENCEparty.NAME_AND_ADDRESS.Party_function_code_qualifierparty.Name_and_address?.PARTY_FUNCTION_CODE_QUALIFIERitem.LINE_ITEM.Line_item_identifieritem.Line_item?.LINE_ITEM_IDENTIFIERitem.QUANTITY/QUANTITY_Typeitem.Quantity/Quantity_TypeBecause those fields are now optional and nilable, the nested
ifguards became early-continuechecks.FTP API adoption:
getText()replacesget()plus a localstreamToString()byte accumulator (helper and theballerina/ioimport deleted).move()moves each processed file toftpProcessedQuotesPath. That configurable was declared but never used, even though the README's Testing step 4 already told users to expect it.Pre-existing breakage fixed:
transformQuoteRequestwas duplicated verbatim inmain.balandtransformer.bal— aredeclared symbolerror since e9a6b73 (Jan 2024). Kept thetransformer.balcopy.configurable sf:ConnectionConfignow fails withinvalid type for configurable variable: expected a subtype of 'anydata', sinceConnectionConfigincludes*http:ClientConfiguration. Split intosalesforceBaseUrlandhttp:OAuth2RefreshTokenGrantConfig salesforceAuth; the README'sConfig.tomlblock is updated to match.01s6C000000UN4PQAW) shadowed thesalesforcePriceBookIdconfigurable in thePricebookEntryquery and as the default onOpportunity.Pricebook2Id. Both now use the configurable..devcontainer.jsonhad a trailing comma, making it invalid JSON.Aligned with the published snippet: the code sample on ballerina.io skips files that
do not end in
.edi, but the sample here fed everything in the new-quotes directorystraight to the EDI parser. Added the same guard.
distributionbumped to2201.13.4across all three samples, matching the newest samples in this repo.CI
build-ediwas already failing onmainat its first build step, so everything after ithad been skipped for a long time:
edi.balis generated into a directory that has aBallerina.toml, so it is not astandalone file. Building the package instead fixes it, and the four steps that had been
skipped (libgen, pack, push,
edi_servicebuild) all pass once unblocked.ftp-edi-message-to-salesforce-opportunitywas commented out of thebuild-packagesmatrix, which is precisely why it stayed uncompilable since e9a6b73 without anyone
noticing. It is back in the matrix.
working_with_jsonandkafka_salesforce_integrationhit the same "invalid sourceprovided" error for the same reason — they are container directories, not packages. The
matrix now points at
working_with_json/ballerina,kafka_salesforce_integration/kafka-message-producer, andkafka_salesforce_integration/kafka-salesforce-pricebook_update, all of which build clean.Finally,
fail-fast: falseon the matrix. One genuine failure(
gdrive-files-to-microsoft-onedrive-files) was cancelling ~30 sibling jobs, so the runreported a wall of red that said nothing about the samples it claimed to be testing.
Failures left on main, untouched by this PR
These are pre-existing and out of scope here; each needs its own connector migration:
gdrive-files-to-microsoft-onedrive-filesDriveItemData/uploadFileToFolderByPathremoved inmicrosoft.onedrive3.0.2gcalendar-new-event-to-trello-cardCards/addCardsremoved intrello2.0.1gcalendar-new-event-to-trello-card-and-twillio-msgtwilio5.0.2 replacedtwilioAuthwith a requiredauthhubspot-contacts-to-google-contactsballerinax/hubspot.crm.contactno longer resolvessalesforce-new-contact-to-twilio-smsballerinax/trigger.salesforceno longer resolvesgmail-to-salesforce-leadsalesforce7.6.0NO_CLASS_DEF_FOUND io/ballerina/runtime/api/async/Callbackshopify-customer-to-salesforce-customerconfigurable sf:ConnectionConfig— sameanydatabreakage fixed hereservicenow-case-to-salesforce-caseThe last two would be fixed by the same split this PR applies to
main.bal, if amaintainer wants them folded in.
User stories
As a user following the pre-built integration guides, I can run the FTP/EDI/Salesforce and EDI codegen samples against a current Ballerina distribution.
Release note
Fixed the FTP EDI to Salesforce opportunity sample, which no longer compiled after the EDIFACT D03A type renames and the
sf:ConnectionConfiganydata change, and updated it to use the newerftp:ClientgetTextandmoveAPIs. The sample now also skips non-EDI files in the input directory.Documentation
The generated-code snippets on the EDI pages under https://ballerina.io/learn/pre-built-integrations/ may need a follow-up:
bal edi codegennow additionally emitsgetSchema(),fromEdiStringWithSchema(), andtoEdiStringWithSchema(), andbal edi libgennow also emitsrest_connector.bal,transformer.bal, andModule.md. No changes to the sample code are implied.Training
N/A
Certification
N/A — sample maintenance, no impact on certification exams.
Marketing
N/A
Automation tests
Unit tests
N/A — these samples have no test suite.
Integration tests
Verified manually:
edi-code-generation: ranbal edi codegen -i schemas/edi-schema.json -o edi.bal, thenbal run -- read(printsOrder date: 2008-01-01) andbal run -- write(round-trips to the expectedHDR*…~ ITM*…~output).edi-package-generation: ranbal edi libgen -p citymart/porder -i schemas -o ., packed and pushed to the local repository, and builtedi_serviceagainst it.ftp-edi-message-to-salesforce-opportunity:bal buildclean,bal format --dry-runclean. Parsedresources/inputs/quote1.edithrough the updatedtransformQuoteRequestand confirmed it yields{"oppName":"TS_035","accountName":"TechShop","itemData":[{"itemId":"…","quantity":10}]}.Not verified end to end: the
list/getText/movecalls against a live FTP server, and the Salesforce calls. Docker was unavailable in my environment and I have no Salesforce org to point at, so the FTP and Salesforce paths are checked by signature and compilation only. Worth a run by someone with both available before merge.Security checks
Samples
This PR is entirely sample maintenance; see Approach.
Related PRs
None.
Migrations (if applicable)
N/A
Test environment
Ballerina 2201.13.3 (Swan Lake Update 13),
bal editool 2.2.1, on Linux (WSL2). Dependencies resolved:ballerina/ftp2.20.2,ballerina/edi1.6.0,ballerinax/edifact.d03a.retail1.0.1,ballerinax/salesforce8.7.0.Learning
The EDIFACT rename is not documented as a breaking change anywhere I could find; I recovered the new names by reading the type definitions in the cached
edifact.d03a.retail1.0.1 bala directly.