diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 4722c7fa9..2989da549 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -25,11 +25,12 @@ sources: - 3.0.0 sync-for-commerce-source: sourceNamespace: sync-for-commerce-source - sourceRevisionDigest: sha256:b84dfd0a144f6e1f6820d89002c47ef49c1577847dbf847b8084e2878f0d665d - sourceBlobDigest: sha256:8d28ab5948234762183d92571ebbc3c5680bbbb4bd74052fad1164eed6d68d14 + sourceRevisionDigest: sha256:257187806b1394379f3dbbd53cc8a8b7397356ff8b0ee243e3d6958a48cd91f3 + sourceBlobDigest: sha256:1d1592cd53dae647bff1e58e43cb64f19f9da714cfc6f6198c43659b89b05369 tags: - latest - - main + - speakeasy-sdk-regen-1732635162 + - "1.1" sync-for-expenses-source: sourceNamespace: sync-for-expenses-source sourceRevisionDigest: sha256:71608ee6d0767a972fa4d4141d8238df3b9233a528d8de80cc0a85a9a7e560b8 @@ -83,8 +84,10 @@ targets: sync-for-commerce-library: source: sync-for-commerce-source sourceNamespace: sync-for-commerce-source - sourceRevisionDigest: sha256:b84dfd0a144f6e1f6820d89002c47ef49c1577847dbf847b8084e2878f0d665d - sourceBlobDigest: sha256:8d28ab5948234762183d92571ebbc3c5680bbbb4bd74052fad1164eed6d68d14 + sourceRevisionDigest: sha256:257187806b1394379f3dbbd53cc8a8b7397356ff8b0ee243e3d6958a48cd91f3 + sourceBlobDigest: sha256:1d1592cd53dae647bff1e58e43cb64f19f9da714cfc6f6198c43659b89b05369 + codeSamplesNamespace: sync-for-commerce-source-code-samples + codeSamplesRevisionDigest: sha256:1021fbad87d5240ea19e961dee7857faf7f2a0154b84ccda1fd6866ac1672261 sync-for-expenses-library: source: sync-for-expenses-source sourceNamespace: sync-for-expenses-source diff --git a/sync-for-commerce/.gitignore b/sync-for-commerce/.gitignore index c9209b37c..d2f200d56 100755 --- a/sync-for-commerce/.gitignore +++ b/sync-for-commerce/.gitignore @@ -1,3 +1,6 @@ +/funcs +/core.* +/__tests__ /hooks /esm /dist diff --git a/sync-for-commerce/.npmignore b/sync-for-commerce/.npmignore index 3ef05d12d..06cd8abf3 100644 --- a/sync-for-commerce/.npmignore +++ b/sync-for-commerce/.npmignore @@ -7,3 +7,4 @@ /cjs /.tshy /.tshy-* +/__tests__ diff --git a/sync-for-commerce/.speakeasy/gen.lock b/sync-for-commerce/.speakeasy/gen.lock index c39f558c1..9f47e59b5 100755 --- a/sync-for-commerce/.speakeasy/gen.lock +++ b/sync-for-commerce/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: c5751d63-9e7b-4fbc-9b31-fa9b6b1310e5 management: - docChecksum: d80797fad92b2756b1ad56399993ad16 + docChecksum: 4dd3691e8d9cbb167c6a1a7bffed41b8 docVersion: "1.1" - speakeasyVersion: 1.338.0 - generationVersion: 2.374.2 - releaseVersion: 4.0.0 - configChecksum: 530f5b0abc005ed259c5916202f2b9ef + speakeasyVersion: 1.446.1 + generationVersion: 2.462.1 + releaseVersion: 5.0.0 + configChecksum: 7cfe39d7c87176e5db713cbfb4776633 repoURL: https://github.com/codatio/client-sdk-typescript.git repoSubDirectory: sync-for-commerce installationURL: https://gitpkg.now.sh/codatio/client-sdk-typescript/sync-for-commerce @@ -14,237 +14,583 @@ management: features: typescript: additionalDependencies: 0.1.0 - constsAndDefaults: 0.1.5 - core: 3.11.7 + constsAndDefaults: 0.1.11 + core: 3.18.7 defaultEnabledRetries: 0.1.0 deprecations: 2.81.1 + enumUnions: 0.1.0 + envVarSecurityUsage: 0.1.2 examples: 2.81.4 - globalSecurity: 2.82.9 + globalSecurity: 2.82.11 globalSecurityCallbacks: 0.1.0 globalSecurityFlattening: 0.1.0 globalServerURLs: 2.82.4 + methodArguments: 0.1.2 nameOverrides: 2.81.2 nullables: 0.1.0 responseFormat: 0.2.3 retries: 2.83.0 - sdkHooks: 0.1.0 + sdkHooks: 0.2.0 serverEventsSentinels: 0.1.0 webhooks: 1.0.0 generatedFiles: - - src/sdk/connections.ts - - src/sdk/advancedcontrols.ts - - src/sdk/integrations.ts - - src/sdk/syncflowsettings.ts - - src/sdk/sync.ts - - src/sdk/sdk.ts - .eslintrc.cjs + - .gitattributes - .npmignore + - CONTRIBUTING.md + - FUNCTIONS.md - RUNTIMES.md + - USAGE.md + - docs/lib/utils/retryconfig.md + - docs/sdk/models/errors/errormessage.md + - docs/sdk/models/operations/createconnectionrequest.md + - docs/sdk/models/operations/createconnectionrequestbody.md + - docs/sdk/models/operations/getconfigtextsyncflowrequest.md + - docs/sdk/models/operations/getconfigurationrequest.md + - docs/sdk/models/operations/getintegrationbrandingrequest.md + - docs/sdk/models/operations/getlastsuccessfulsyncrequest.md + - docs/sdk/models/operations/getlatestsyncrequest.md + - docs/sdk/models/operations/getsyncbyidrequest.md + - docs/sdk/models/operations/getsyncflowurlrequest.md + - docs/sdk/models/operations/getsyncstatusrequest.md + - docs/sdk/models/operations/getvisibleaccountsrequest.md + - docs/sdk/models/operations/listcompaniesrequest.md + - docs/sdk/models/operations/listconnectionsrequest.md + - docs/sdk/models/operations/listintegrationsrequest.md + - docs/sdk/models/operations/listsyncsrequest.md + - docs/sdk/models/operations/requestsyncfordaterangerequest.md + - docs/sdk/models/operations/requestsyncrequest.md + - docs/sdk/models/operations/setconfigurationrequest.md + - docs/sdk/models/operations/updateconfigtextsyncflowrequest.md + - docs/sdk/models/operations/updateconnectionauthorizationrequest.md + - docs/sdk/models/operations/updateconnectionrequest.md + - docs/sdk/models/operations/updatevisibleaccountssyncflowrequest.md + - docs/sdk/models/shared/accountconfiguration.md + - docs/sdk/models/shared/accountconfigurationoption.md + - docs/sdk/models/shared/branding.md + - docs/sdk/models/shared/brandingbutton.md + - docs/sdk/models/shared/brandingimage.md + - docs/sdk/models/shared/brandinglogo.md + - docs/sdk/models/shared/commerceconfiguration.md + - docs/sdk/models/shared/companies.md + - docs/sdk/models/shared/company.md + - docs/sdk/models/shared/companyreference.md + - docs/sdk/models/shared/companyreferencelinks.md + - docs/sdk/models/shared/companysyncstatus.md + - docs/sdk/models/shared/configuration.md + - docs/sdk/models/shared/configurationmapsettings.md + - docs/sdk/models/shared/configurationoption.md + - docs/sdk/models/shared/connection.md + - docs/sdk/models/shared/connections.md + - docs/sdk/models/shared/connectionwebhook.md + - docs/sdk/models/shared/connectionwebhookpayload.md + - docs/sdk/models/shared/createcompany.md + - docs/sdk/models/shared/dataconnectionerror.md + - docs/sdk/models/shared/dataconnectionstatus.md + - docs/sdk/models/shared/datatypefeature.md + - docs/sdk/models/shared/datatypes.md + - docs/sdk/models/shared/daterange.md + - docs/sdk/models/shared/errorstatus.md + - docs/sdk/models/shared/errorvalidation.md + - docs/sdk/models/shared/errorvalidationitem.md + - docs/sdk/models/shared/featurestate.md + - docs/sdk/models/shared/featuretype.md + - docs/sdk/models/shared/feesconfiguration.md + - docs/sdk/models/shared/feessupplier.md + - docs/sdk/models/shared/grouping.md + - docs/sdk/models/shared/groupinglevels.md + - docs/sdk/models/shared/groupingperiod.md + - docs/sdk/models/shared/halref.md + - docs/sdk/models/shared/imagereference.md + - docs/sdk/models/shared/integration.md + - docs/sdk/models/shared/integrations.md + - docs/sdk/models/shared/invoicelevelselection.md + - docs/sdk/models/shared/invoicelinelevelselection.md + - docs/sdk/models/shared/invoicestatus.md + - docs/sdk/models/shared/links.md + - docs/sdk/models/shared/locale.md + - docs/sdk/models/shared/localization.md + - docs/sdk/models/shared/newpaymentsconfiguration.md + - docs/sdk/models/shared/newtaxrates.md + - docs/sdk/models/shared/outputformat.md + - docs/sdk/models/shared/paymentsconfiguration.md + - docs/sdk/models/shared/salesconfiguration.md + - docs/sdk/models/shared/salescustomer.md + - docs/sdk/models/shared/security.md + - docs/sdk/models/shared/sourcetype.md + - docs/sdk/models/shared/supportedfeature.md + - docs/sdk/models/shared/syncconnectiondeletedwebhook.md + - docs/sdk/models/shared/syncdaterangeutc.md + - docs/sdk/models/shared/syncflowurl.md + - docs/sdk/models/shared/syncfrequency.md + - docs/sdk/models/shared/syncrange.md + - docs/sdk/models/shared/syncschedule.md + - docs/sdk/models/shared/syncstatus.md + - docs/sdk/models/shared/syncsummary.md + - docs/sdk/models/shared/synctolatestargs.md + - docs/sdk/models/shared/taxrateamount.md + - docs/sdk/models/shared/taxratemapping.md + - docs/sdk/models/shared/updateconnection.md + - docs/sdk/models/shared/visibleaccounts.md + - docs/sdks/advancedcontrols/README.md + - docs/sdks/codatsynccommerce/README.md + - docs/sdks/connections/README.md + - docs/sdks/integrations/README.md + - docs/sdks/sync/README.md + - docs/sdks/syncflowsettings/README.md - jsr.json - package.json + - src/core.ts + - src/funcs/advancedControlsCreateCompany.ts + - src/funcs/advancedControlsGetConfiguration.ts + - src/funcs/advancedControlsListCompanies.ts + - src/funcs/advancedControlsSetConfiguration.ts + - src/funcs/connectionsCreate.ts + - src/funcs/connectionsGetSyncFlowUrl.ts + - src/funcs/connectionsList.ts + - src/funcs/connectionsUpdateAuthorization.ts + - src/funcs/connectionsUpdateConnection.ts + - src/funcs/integrationsGetBranding.ts + - src/funcs/integrationsList.ts + - src/funcs/syncFlowSettingsGetConfigTextSyncFlow.ts + - src/funcs/syncFlowSettingsGetVisibleAccounts.ts + - src/funcs/syncFlowSettingsUpdateConfigTextSyncFlow.ts + - src/funcs/syncFlowSettingsUpdateVisibleAccountsSyncFlow.ts + - src/funcs/syncGet.ts + - src/funcs/syncGetLastSuccessfulSync.ts + - src/funcs/syncGetLatestSync.ts + - src/funcs/syncGetStatus.ts + - src/funcs/syncList.ts + - src/funcs/syncRequest.ts + - src/funcs/syncRequestForDateRange.ts + - src/hooks/hooks.ts + - src/hooks/index.ts + - src/hooks/types.ts - src/index.ts - src/lib/base64.ts - src/lib/config.ts + - src/lib/dlv.ts - src/lib/encodings.ts + - src/lib/files.ts - src/lib/http.ts - src/lib/is-plain-object.ts + - src/lib/logger.ts + - src/lib/matchers.ts - src/lib/primitives.ts - src/lib/retries.ts - src/lib/schemas.ts - src/lib/sdks.ts - src/lib/security.ts - src/lib/url.ts + - src/sdk/advancedcontrols.ts + - src/sdk/connections.ts - src/sdk/index.ts + - src/sdk/integrations.ts + - src/sdk/models/errors/errormessage.ts + - src/sdk/models/errors/httpclienterrors.ts + - src/sdk/models/errors/index.ts - src/sdk/models/errors/sdkerror.ts - src/sdk/models/errors/sdkvalidationerror.ts - - src/sdk/types/blobs.ts - - src/sdk/types/enums.ts - - src/sdk/types/index.ts - - src/sdk/types/operations.ts - - src/sdk/types/rfcdate.ts - - tsconfig.json - - src/sdk/models/shared/syncflowurl.ts - - src/sdk/models/shared/errorvalidation.ts - - src/sdk/models/shared/errorvalidationitem.ts - - src/sdk/models/shared/connections.ts - - src/sdk/models/shared/links.ts - - src/sdk/models/shared/halref.ts - - src/sdk/models/shared/connection.ts - - src/sdk/models/shared/dataconnectionerror.ts - - src/sdk/models/shared/dataconnectionstatus.ts - - src/sdk/models/shared/sourcetype.ts - - src/sdk/models/shared/updateconnection.ts + - src/sdk/models/operations/createconnection.ts + - src/sdk/models/operations/getconfigtextsyncflow.ts + - src/sdk/models/operations/getconfiguration.ts + - src/sdk/models/operations/getintegrationbranding.ts + - src/sdk/models/operations/getlastsuccessfulsync.ts + - src/sdk/models/operations/getlatestsync.ts + - src/sdk/models/operations/getsyncbyid.ts + - src/sdk/models/operations/getsyncflowurl.ts + - src/sdk/models/operations/getsyncstatus.ts + - src/sdk/models/operations/getvisibleaccounts.ts + - src/sdk/models/operations/index.ts + - src/sdk/models/operations/listcompanies.ts + - src/sdk/models/operations/listconnections.ts + - src/sdk/models/operations/listintegrations.ts + - src/sdk/models/operations/listsyncs.ts + - src/sdk/models/operations/requestsync.ts + - src/sdk/models/operations/requestsyncfordaterange.ts + - src/sdk/models/operations/setconfiguration.ts + - src/sdk/models/operations/updateconfigtextsyncflow.ts + - src/sdk/models/operations/updateconnection.ts + - src/sdk/models/operations/updateconnectionauthorization.ts + - src/sdk/models/operations/updatevisibleaccountssyncflow.ts + - src/sdk/models/shared/accountconfiguration.ts + - src/sdk/models/shared/accountconfigurationoption.ts + - src/sdk/models/shared/branding.ts + - src/sdk/models/shared/brandingbutton.ts + - src/sdk/models/shared/brandingimage.ts + - src/sdk/models/shared/brandinglogo.ts + - src/sdk/models/shared/commerceconfiguration.ts - src/sdk/models/shared/companies.ts - src/sdk/models/shared/company.ts - - src/sdk/models/shared/createcompany.ts - - src/sdk/models/shared/items.ts + - src/sdk/models/shared/companyreference.ts + - src/sdk/models/shared/companysyncstatus.ts - src/sdk/models/shared/configuration.ts - - src/sdk/models/shared/commerceconfiguration.ts + - src/sdk/models/shared/configurationmapsettings.ts + - src/sdk/models/shared/configurationoption.ts + - src/sdk/models/shared/connection.ts + - src/sdk/models/shared/connections.ts + - src/sdk/models/shared/connectionwebhook.ts + - src/sdk/models/shared/connectionwebhookpayload.ts + - src/sdk/models/shared/createcompany.ts + - src/sdk/models/shared/dataconnectionerror.ts + - src/sdk/models/shared/dataconnectionstatus.ts + - src/sdk/models/shared/datatypefeature.ts + - src/sdk/models/shared/errorvalidation.ts + - src/sdk/models/shared/errorvalidationitem.ts + - src/sdk/models/shared/featurestate.ts + - src/sdk/models/shared/featuretype.ts - src/sdk/models/shared/feesconfiguration.ts - - src/sdk/models/shared/accountconfiguration.ts - - src/sdk/models/shared/accountconfigurationoption.ts - src/sdk/models/shared/feessupplier.ts - - src/sdk/models/shared/configurationoption.ts - - src/sdk/models/shared/newpaymentsconfiguration.ts - - src/sdk/models/shared/paymentsconfiguration.ts - - src/sdk/models/shared/salesconfiguration.ts - src/sdk/models/shared/grouping.ts - src/sdk/models/shared/groupinglevels.ts - - src/sdk/models/shared/invoicelinelevelselection.ts - - src/sdk/models/shared/invoicelevelselection.ts - src/sdk/models/shared/groupingperiod.ts + - src/sdk/models/shared/halref.ts + - src/sdk/models/shared/imagereference.ts + - src/sdk/models/shared/index.ts + - src/sdk/models/shared/integration.ts + - src/sdk/models/shared/integrations.ts + - src/sdk/models/shared/invoicelevelselection.ts + - src/sdk/models/shared/invoicelinelevelselection.ts + - src/sdk/models/shared/invoicestatus.ts + - src/sdk/models/shared/links.ts + - src/sdk/models/shared/locale.ts + - src/sdk/models/shared/localization.ts + - src/sdk/models/shared/newpaymentsconfiguration.ts - src/sdk/models/shared/newtaxrates.ts - - src/sdk/models/shared/taxratemapping.ts - - src/sdk/models/shared/taxrateamount.ts + - src/sdk/models/shared/paymentsconfiguration.ts + - src/sdk/models/shared/salesconfiguration.ts - src/sdk/models/shared/salescustomer.ts - - src/sdk/models/shared/invoicestatus.ts - - src/sdk/models/shared/configurationmapsettings.ts - - src/sdk/models/shared/syncschedule.ts - - src/sdk/models/shared/syncfrequency.ts - - src/sdk/models/shared/integrations.ts - - src/sdk/models/shared/integration.ts - - src/sdk/models/shared/datatypefeature.ts + - src/sdk/models/shared/security.ts + - src/sdk/models/shared/sourcetype.ts - src/sdk/models/shared/supportedfeature.ts - - src/sdk/models/shared/featurestate.ts - - src/sdk/models/shared/featuretype.ts - - src/sdk/models/shared/branding.ts - - src/sdk/models/shared/brandingbutton.ts - - src/sdk/models/shared/brandingimage.ts - - src/sdk/models/shared/imagereference.ts - - src/sdk/models/shared/brandinglogo.ts - - src/sdk/models/shared/localization.ts - - src/sdk/models/shared/locale.ts - - src/sdk/models/shared/visibleaccounts.ts - - src/sdk/models/shared/syncsummary.ts - - src/sdk/models/shared/synctolatestargs.ts + - src/sdk/models/shared/syncconnectiondeletedwebhook.ts + - src/sdk/models/shared/syncflowurl.ts + - src/sdk/models/shared/syncfrequency.ts - src/sdk/models/shared/syncrange.ts + - src/sdk/models/shared/syncschedule.ts - src/sdk/models/shared/syncstatus.ts - - src/sdk/models/shared/companysyncstatus.ts - - src/sdk/models/shared/security.ts - - src/sdk/models/shared/syncconnectiondeletedwebhook.ts - - src/sdk/models/errors/errormessage.ts - - src/sdk/models/operations/getsyncflowurl.ts - - src/sdk/models/operations/listconnections.ts - - src/sdk/models/operations/createconnection.ts - - src/sdk/models/operations/updateconnection.ts - - src/sdk/models/operations/updateconnectionauthorization.ts - - src/sdk/models/operations/listcompanies.ts - - src/sdk/models/operations/getconfiguration.ts - - src/sdk/models/operations/setconfiguration.ts - - src/sdk/models/operations/listintegrations.ts - - src/sdk/models/operations/getintegrationbranding.ts - - src/sdk/models/operations/getconfigtextsyncflow.ts - - src/sdk/models/operations/updateconfigtextsyncflow.ts - - src/sdk/models/operations/getvisibleaccounts.ts - - src/sdk/models/operations/updatevisibleaccountssyncflow.ts - - src/sdk/models/operations/requestsync.ts - - src/sdk/models/operations/requestsyncfordaterange.ts - - src/sdk/models/operations/getsyncstatus.ts - - src/sdk/models/operations/getlastsuccessfulsync.ts - - src/sdk/models/operations/getlatestsync.ts - - src/sdk/models/operations/getsyncbyid.ts - - src/sdk/models/operations/listsyncs.ts - - src/sdk/models/errors/index.ts - - src/sdk/models/shared/index.ts - - src/sdk/models/operations/index.ts - - docs/sdk/models/shared/syncflowurl.md - - docs/sdk/models/shared/errorvalidation.md - - docs/sdk/models/shared/errorvalidationitem.md - - docs/sdk/models/shared/connections.md - - docs/sdk/models/shared/links.md - - docs/sdk/models/shared/halref.md - - docs/sdk/models/shared/connection.md - - docs/sdk/models/shared/errorstatus.md - - docs/sdk/models/shared/dataconnectionerror.md - - docs/sdk/models/shared/dataconnectionstatus.md - - docs/sdk/models/shared/sourcetype.md - - docs/sdk/models/shared/updateconnection.md - - docs/sdk/models/shared/companies.md - - docs/sdk/models/shared/groupreference.md - - docs/sdk/models/shared/company.md - - docs/sdk/models/shared/createcompany.md - - docs/sdk/models/shared/items.md - - docs/sdk/models/shared/configuration.md - - docs/sdk/models/shared/commerceconfiguration.md - - docs/sdk/models/shared/feesconfiguration.md - - docs/sdk/models/shared/accountconfiguration.md - - docs/sdk/models/shared/accountconfigurationoption.md - - docs/sdk/models/shared/feessupplier.md - - docs/sdk/models/shared/configurationoption.md - - docs/sdk/models/shared/newpaymentsconfiguration.md - - docs/sdk/models/shared/paymentsconfiguration.md - - docs/sdk/models/shared/salesconfiguration.md - - docs/sdk/models/shared/grouping.md - - docs/sdk/models/shared/groupinglevels.md - - docs/sdk/models/shared/invoicelinelevelselection.md - - docs/sdk/models/shared/invoicelevelselection.md - - docs/sdk/models/shared/groupingperiod.md - - docs/sdk/models/shared/newtaxrates.md - - docs/sdk/models/shared/taxratemapping.md - - docs/sdk/models/shared/taxrateamount.md - - docs/sdk/models/shared/salescustomer.md - - docs/sdk/models/shared/invoicestatus.md - - docs/sdk/models/shared/outputformat.md - - docs/sdk/models/shared/configurationmapsettings.md - - docs/sdk/models/shared/syncschedule.md - - docs/sdk/models/shared/syncfrequency.md - - docs/sdk/models/shared/integrations.md - - docs/sdk/models/shared/integration.md - - docs/sdk/models/shared/datatypes.md - - docs/sdk/models/shared/datatypefeature.md - - docs/sdk/models/shared/supportedfeature.md - - docs/sdk/models/shared/featurestate.md - - docs/sdk/models/shared/featuretype.md - - docs/sdk/models/shared/branding.md - - docs/sdk/models/shared/brandingbutton.md - - docs/sdk/models/shared/brandingimage.md - - docs/sdk/models/shared/imagereference.md - - docs/sdk/models/shared/brandinglogo.md - - docs/sdk/models/shared/localization.md - - docs/sdk/models/shared/locale.md - - docs/sdk/models/shared/visibleaccounts.md - - docs/sdk/models/shared/syncdaterangeutc.md - - docs/sdk/models/shared/syncsummary.md - - docs/sdk/models/shared/synctolatestargs.md - - docs/sdk/models/shared/daterange.md - - docs/sdk/models/shared/syncrange.md - - docs/sdk/models/shared/syncstatus.md - - docs/sdk/models/shared/companysyncstatus.md - - docs/sdk/models/shared/security.md - - docs/sdk/models/shared/syncconnectiondeletedwebhook.md - - docs/sdk/models/errors/errormessage.md - - docs/sdk/models/operations/getsyncflowurlrequest.md - - docs/sdk/models/operations/listconnectionsrequest.md - - docs/sdk/models/operations/createconnectionrequestbody.md - - docs/sdk/models/operations/createconnectionrequest.md - - docs/sdk/models/operations/updateconnectionrequest.md - - docs/sdk/models/operations/updateconnectionauthorizationrequest.md - - docs/sdk/models/operations/listcompaniesrequest.md - - docs/sdk/models/operations/getconfigurationrequest.md - - docs/sdk/models/operations/setconfigurationrequest.md - - docs/sdk/models/operations/listintegrationsrequest.md - - docs/sdk/models/operations/getintegrationbrandingrequest.md - - docs/sdk/models/operations/getconfigtextsyncflowrequest.md - - docs/sdk/models/operations/updateconfigtextsyncflowrequest.md - - docs/sdk/models/operations/getvisibleaccountsrequest.md - - docs/sdk/models/operations/updatevisibleaccountssyncflowrequest.md - - docs/sdk/models/operations/requestsyncrequest.md - - docs/sdk/models/operations/requestsyncfordaterangerequest.md - - docs/sdk/models/operations/getsyncstatusrequest.md - - docs/sdk/models/operations/getlastsuccessfulsyncrequest.md - - docs/sdk/models/operations/getlatestsyncrequest.md - - docs/sdk/models/operations/getsyncbyidrequest.md - - docs/sdk/models/operations/listsyncsrequest.md - - docs/sdks/codatsynccommerce/README.md - - docs/lib/utils/retryconfig.md - - docs/sdks/connections/README.md - - docs/sdks/advancedcontrols/README.md - - docs/sdks/integrations/README.md - - docs/sdks/syncflowsettings/README.md - - docs/sdks/sync/README.md - - USAGE.md - - .gitattributes - - src/hooks/hooks.ts - - src/hooks/types.ts - - src/hooks/index.ts - - CONTRIBUTING.md + - src/sdk/models/shared/syncsummary.ts + - src/sdk/models/shared/synctolatestargs.ts + - src/sdk/models/shared/taxrateamount.ts + - src/sdk/models/shared/taxratemapping.ts + - src/sdk/models/shared/updateconnection.ts + - src/sdk/models/shared/visibleaccounts.ts + - src/sdk/sdk.ts + - src/sdk/sync.ts + - src/sdk/syncflowsettings.ts + - src/sdk/types/blobs.ts + - src/sdk/types/constdatetime.ts + - src/sdk/types/enums.ts + - src/sdk/types/fp.ts + - src/sdk/types/index.ts + - src/sdk/types/operations.ts + - src/sdk/types/rfcdate.ts + - src/sdk/types/streams.ts + - tsconfig.json +examples: + get-sync-flow-url: + Malformed query: + parameters: + path: + commerceKey: "" + accountingKey: "" + query: {} + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + list-connections: + "": + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"pageNumber": 1, "pageSize": 10, "totalResults": 1, "_links": {"self": {"href": "/companies/{id}/data/{dataType}"}, "current": {"href": "/companies/{id}/data/{dataType}?page=1&pageSize=10"}}} + "400": {} + Connections: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"results": [{"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "platformName": "Basiq", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "status": "Linked", "lastSync": "2022-10-27T10:22:43.6464237Z", "created": "2022-10-27T09:53:29Z"}], "pageNumber": 0, "pageSize": 0, "totalResults": 0, "_links": {"self": {"href": "string"}, "current": {"href": "string"}, "next": {"href": "string"}, "previous": {"href": "string"}}} + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"statusCode": 400, "service": "ClientsApi", "error": "Error parsing query - Malformed query.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + Unresolved property: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"statusCode": 400, "service": "PullApi", "error": "Error parsing query - Could not resolve property isCompleted on Dataset", "correlationId": "98457fb9956b7f9b4b2fd4f6e23bb5c8", "canBeRetried": "Unknown", "detailedErrorCode": 0} + create-connection: + Connection: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + requestBody: + application/json: {"platformKey": "gbol"} + responses: + "200": + application/json: {"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "platformName": "Basiq", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "status": "Linked", "lastSync": "2022-10-27T10:22:43.6464237Z", "created": "2022-10-27T09:53:29Z"} + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + requestBody: + application/json: {"platformKey": "gbol"} + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + update-connection: + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + update-connection-authorization: + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + list-companies: + "": + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"pageNumber": 1, "pageSize": 10, "totalResults": 1, "_links": {"self": {"href": "/companies/{id}/data/{dataType}"}, "current": {"href": "/companies/{id}/data/{dataType}?page=1&pageSize=10"}}} + "400": {} + Malformed query: + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"statusCode": 400, "service": "ClientsApi", "error": "Error parsing query - Malformed query.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + Unresolved property: + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"statusCode": 400, "service": "PullApi", "error": "Error parsing query - Could not resolve property isCompleted on Dataset", "correlationId": "98457fb9956b7f9b4b2fd4f6e23bb5c8", "canBeRetried": "Unknown", "detailedErrorCode": 0} + create-company: + "": + requestBody: + application/json: {"name": "string"} + responses: + "200": + application/json: {"id": "0498e921-9b53-4396-a412-4f2f5983b0a2", "name": "string", "redirect": "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", "lastSync": "2022-01-01T12:00:00.000Z", "created": "2022-01-01T12:00:00.000Z", "createdByUserName": "string", "tags": {"region": "us", "uid": "f6b0c253-16c7-4da1-a0c5-9c871e9c9d6c"}, "dataConnections": [{"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", "integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c", "integrationKey": "dfxm", "sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee", "sourceType": "Banking", "platformName": "Basiq", "linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", "status": "Linked", "lastSync": "2022-10-27T10:22:43.6464237Z", "created": "2022-10-27T09:53:29Z"}]} + "400": {} + Malformed query: + requestBody: + application/json: {"name": "Bank of Dave", "description": "Requested early access to the new financing scheme."} + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + get-configuration: + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + set-configuration: + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + list-integrations: + "": + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "200": + application/json: {"pageNumber": 1, "pageSize": 10, "totalResults": 1, "_links": {"self": {"href": "/companies/{id}/data/{dataType}"}, "current": {"href": "/companies/{id}/data/{dataType}?page=1&pageSize=10"}}} + "400": {} + Malformed query: + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"statusCode": 400, "service": "ClientsApi", "error": "Error parsing query - Malformed query.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + Unresolved property: + parameters: + query: + page: 1 + pageSize: 100 + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee" + orderBy: "-modifiedDate" + responses: + "400": + application/json: {"statusCode": 400, "service": "PullApi", "error": "Error parsing query - Could not resolve property isCompleted on Dataset", "correlationId": "98457fb9956b7f9b4b2fd4f6e23bb5c8", "canBeRetried": "Unknown", "detailedErrorCode": 0} + get-integration-branding: + Unauthorized: + parameters: + path: + platformKey: "gbol" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + get-config-text-sync-flow: + "": + parameters: + query: + locale: "en-us" + Unauthorized: + parameters: + query: + locale: "en-us" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + update-config-text-sync-flow: + "": + parameters: + query: + locale: "en-us" + responses: + "200": + application/json: {} + "400": {} + Malformed query: + parameters: + query: + locale: "en-us" + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + get-visible-accounts: + Unauthorized: + parameters: + path: + clientId: "8f9478fc-e6cf-445e-b122-74136f8fd7ab" + platformKey: "gbol" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + update-visible-accounts-sync-flow: + Malformed query: + parameters: + path: + platformKey: "gbol" + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + request-sync: + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + requestBody: + application/json: {"syncTo": "2022-10-23T00:00:00Z"} + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + request-sync-for-date-range: + Malformed query: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + requestBody: + application/json: {"dateRange": {"start": "2022-10-23T00:00:00Z", "finish": "2022-10-23T00:00:00Z"}} + responses: + "400": + application/json: {"statusCode": 400, "service": "PublicApi", "error": "Error processing request - not valid.", "correlationId": "bc997528a9d7abb9161ef45f05d38599", "canBeRetried": "Unknown", "detailedErrorCode": 0} + get-sync-status: + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + get-last-successful-sync: + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + get-latest-sync: + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + get-sync-by-id: + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + syncId: "6fb40d5e-b13e-11ed-afa1-0242ac120002" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} + list-syncs: + Unauthorized: + parameters: + path: + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002" + responses: + "401": + application/json: {"statusCode": 401, "service": "PublicApi", "error": "Unauthorized", "correlationId": "7eb40d6b415d7bcd99ce658268284056", "canBeRetried": "Unknown", "detailedErrorCode": 0} +generatedTests: {} diff --git a/sync-for-commerce/.speakeasy/gen.yaml b/sync-for-commerce/.speakeasy/gen.yaml index 2c975231f..2bc5867e7 100644 --- a/sync-for-commerce/.speakeasy/gen.yaml +++ b/sync-for-commerce/.speakeasy/gen.yaml @@ -11,9 +11,10 @@ generation: requestResponseComponentNamesFeb2024: true auth: oAuth2ClientCredentialsEnabled: false + oAuth2PasswordEnabled: false telemetryEnabled: true typescript: - version: 4.0.0 + version: 5.0.0 additionalDependencies: dependencies: {} devDependencies: {} @@ -21,9 +22,11 @@ typescript: additionalPackageJSON: {} author: Codat clientServerStatusCodesAsErrors: true + defaultErrorName: SDKError description: Push merchants' data from your ecommerce or point-of-sale (POS) platform into your merchants' accounting platform. enumFormat: union flattenGlobalSecurity: true + flatteningOrder: body-first imports: option: openapi paths: diff --git a/sync-for-commerce/FUNCTIONS.md b/sync-for-commerce/FUNCTIONS.md new file mode 100644 index 000000000..22332db2a --- /dev/null +++ b/sync-for-commerce/FUNCTIONS.md @@ -0,0 +1,107 @@ +# Standalone Functions + +> [!NOTE] +> This section is useful if you are using a bundler and targetting browsers and +> runtimes where the size of an application affects performance and load times. + +Every method in this SDK is also available as a standalone function. This +alternative API is suitable when targetting the browser or serverless runtimes +and using a bundler to build your application since all unused functionality +will be tree-shaken away. This includes code for unused methods, Zod schemas, +encoding helpers and response handlers. The result is dramatically smaller +impact on the application's final bundle size which grows very slowly as you use +more and more functionality from this SDK. + +Calling methods through the main SDK class remains a valid and generally more +more ergonomic option. Standalone functions represent an optimisation for a +specific category of applications. + +## Example + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { connectionsGetSyncFlowUrl } from "@codat/sync-for-commerce/funcs/connectionsGetSyncFlowUrl.js"; +import { SDKValidationError } from "@codat/sync-for-commerce/sdk/models/errors/sdkvalidationerror.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await connectionsGetSyncFlowUrl(codatSyncCommerce, { + commerceKey: "", + accountingKey: "", + }); + + switch (true) { + case res.ok: + // The success case will be handled outside of the switch block + break; + case res.error instanceof SDKValidationError: + // Pretty-print validation errors. + return console.log(res.error.pretty()); + case res.error instanceof Error: + return console.log(res.error); + default: + // TypeScript's type checking will fail on the following line if the above + // cases were not exhaustive. + res.error satisfies never; + throw new Error("Assertion failed: expected error checks to be exhaustive: " + res.error); + } + + + const { value: result } = res; + + // Handle the result + console.log(result); +} + +run(); +``` + +## Result types + +Standalone functions differ from SDK methods in that they return a +`Result` type to capture _known errors_ and document them using +the type system. By avoiding throwing errors, application code maintains clear +control flow and error-handling become part of the regular flow of application +code. + +> We use the term "known errors" because standalone functions, and JavaScript +> code in general, can still throw unexpected errors such as `TypeError`s, +> `RangeError`s and `DOMException`s. Exhaustively catching all errors may be +> something this SDK addresses in the future. Nevertheless, there is still a lot +> of benefit from capturing most errors and turning them into values. + +The second reason for this style of programming is because these functions will +typically be used in front-end applications where exception throwing is +sometimes discouraged or considered unidiomatic. React and similar ecosystems +and libraries tend to promote this style of programming so that components +render useful content under all states (loading, success, error and so on). + +The general pattern when calling standalone functions looks like this: + +```typescript +import { Core } from ""; +import { fetchSomething } from "/funcs/fetchSomething.js"; + +const client = new Core(); + +async function run() { + const result = await fetchSomething(client, { id: "123" }); + if (!result.ok) { + // You can throw the error or handle it. It's your choice now. + throw result.error; + } + + console.log(result.value); +} + +run(); +``` + +Notably, `result.error` above will have an explicit type compared to a try-catch +variation where the error in the catch block can only be of type `unknown` (or +`any` depending on your TypeScript settings). \ No newline at end of file diff --git a/sync-for-commerce/README.md b/sync-for-commerce/README.md index 7ee85761c..bc385a0d5 100755 --- a/sync-for-commerce/README.md +++ b/sync-for-commerce/README.md @@ -4,9 +4,53 @@ Embedded accounting integrations for POS and eCommerce platforms. + +## Summary + +Sync for Commerce: The API for Sync for Commerce. + +Sync for Commerce automatically replicates and reconciles sales data from a merchant’s source PoS, Payments, and eCommerce systems into their accounting software. This eliminates manual processing by merchants and transforms their ability to run and grow their business. + +[Explore product](https://docs.codat.io/commerce/overview) | [See our OpenAPI spec](https://github.com/codatio/oas) + +Not seeing the endpoints you're expecting? We've [reorganized our products](https://docs.codat.io/updates/230901-new-products), and you may be using a [different version of Sync for Commerce](https://docs.codat.io/sync-for-commerce-v1-api#/). + +--- + + +## Endpoints + +| Endpoints | Description | +| :- |:- | +| Connections | Create new and manage existing data connections for a company. | +| Sync | Initiate data syncs and monitor their status. | +| Sync flow settings | Control text and visibility settings for the Sync Flow. | +| Integrations | Get a list of integrations supported by Sync for Commerce and their logos. | +| Advanced controls | View and manage mapping configured for a company's commerce sync. | + + + + +## Table of Contents + +* [SDK Installation](#sdk-installation) +* [Requirements](#requirements) +* [SDK Example Usage](#sdk-example-usage) +* [Available Resources and Operations](#available-resources-and-operations) +* [Standalone functions](#standalone-functions) +* [Retries](#retries) +* [Error Handling](#error-handling) +* [Server Selection](#server-selection) +* [Custom HTTP Client](#custom-http-client) +* [Authentication](#authentication) +* [Debugging](#debugging) + + ## SDK Installation +The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers. + ### NPM ```bash @@ -45,17 +89,17 @@ yarn add @codat/sync-for-commerce zod import { CodatSyncCommerce } from "@codat/sync-for-commerce"; const codatSyncCommerce = new CodatSyncCommerce({ - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await codatSyncCommerce.connections.getSyncFlowUrl({ - commerceKey: "", - accountingKey: "", - }); + const result = await codatSyncCommerce.connections.getSyncFlowUrl({ + commerceKey: "", + accountingKey: "", + }); - // Handle the result - console.log(result); + // Handle the result + console.log(result); } run(); @@ -66,13 +110,8 @@ run(); ## Available Resources and Operations -### [connections](docs/sdks/connections/README.md) - -* [getSyncFlowUrl](docs/sdks/connections/README.md#getsyncflowurl) - Start new sync flow -* [list](docs/sdks/connections/README.md#list) - List connections -* [create](docs/sdks/connections/README.md#create) - Create connection -* [updateConnection](docs/sdks/connections/README.md#updateconnection) - Update connection -* [updateAuthorization](docs/sdks/connections/README.md#updateauthorization) - Update authorization +
+Available methods ### [advancedControls](docs/sdks/advancedcontrols/README.md) @@ -81,18 +120,20 @@ run(); * [getConfiguration](docs/sdks/advancedcontrols/README.md#getconfiguration) - Get company configuration * [setConfiguration](docs/sdks/advancedcontrols/README.md#setconfiguration) - Set configuration + +### [connections](docs/sdks/connections/README.md) + +* [getSyncFlowUrl](docs/sdks/connections/README.md#getsyncflowurl) - Start new sync flow +* [list](docs/sdks/connections/README.md#list) - List connections +* [create](docs/sdks/connections/README.md#create) - Create connection +* [updateConnection](docs/sdks/connections/README.md#updateconnection) - Update connection +* [updateAuthorization](docs/sdks/connections/README.md#updateauthorization) - Update authorization + ### [integrations](docs/sdks/integrations/README.md) * [list](docs/sdks/integrations/README.md#list) - List integrations * [getBranding](docs/sdks/integrations/README.md#getbranding) - Get branding for an integration -### [syncFlowSettings](docs/sdks/syncflowsettings/README.md) - -* [getConfigTextSyncFlow](docs/sdks/syncflowsettings/README.md#getconfigtextsyncflow) - Get preferences for text fields -* [updateConfigTextSyncFlow](docs/sdks/syncflowsettings/README.md#updateconfigtextsyncflow) - Update preferences for text fields -* [getVisibleAccounts](docs/sdks/syncflowsettings/README.md#getvisibleaccounts) - List visible accounts -* [updateVisibleAccountsSyncFlow](docs/sdks/syncflowsettings/README.md#updatevisibleaccountssyncflow) - Update visible accounts - ### [sync](docs/sdks/sync/README.md) * [request](docs/sdks/sync/README.md#request) - Initiate new sync @@ -102,6 +143,15 @@ run(); * [getLatestSync](docs/sdks/sync/README.md#getlatestsync) - Latest sync status * [get](docs/sdks/sync/README.md#get) - Get sync status * [list](docs/sdks/sync/README.md#list) - List sync statuses + +### [syncFlowSettings](docs/sdks/syncflowsettings/README.md) + +* [getConfigTextSyncFlow](docs/sdks/syncflowsettings/README.md#getconfigtextsyncflow) - Get preferences for text fields +* [updateConfigTextSyncFlow](docs/sdks/syncflowsettings/README.md#updateconfigtextsyncflow) - Update preferences for text fields +* [getVisibleAccounts](docs/sdks/syncflowsettings/README.md#getvisibleaccounts) - List visible accounts +* [updateVisibleAccountsSyncFlow](docs/sdks/syncflowsettings/README.md#updatevisibleaccountssyncflow) - Update visible accounts + +
@@ -112,6 +162,47 @@ run(); For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md). + +## Standalone functions + +All the methods listed above are available as standalone functions. These +functions are ideal for use in applications running in the browser, serverless +runtimes or other environments where application bundle size is a primary +concern. When using a bundler to build your application, all unused +functionality will be either excluded from the final bundle or tree-shaken away. + +To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md). + +
+ +Available standalone functions + +- [`advancedControlsCreateCompany`](docs/sdks/advancedcontrols/README.md#createcompany) - Create company +- [`advancedControlsGetConfiguration`](docs/sdks/advancedcontrols/README.md#getconfiguration) - Get company configuration +- [`advancedControlsListCompanies`](docs/sdks/advancedcontrols/README.md#listcompanies) - List companies +- [`advancedControlsSetConfiguration`](docs/sdks/advancedcontrols/README.md#setconfiguration) - Set configuration +- [`connectionsCreate`](docs/sdks/connections/README.md#create) - Create connection +- [`connectionsGetSyncFlowUrl`](docs/sdks/connections/README.md#getsyncflowurl) - Start new sync flow +- [`connectionsList`](docs/sdks/connections/README.md#list) - List connections +- [`connectionsUpdateAuthorization`](docs/sdks/connections/README.md#updateauthorization) - Update authorization +- [`connectionsUpdateConnection`](docs/sdks/connections/README.md#updateconnection) - Update connection +- [`integrationsGetBranding`](docs/sdks/integrations/README.md#getbranding) - Get branding for an integration +- [`integrationsList`](docs/sdks/integrations/README.md#list) - List integrations +- [`syncFlowSettingsGetConfigTextSyncFlow`](docs/sdks/syncflowsettings/README.md#getconfigtextsyncflow) - Get preferences for text fields +- [`syncFlowSettingsGetVisibleAccounts`](docs/sdks/syncflowsettings/README.md#getvisibleaccounts) - List visible accounts +- [`syncFlowSettingsUpdateConfigTextSyncFlow`](docs/sdks/syncflowsettings/README.md#updateconfigtextsyncflow) - Update preferences for text fields +- [`syncFlowSettingsUpdateVisibleAccountsSyncFlow`](docs/sdks/syncflowsettings/README.md#updatevisibleaccountssyncflow) - Update visible accounts +- [`syncGet`](docs/sdks/sync/README.md#get) - Get sync status +- [`syncGetLastSuccessfulSync`](docs/sdks/sync/README.md#getlastsuccessfulsync) - Last successful sync +- [`syncGetLatestSync`](docs/sdks/sync/README.md#getlatestsync) - Latest sync status +- [`syncGetStatus`](docs/sdks/sync/README.md#getstatus) - Get sync status +- [`syncList`](docs/sdks/sync/README.md#list) - List sync statuses +- [`syncRequest`](docs/sdks/sync/README.md#request) - Initiate new sync +- [`syncRequestForDateRange`](docs/sdks/sync/README.md#requestfordaterange) - Initiate sync for specific range + +
+ + ## Retries @@ -122,31 +213,28 @@ To change the default retry strategy for a single API call, simply provide a ret import { CodatSyncCommerce } from "@codat/sync-for-commerce"; const codatSyncCommerce = new CodatSyncCommerce({ - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await codatSyncCommerce.connections.getSyncFlowUrl( - { - commerceKey: "", - accountingKey: "", - }, - { - retries: { - strategy: "backoff", - backoff: { - initialInterval: 1, - maxInterval: 50, - exponent: 1.1, - maxElapsedTime: 100, - }, - retryConnectionErrors: false, - }, - } - ); + const result = await codatSyncCommerce.connections.getSyncFlowUrl({ + commerceKey: "", + accountingKey: "", + }, { + retries: { + strategy: "backoff", + backoff: { + initialInterval: 1, + maxInterval: 50, + exponent: 1.1, + maxElapsedTime: 100, + }, + retryConnectionErrors: false, + }, + }); - // Handle the result - console.log(result); + // Handle the result + console.log(result); } run(); @@ -158,27 +246,27 @@ If you'd like to override the default retry strategy for all operations that sup import { CodatSyncCommerce } from "@codat/sync-for-commerce"; const codatSyncCommerce = new CodatSyncCommerce({ - retryConfig: { - strategy: "backoff", - backoff: { - initialInterval: 1, - maxInterval: 50, - exponent: 1.1, - maxElapsedTime: 100, - }, - retryConnectionErrors: false, + retryConfig: { + strategy: "backoff", + backoff: { + initialInterval: 1, + maxInterval: 50, + exponent: 1.1, + maxElapsedTime: 100, }, - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + retryConnectionErrors: false, + }, + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await codatSyncCommerce.connections.getSyncFlowUrl({ - commerceKey: "", - accountingKey: "", - }); + const result = await codatSyncCommerce.connections.getSyncFlowUrl({ + commerceKey: "", + accountingKey: "", + }); - // Handle the result - console.log(result); + // Handle the result + console.log(result); } run(); @@ -189,113 +277,96 @@ run(); ## Error Handling -All SDK methods return a response object or throw an error. If Error objects are specified in your OpenAPI Spec, the SDK will throw the appropriate Error type. +All SDK methods return a response object or throw an error. By default, an API error will throw a `errors.SDKError`. -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| errors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +If a HTTP request fails, an operation my also throw an error from the `sdk/models/errors/httpclienterrors.ts` module: -Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted string since validation errors can list many issues and the plain error string may be difficult read when debugging. +| HTTP Client Error | Description | +| ---------------------------------------------------- | ---------------------------------------------------- | +| RequestAbortedError | HTTP request was aborted by the client | +| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal | +| ConnectionError | HTTP client was unable to make a request to a server | +| InvalidRequestError | Any input used to create a request is invalid | +| UnexpectedClientError | Unrecognised or unexpected error | +In addition, when custom error responses are specified for an operation, the SDK may throw their associated Error type. You can refer to respective *Errors* tables in SDK docs for more details on possible error types for each operation. For example, the `getSyncFlowUrl` method may throw the following errors: + +| Error Type | Status Code | Content Type | +| ------------------- | -------------------------------------- | ---------------- | +| errors.ErrorMessage | 400, 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ```typescript import { CodatSyncCommerce } from "@codat/sync-for-commerce"; -import { SDKValidationError } from "@codat/sync-for-commerce/sdk/models/errors"; +import { + ErrorMessage, + SDKValidationError, +} from "@codat/sync-for-commerce/sdk/models/errors"; const codatSyncCommerce = new CodatSyncCommerce({ - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - let result; - try { - result = await codatSyncCommerce.connections.getSyncFlowUrl({ - commerceKey: "", - accountingKey: "", - }); - } catch (err) { - switch (true) { - case err instanceof SDKValidationError: { - // Validation errors can be pretty-printed - console.error(err.pretty()); - // Raw value may also be inspected - console.error(err.rawValue); - return; - } - case err instanceof errors.ErrorMessage: { - console.error(err); // handle exception - return; - } - default: { - throw err; - } - } - } + let result; + try { + result = await codatSyncCommerce.connections.getSyncFlowUrl({ + commerceKey: "", + accountingKey: "", + }); // Handle the result console.log(result); + } catch (err) { + switch (true) { + case (err instanceof SDKValidationError): { + // Validation errors can be pretty-printed + console.error(err.pretty()); + // Raw value may also be inspected + console.error(err.rawValue); + return; + } + case (err instanceof ErrorMessage): { + // Handle err.data$: ErrorMessageData + console.error(err); + return; + } + default: { + throw err; + } + } + } } run(); ``` + +Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted string since validation errors can list many issues and the plain error string may be difficult read when debugging. ## Server Selection -### Select Server by Index - -You can override the default server globally by passing a server index to the `serverIdx` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers: - -| # | Server | Variables | -| - | ------ | --------- | -| 0 | `https://api.codat.io` | None | - -```typescript -import { CodatSyncCommerce } from "@codat/sync-for-commerce"; - -const codatSyncCommerce = new CodatSyncCommerce({ - serverIdx: 0, - authHeader: "Basic BASE_64_ENCODED(API_KEY)", -}); - -async function run() { - const result = await codatSyncCommerce.connections.getSyncFlowUrl({ - commerceKey: "", - accountingKey: "", - }); - - // Handle the result - console.log(result); -} - -run(); - -``` - - ### Override Server URL Per-Client -The default server can also be overridden globally by passing a URL to the `serverURL` optional parameter when initializing the SDK client instance. For example: - +The default server can also be overridden globally by passing a URL to the `serverURL: string` optional parameter when initializing the SDK client instance. For example: ```typescript import { CodatSyncCommerce } from "@codat/sync-for-commerce"; const codatSyncCommerce = new CodatSyncCommerce({ - serverURL: "https://api.codat.io", - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + serverURL: "https://api.codat.io", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await codatSyncCommerce.connections.getSyncFlowUrl({ - commerceKey: "", - accountingKey: "", - }); + const result = await codatSyncCommerce.connections.getSyncFlowUrl({ + commerceKey: "", + accountingKey: "", + }); - // Handle the result - console.log(result); + // Handle the result + console.log(result); } run(); @@ -359,26 +430,26 @@ const sdk = new CodatSyncCommerce({ httpClient }); This SDK supports the following security scheme globally: -| Name | Type | Scheme | -| ------------ | ------------ | ------------ | -| `authHeader` | apiKey | API key | +| Name | Type | Scheme | +| ------------ | ------ | ------- | +| `authHeader` | apiKey | API key | To authenticate with the API the `authHeader` parameter must be set when initializing the SDK client instance. For example: ```typescript import { CodatSyncCommerce } from "@codat/sync-for-commerce"; const codatSyncCommerce = new CodatSyncCommerce({ - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await codatSyncCommerce.connections.getSyncFlowUrl({ - commerceKey: "", - accountingKey: "", - }); + const result = await codatSyncCommerce.connections.getSyncFlowUrl({ + commerceKey: "", + accountingKey: "", + }); - // Handle the result - console.log(result); + // Handle the result + console.log(result); } run(); @@ -386,6 +457,23 @@ run(); ``` + +## Debugging + +You can setup your SDK to emit debug logs for SDK requests and responses. + +You can pass a logger that matches `console`'s interface as an SDK option. + +> [!WARNING] +> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production. + +```typescript +import { CodatSyncCommerce } from "@codat/sync-for-commerce"; + +const sdk = new CodatSyncCommerce({ debugLogger: console }); +``` + + diff --git a/sync-for-commerce/RELEASES.md b/sync-for-commerce/RELEASES.md index 228465687..2f3912731 100644 --- a/sync-for-commerce/RELEASES.md +++ b/sync-for-commerce/RELEASES.md @@ -600,4 +600,14 @@ Based on: ### Generated - [typescript v4.0.0] sync-for-commerce ### Releases -- [NPM v4.0.0] https://www.npmjs.com/package/@codat/sync-for-commerce/v/4.0.0 - sync-for-commerce \ No newline at end of file +- [NPM v4.0.0] https://www.npmjs.com/package/@codat/sync-for-commerce/v/4.0.0 - sync-for-commerce + +## 2024-11-26 15:32:32 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.446.1 (2.462.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v5.0.0] sync-for-commerce +### Releases +- [NPM v5.0.0] https://www.npmjs.com/package/@codat/sync-for-commerce/v/5.0.0 - sync-for-commerce \ No newline at end of file diff --git a/sync-for-commerce/USAGE.md b/sync-for-commerce/USAGE.md index 52de0dfd6..080389087 100644 --- a/sync-for-commerce/USAGE.md +++ b/sync-for-commerce/USAGE.md @@ -3,17 +3,17 @@ import { CodatSyncCommerce } from "@codat/sync-for-commerce"; const codatSyncCommerce = new CodatSyncCommerce({ - authHeader: "Basic BASE_64_ENCODED(API_KEY)", + authHeader: "Basic BASE_64_ENCODED(API_KEY)", }); async function run() { - const result = await codatSyncCommerce.connections.getSyncFlowUrl({ - commerceKey: "", - accountingKey: "", - }); + const result = await codatSyncCommerce.connections.getSyncFlowUrl({ + commerceKey: "", + accountingKey: "", + }); - // Handle the result - console.log(result); + // Handle the result + console.log(result); } run(); diff --git a/sync-for-commerce/docs/sdk/models/errors/errormessage.md b/sync-for-commerce/docs/sdk/models/errors/errormessage.md index 391ca1ff4..1e09d1726 100644 --- a/sync-for-commerce/docs/sdk/models/errors/errormessage.md +++ b/sync-for-commerce/docs/sdk/models/errors/errormessage.md @@ -1,7 +1,14 @@ # ErrorMessage -Your `query` parameter was not correctly formed +The request made is not valid. +## Example Usage + +```typescript +import { ErrorMessage } from "@codat/sync-for-commerce/sdk/models/errors"; + +// No examples available for this model +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/createconnectionrequest.md b/sync-for-commerce/docs/sdk/models/operations/createconnectionrequest.md index cc236eb9b..12cf0f71c 100644 --- a/sync-for-commerce/docs/sdk/models/operations/createconnectionrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/createconnectionrequest.md @@ -1,5 +1,17 @@ # CreateConnectionRequest +## Example Usage + +```typescript +import { CreateConnectionRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: CreateConnectionRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + requestBody: { + platformKey: "gbol", + }, +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/createconnectionrequestbody.md b/sync-for-commerce/docs/sdk/models/operations/createconnectionrequestbody.md index 509321abe..0ce828951 100644 --- a/sync-for-commerce/docs/sdk/models/operations/createconnectionrequestbody.md +++ b/sync-for-commerce/docs/sdk/models/operations/createconnectionrequestbody.md @@ -1,5 +1,14 @@ # CreateConnectionRequestBody +## Example Usage + +```typescript +import { CreateConnectionRequestBody } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: CreateConnectionRequestBody = { + platformKey: "gbol", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/getconfigtextsyncflowrequest.md b/sync-for-commerce/docs/sdk/models/operations/getconfigtextsyncflowrequest.md index dad7582a7..4d0bddef8 100644 --- a/sync-for-commerce/docs/sdk/models/operations/getconfigtextsyncflowrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/getconfigtextsyncflowrequest.md @@ -1,5 +1,14 @@ # GetConfigTextSyncFlowRequest +## Example Usage + +```typescript +import { GetConfigTextSyncFlowRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: GetConfigTextSyncFlowRequest = { + locale: "en-us", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/getconfigurationrequest.md b/sync-for-commerce/docs/sdk/models/operations/getconfigurationrequest.md index 7f9799be6..7d09fca1d 100644 --- a/sync-for-commerce/docs/sdk/models/operations/getconfigurationrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/getconfigurationrequest.md @@ -1,5 +1,14 @@ # GetConfigurationRequest +## Example Usage + +```typescript +import { GetConfigurationRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: GetConfigurationRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/getintegrationbrandingrequest.md b/sync-for-commerce/docs/sdk/models/operations/getintegrationbrandingrequest.md index 70dc9dcc5..849b819e7 100644 --- a/sync-for-commerce/docs/sdk/models/operations/getintegrationbrandingrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/getintegrationbrandingrequest.md @@ -1,5 +1,14 @@ # GetIntegrationBrandingRequest +## Example Usage + +```typescript +import { GetIntegrationBrandingRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: GetIntegrationBrandingRequest = { + platformKey: "gbol", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/getlastsuccessfulsyncrequest.md b/sync-for-commerce/docs/sdk/models/operations/getlastsuccessfulsyncrequest.md index 15cb06c91..3e655f6ee 100644 --- a/sync-for-commerce/docs/sdk/models/operations/getlastsuccessfulsyncrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/getlastsuccessfulsyncrequest.md @@ -1,5 +1,14 @@ # GetLastSuccessfulSyncRequest +## Example Usage + +```typescript +import { GetLastSuccessfulSyncRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: GetLastSuccessfulSyncRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/getlatestsyncrequest.md b/sync-for-commerce/docs/sdk/models/operations/getlatestsyncrequest.md index 5866a798b..c151566fc 100644 --- a/sync-for-commerce/docs/sdk/models/operations/getlatestsyncrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/getlatestsyncrequest.md @@ -1,5 +1,14 @@ # GetLatestSyncRequest +## Example Usage + +```typescript +import { GetLatestSyncRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: GetLatestSyncRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/getsyncbyidrequest.md b/sync-for-commerce/docs/sdk/models/operations/getsyncbyidrequest.md index 0e88edc1d..2f0584427 100644 --- a/sync-for-commerce/docs/sdk/models/operations/getsyncbyidrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/getsyncbyidrequest.md @@ -1,5 +1,15 @@ # GetSyncByIdRequest +## Example Usage + +```typescript +import { GetSyncByIdRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: GetSyncByIdRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + syncId: "6fb40d5e-b13e-11ed-afa1-0242ac120002", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/getsyncflowurlrequest.md b/sync-for-commerce/docs/sdk/models/operations/getsyncflowurlrequest.md index 88593f605..96645331e 100644 --- a/sync-for-commerce/docs/sdk/models/operations/getsyncflowurlrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/getsyncflowurlrequest.md @@ -1,5 +1,15 @@ # GetSyncFlowUrlRequest +## Example Usage + +```typescript +import { GetSyncFlowUrlRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: GetSyncFlowUrlRequest = { + commerceKey: "", + accountingKey: "", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/getsyncstatusrequest.md b/sync-for-commerce/docs/sdk/models/operations/getsyncstatusrequest.md index 12d25a448..2aeb45766 100644 --- a/sync-for-commerce/docs/sdk/models/operations/getsyncstatusrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/getsyncstatusrequest.md @@ -1,5 +1,14 @@ # GetSyncStatusRequest +## Example Usage + +```typescript +import { GetSyncStatusRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: GetSyncStatusRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/getvisibleaccountsrequest.md b/sync-for-commerce/docs/sdk/models/operations/getvisibleaccountsrequest.md index 84ab12ba3..e9c44d37c 100644 --- a/sync-for-commerce/docs/sdk/models/operations/getvisibleaccountsrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/getvisibleaccountsrequest.md @@ -1,5 +1,15 @@ # GetVisibleAccountsRequest +## Example Usage + +```typescript +import { GetVisibleAccountsRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: GetVisibleAccountsRequest = { + clientId: "2f864c79-0999-4fa5-a6b0-aa325597f132", + platformKey: "gbol", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/listcompaniesrequest.md b/sync-for-commerce/docs/sdk/models/operations/listcompaniesrequest.md index fd35ced3f..b643d5ab9 100644 --- a/sync-for-commerce/docs/sdk/models/operations/listcompaniesrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/listcompaniesrequest.md @@ -1,5 +1,17 @@ # ListCompaniesRequest +## Example Usage + +```typescript +import { ListCompaniesRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: ListCompaniesRequest = { + page: 1, + pageSize: 100, + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + orderBy: "-modifiedDate", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/listconnectionsrequest.md b/sync-for-commerce/docs/sdk/models/operations/listconnectionsrequest.md index 562bbba8c..98e4ae6ec 100644 --- a/sync-for-commerce/docs/sdk/models/operations/listconnectionsrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/listconnectionsrequest.md @@ -1,5 +1,18 @@ # ListConnectionsRequest +## Example Usage + +```typescript +import { ListConnectionsRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: ListConnectionsRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + page: 1, + pageSize: 100, + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + orderBy: "-modifiedDate", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/listintegrationsrequest.md b/sync-for-commerce/docs/sdk/models/operations/listintegrationsrequest.md index 754b2b249..a68eab8cf 100644 --- a/sync-for-commerce/docs/sdk/models/operations/listintegrationsrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/listintegrationsrequest.md @@ -1,5 +1,17 @@ # ListIntegrationsRequest +## Example Usage + +```typescript +import { ListIntegrationsRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: ListIntegrationsRequest = { + page: 1, + pageSize: 100, + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + orderBy: "-modifiedDate", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/listsyncsrequest.md b/sync-for-commerce/docs/sdk/models/operations/listsyncsrequest.md index 29cf39b8a..c287b2afc 100644 --- a/sync-for-commerce/docs/sdk/models/operations/listsyncsrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/listsyncsrequest.md @@ -1,5 +1,14 @@ # ListSyncsRequest +## Example Usage + +```typescript +import { ListSyncsRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: ListSyncsRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/requestsyncfordaterangerequest.md b/sync-for-commerce/docs/sdk/models/operations/requestsyncfordaterangerequest.md index dfc6cd79f..3b5ebb27b 100644 --- a/sync-for-commerce/docs/sdk/models/operations/requestsyncfordaterangerequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/requestsyncfordaterangerequest.md @@ -1,5 +1,20 @@ # RequestSyncForDateRangeRequest +## Example Usage + +```typescript +import { RequestSyncForDateRangeRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: RequestSyncForDateRangeRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + syncRange: { + dateRange: { + start: "2022-10-23T00:00:00Z", + finish: "2022-10-23T00:00:00Z", + }, + }, +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/requestsyncrequest.md b/sync-for-commerce/docs/sdk/models/operations/requestsyncrequest.md index 8816fff3f..d4ac67dc6 100644 --- a/sync-for-commerce/docs/sdk/models/operations/requestsyncrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/requestsyncrequest.md @@ -1,5 +1,17 @@ # RequestSyncRequest +## Example Usage + +```typescript +import { RequestSyncRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: RequestSyncRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + syncToLatestArgs: { + syncTo: "2022-10-23T00:00:00Z", + }, +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/setconfigurationrequest.md b/sync-for-commerce/docs/sdk/models/operations/setconfigurationrequest.md index 46feb81b2..695b6e54a 100644 --- a/sync-for-commerce/docs/sdk/models/operations/setconfigurationrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/setconfigurationrequest.md @@ -1,5 +1,14 @@ # SetConfigurationRequest +## Example Usage + +```typescript +import { SetConfigurationRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: SetConfigurationRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/updateconfigtextsyncflowrequest.md b/sync-for-commerce/docs/sdk/models/operations/updateconfigtextsyncflowrequest.md index f9e46618b..ffd690581 100644 --- a/sync-for-commerce/docs/sdk/models/operations/updateconfigtextsyncflowrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/updateconfigtextsyncflowrequest.md @@ -1,5 +1,14 @@ # UpdateConfigTextSyncFlowRequest +## Example Usage + +```typescript +import { UpdateConfigTextSyncFlowRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: UpdateConfigTextSyncFlowRequest = { + locale: "en-us", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/updateconnectionauthorizationrequest.md b/sync-for-commerce/docs/sdk/models/operations/updateconnectionauthorizationrequest.md index 5860ae209..7fb28541a 100644 --- a/sync-for-commerce/docs/sdk/models/operations/updateconnectionauthorizationrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/updateconnectionauthorizationrequest.md @@ -1,5 +1,15 @@ # UpdateConnectionAuthorizationRequest +## Example Usage + +```typescript +import { UpdateConnectionAuthorizationRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: UpdateConnectionAuthorizationRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/updateconnectionrequest.md b/sync-for-commerce/docs/sdk/models/operations/updateconnectionrequest.md index 37ce5b89e..456d931a1 100644 --- a/sync-for-commerce/docs/sdk/models/operations/updateconnectionrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/updateconnectionrequest.md @@ -1,5 +1,15 @@ # UpdateConnectionRequest +## Example Usage + +```typescript +import { UpdateConnectionRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: UpdateConnectionRequest = { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/operations/updatevisibleaccountssyncflowrequest.md b/sync-for-commerce/docs/sdk/models/operations/updatevisibleaccountssyncflowrequest.md index b110c6983..6a1b8373e 100644 --- a/sync-for-commerce/docs/sdk/models/operations/updatevisibleaccountssyncflowrequest.md +++ b/sync-for-commerce/docs/sdk/models/operations/updatevisibleaccountssyncflowrequest.md @@ -1,5 +1,14 @@ # UpdateVisibleAccountsSyncFlowRequest +## Example Usage + +```typescript +import { UpdateVisibleAccountsSyncFlowRequest } from "@codat/sync-for-commerce/sdk/models/operations"; + +let value: UpdateVisibleAccountsSyncFlowRequest = { + platformKey: "gbol", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/accountconfiguration.md b/sync-for-commerce/docs/sdk/models/shared/accountconfiguration.md index d75465e61..41c13b397 100644 --- a/sync-for-commerce/docs/sdk/models/shared/accountconfiguration.md +++ b/sync-for-commerce/docs/sdk/models/shared/accountconfiguration.md @@ -2,6 +2,19 @@ G/L account object for configuration. +## Example Usage + +```typescript +import { AccountConfiguration } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: AccountConfiguration = { + accountOptions: [ + { + classification: "Bank Nominal", + }, + ], +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/accountconfigurationoption.md b/sync-for-commerce/docs/sdk/models/shared/accountconfigurationoption.md index b166dc00d..2c4cd2d77 100644 --- a/sync-for-commerce/docs/sdk/models/shared/accountconfigurationoption.md +++ b/sync-for-commerce/docs/sdk/models/shared/accountconfigurationoption.md @@ -1,5 +1,14 @@ # AccountConfigurationOption +## Example Usage + +```typescript +import { AccountConfigurationOption } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: AccountConfigurationOption = { + classification: "Bank Nominal", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/branding.md b/sync-for-commerce/docs/sdk/models/shared/branding.md index f7f74006e..84e7891f0 100644 --- a/sync-for-commerce/docs/sdk/models/shared/branding.md +++ b/sync-for-commerce/docs/sdk/models/shared/branding.md @@ -1,5 +1,46 @@ # Branding +## Example Usage + +```typescript +import { Branding } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: Branding = { + logo: { + full: { + image: { + src: + "https://static.codat.io/public/officialLogos/Full/8A156A5A-39CB-4F9D-856E-76EF9B9A9607.png", + alt: "xero full icon", + }, + }, + square: { + image: { + src: + "https://static.codat.io/public/officialLogos/Square/8A156A5A-39CB-4F9D-856E-76EF9B2W3607.png", + alt: "xero square icon", + }, + }, + }, + button: { + default: { + image: { + src: + "https://static.codat.io/public/officialButtons/Full/8A156A5A-39CB-4F9D-856E-76EF9Q7A9607.png", + alt: "xero default button icon", + }, + }, + hover: { + image: { + src: + "https://static.codat.io/public/officialLogos/Full/8A156A5A-39CB-4F9D-856E-76EF9B9A9607.png", + alt: "xero hover button icon", + }, + }, + }, + sourceId: "35b92968-9851-4095-ad60-395c95cbcba4", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/brandingbutton.md b/sync-for-commerce/docs/sdk/models/shared/brandingbutton.md index f8679627b..a5f317b5b 100644 --- a/sync-for-commerce/docs/sdk/models/shared/brandingbutton.md +++ b/sync-for-commerce/docs/sdk/models/shared/brandingbutton.md @@ -2,6 +2,13 @@ Button branding references. +## Example Usage + +```typescript +import { BrandingButton } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: BrandingButton = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/brandingimage.md b/sync-for-commerce/docs/sdk/models/shared/brandingimage.md index 10cdd1a76..6e639f83a 100644 --- a/sync-for-commerce/docs/sdk/models/shared/brandingimage.md +++ b/sync-for-commerce/docs/sdk/models/shared/brandingimage.md @@ -1,5 +1,12 @@ # BrandingImage +## Example Usage + +```typescript +import { BrandingImage } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: BrandingImage = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/brandinglogo.md b/sync-for-commerce/docs/sdk/models/shared/brandinglogo.md index 942efa717..b1b09a387 100644 --- a/sync-for-commerce/docs/sdk/models/shared/brandinglogo.md +++ b/sync-for-commerce/docs/sdk/models/shared/brandinglogo.md @@ -2,6 +2,13 @@ Logo branding references. +## Example Usage + +```typescript +import { BrandingLogo } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: BrandingLogo = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/commerceconfiguration.md b/sync-for-commerce/docs/sdk/models/shared/commerceconfiguration.md index 3ccfdd7d3..f0ec53ad4 100644 --- a/sync-for-commerce/docs/sdk/models/shared/commerceconfiguration.md +++ b/sync-for-commerce/docs/sdk/models/shared/commerceconfiguration.md @@ -1,5 +1,60 @@ # CommerceConfiguration +## Example Usage + +```typescript +import { CommerceConfiguration } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: CommerceConfiguration = { + sales: { + accounts: { + "key": { + accountOptions: [ + { + classification: "Bank Nominal", + }, + ], + }, + }, + invoiceStatus: { + selectedInvoiceStatus: "Submitted", + }, + }, + payments: { + accounts: { + "key": { + accountOptions: [ + { + classification: "Bank Nominal", + }, + ], + }, + }, + }, + newPayments: { + accounts: { + "key": { + accountOptions: [ + { + classification: "Bank Nominal", + }, + ], + }, + }, + }, + fees: { + accounts: { + "key": { + accountOptions: [ + { + classification: "Bank Nominal", + }, + ], + }, + }, + }, +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/companies.md b/sync-for-commerce/docs/sdk/models/shared/companies.md index 40adb0609..7cb5c7094 100644 --- a/sync-for-commerce/docs/sdk/models/shared/companies.md +++ b/sync-for-commerce/docs/sdk/models/shared/companies.md @@ -1,5 +1,24 @@ # Companies +## Example Usage + +```typescript +import { Companies } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: Companies = { + pageNumber: 1, + pageSize: 10, + totalResults: 1, + links: { + self: { + href: "/companies/{id}/data/{dataType}", + }, + current: { + href: "/companies/{id}/data/{dataType}?page=1&pageSize=10", + }, + }, +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/company.md b/sync-for-commerce/docs/sdk/models/shared/company.md index fe2ff3aa4..87229c435 100644 --- a/sync-for-commerce/docs/sdk/models/shared/company.md +++ b/sync-for-commerce/docs/sdk/models/shared/company.md @@ -6,6 +6,40 @@ Typically each company is one of your customers. When you create a company, you can specify a `name` and we will automatically generate a unique `id` for the company. You can also add a `description` to store any additional information about the company. +## Example Usage + +```typescript +import { Company } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: Company = { + id: "0498e921-9b53-4396-a412-4f2f5983b0a2", + name: "string", + redirect: + "https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739", + lastSync: "2022-01-01T12:00:00.000Z", + created: "2022-01-01T12:00:00.000Z", + createdByUserName: "string", + tags: { + "region": "us", + "uid": "f6b0c253-16c7-4da1-a0c5-9c871e9c9d6c", + }, + dataConnections: [ + { + id: "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", + integrationId: "bf083d72-62c7-493e-aec9-81b4dbba7e2c", + integrationKey: "dfxm", + sourceId: "bdd831ce-eebd-4896-89a7-20e5ee8989ee", + sourceType: "Banking", + platformName: "Basiq", + linkUrl: + "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", + status: "Linked", + lastSync: "2022-10-27T10:22:43.6464237Z", + created: "2022-10-27T09:53:29Z", + }, + ], +}; +``` ## Fields @@ -14,10 +48,12 @@ When you create a company, you can specify a `name` and we will automatically ge | `id` | *string* | :heavy_check_mark: | Unique identifier for your SMB in Codat. | 8a210b68-6988-11ed-a1eb-0242ac120002 | | `name` | *string* | :heavy_check_mark: | The name of the company | Codat Ltd. | | `description` | *string* | :heavy_minus_sign: | Additional information about the company. This can be used to store foreign IDs, references, etc. | Requested early access to the new financing scheme. | -| ~~`platform`~~ | *string* | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

`platformKeys` name used when creating the company. | Xero | | `redirect` | *string* | :heavy_check_mark: | The `redirect` [Link URL](https://docs.codat.io/auth-flow/authorize-hosted-link) enabling the customer to start their auth flow journey for the company. | https://link.codat.io/company/27628208-459c-46a2-a705-5641ce25f739 | | `lastSync` | *string* | :heavy_minus_sign: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | | `created` | *string* | :heavy_minus_sign: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | | `createdByUserName` | *string* | :heavy_minus_sign: | Name of user that created the company in Codat. | | -| `dataConnections` | [shared.Connection](../../../sdk/models/shared/connection.md)[] | :heavy_minus_sign: | N/A | | -| `groups` | [shared.GroupReference](../../../sdk/models/shared/groupreference.md)[] | :heavy_minus_sign: | An array of groups the company has been assigned to. | | \ No newline at end of file +| `products` | *string*[] | :heavy_minus_sign: | An array of products that are currently enabled for the company. | | +| `tags` | Record | :heavy_minus_sign: | A collection of user-defined key-value pairs that store custom metadata against the company. | | +| `referenceParentCompany` | [shared.CompanyReference](../../../sdk/models/shared/companyreference.md) | :heavy_minus_sign: | N/A | | +| `referenceSubsidiaryCompanies` | [shared.CompanyReference](../../../sdk/models/shared/companyreference.md)[] | :heavy_minus_sign: | A list of subsidiary companies owned or controlled by this entity. Empty if the company has no children. | | +| `dataConnections` | [shared.Connection](../../../sdk/models/shared/connection.md)[] | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/companyreference.md b/sync-for-commerce/docs/sdk/models/shared/companyreference.md new file mode 100644 index 000000000..ecfde7fab --- /dev/null +++ b/sync-for-commerce/docs/sdk/models/shared/companyreference.md @@ -0,0 +1,23 @@ +# CompanyReference + +## Example Usage + +```typescript +import { CompanyReference } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: CompanyReference = { + id: "8a210b68-6988-11ed-a1eb-0242ac120002", + name: "Codat Ltd.", + description: "Requested early access to the new financing scheme.", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | +| `id` | *string* | :heavy_minus_sign: | Unique identifier for your SMB in Codat. | 8a210b68-6988-11ed-a1eb-0242ac120002 | +| `name` | *string* | :heavy_minus_sign: | The name of the company | Codat Ltd. | +| `description` | *string* | :heavy_minus_sign: | Additional information about the company. This can be used to store foreign IDs, references, etc. | Requested early access to the new financing scheme. | +| `links` | [shared.CompanyReferenceLinks](../../../sdk/models/shared/companyreferencelinks.md) | :heavy_minus_sign: | A collection of links for the company. | | +| `tags` | Record | :heavy_minus_sign: | A collection of user-defined key-value pairs that store custom metadata against the company. | | \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/companyreferencelinks.md b/sync-for-commerce/docs/sdk/models/shared/companyreferencelinks.md new file mode 100644 index 000000000..3744a094f --- /dev/null +++ b/sync-for-commerce/docs/sdk/models/shared/companyreferencelinks.md @@ -0,0 +1,17 @@ +# CompanyReferenceLinks + +A collection of links for the company. + +## Example Usage + +```typescript +import { CompanyReferenceLinks } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: CompanyReferenceLinks = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------- | --------------------------------------- | --------------------------------------- | --------------------------------------- | +| `portal` | *string* | :heavy_minus_sign: | Link to the company page in the portal. | \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/companysyncstatus.md b/sync-for-commerce/docs/sdk/models/shared/companysyncstatus.md index b371522ef..7ddc92f70 100644 --- a/sync-for-commerce/docs/sdk/models/shared/companysyncstatus.md +++ b/sync-for-commerce/docs/sdk/models/shared/companysyncstatus.md @@ -1,5 +1,18 @@ # CompanySyncStatus +## Example Usage + +```typescript +import { CompanySyncStatus } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: CompanySyncStatus = { + companyId: "d4d73051-ed31-42b6-99f6-d288cd940992", + syncId: "a6a22aff-a43a-411d-a910-2dae73217cce", + syncStatusCode: 2000, + syncStatus: "NotStarted", + syncUtc: "2022-10-23T00:00:00Z", +}; +``` ## Fields @@ -8,7 +21,7 @@ | `companyId` | *string* | :heavy_minus_sign: | Unique identifier for your SMB in Codat. | d4d73051-ed31-42b6-99f6-d288cd940992 | | `syncId` | *string* | :heavy_minus_sign: | Unique identifier of the sync. | a6a22aff-a43a-411d-a910-2dae73217cce | | `syncStatusCode` | *number* | :heavy_minus_sign: | Status code of the sync. | 2000 | -| `syncStatus` | *string* | :heavy_minus_sign: | Text status of the sync. | Completed | +| `syncStatus` | *string* | :heavy_minus_sign: | Text status of the sync. | Complete | | `errorMessage` | *string* | :heavy_minus_sign: | Error message of the sync. | | | `syncExceptionMessage` | *string* | :heavy_minus_sign: | Exception message of the sync. | | | `syncUtc` | *string* | :heavy_minus_sign: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | diff --git a/sync-for-commerce/docs/sdk/models/shared/configuration.md b/sync-for-commerce/docs/sdk/models/shared/configuration.md index c032c8c52..e0ef4e906 100644 --- a/sync-for-commerce/docs/sdk/models/shared/configuration.md +++ b/sync-for-commerce/docs/sdk/models/shared/configuration.md @@ -1,12 +1,73 @@ # Configuration +## Example Usage + +```typescript +import { Configuration } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: Configuration = { + schedule: { + startDate: "2022-10-23T00:00:00Z", + timeZone: "Europe/London", + }, + configuration: { + sales: { + accounts: { + "key": { + accountOptions: [ + { + classification: "Bank Nominal", + }, + ], + }, + }, + invoiceStatus: { + selectedInvoiceStatus: "Submitted", + }, + }, + payments: { + accounts: { + "key": { + accountOptions: [ + { + classification: "Bank Nominal", + }, + ], + }, + }, + }, + newPayments: { + accounts: { + "key": { + accountOptions: [ + { + classification: "Bank Nominal", + }, + ], + }, + }, + }, + fees: { + accounts: { + "key": { + accountOptions: [ + { + classification: "Bank Nominal", + }, + ], + }, + }, + }, + }, +}; +``` ## Fields | Field | Type | Required | Description | | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | | `companyId` | *any* | :heavy_minus_sign: | Unique identifier for a company. | -| `accountingSoftwareCompanyName` | *string* | :heavy_minus_sign: | The company name defined in the accounting platform. | +| `accountingSoftwareCompanyName` | *string* | :heavy_minus_sign: | The company name defined in the accounting software. | | `enable` | *boolean* | :heavy_minus_sign: | True if Sync for Commerce is enabled for the company. | | `configured` | *boolean* | :heavy_minus_sign: | True if Sync for Commerce has been configured for the company. | | `schedule` | [shared.SyncSchedule](../../../sdk/models/shared/syncschedule.md) | :heavy_minus_sign: | N/A | diff --git a/sync-for-commerce/docs/sdk/models/shared/configurationmapsettings.md b/sync-for-commerce/docs/sdk/models/shared/configurationmapsettings.md index 468ab0228..527283b71 100644 --- a/sync-for-commerce/docs/sdk/models/shared/configurationmapsettings.md +++ b/sync-for-commerce/docs/sdk/models/shared/configurationmapsettings.md @@ -1,8 +1,15 @@ # ConfigurationMapSettings +## Example Usage + +```typescript +import { ConfigurationMapSettings } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: ConfigurationMapSettings = {}; +``` ## Fields | Field | Type | Required | Description | | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | -| `outputFormat` | [shared.OutputFormat](../../../sdk/models/shared/outputformat.md) | :heavy_minus_sign: | The format commerce transactions are stored in the accounting platform. | \ No newline at end of file +| `outputFormat` | [shared.OutputFormat](../../../sdk/models/shared/outputformat.md) | :heavy_minus_sign: | The format commerce transactions are stored in the accounting software. | \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/configurationoption.md b/sync-for-commerce/docs/sdk/models/shared/configurationoption.md index a1c8ca2d7..acda78880 100644 --- a/sync-for-commerce/docs/sdk/models/shared/configurationoption.md +++ b/sync-for-commerce/docs/sdk/models/shared/configurationoption.md @@ -1,5 +1,12 @@ # ConfigurationOption +## Example Usage + +```typescript +import { ConfigurationOption } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: ConfigurationOption = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/connection.md b/sync-for-commerce/docs/sdk/models/shared/connection.md index 96ab52eb9..b02178b24 100644 --- a/sync-for-commerce/docs/sdk/models/shared/connection.md +++ b/sync-for-commerce/docs/sdk/models/shared/connection.md @@ -11,6 +11,25 @@ Any combination of accounting, banking, and commerce data connections is allowed Before you can use a data connection to pull or push data, the company must grant you access to their business data by [linking the connection](https://docs.codat.io/auth-flow/overview). +## Example Usage + +```typescript +import { Connection } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: Connection = { + id: "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", + integrationId: "bf083d72-62c7-493e-aec9-81b4dbba7e2c", + integrationKey: "dfxm", + sourceId: "bdd831ce-eebd-4896-89a7-20e5ee8989ee", + sourceType: "Banking", + platformName: "Basiq", + linkUrl: + "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", + status: "Linked", + lastSync: "2022-10-27T10:22:43.6464237Z", + created: "2022-10-27T09:53:29Z", +}; +``` ## Fields @@ -27,5 +46,4 @@ Before you can use a data connection to pull or push data, the company must gran | `lastSync` | *string* | :heavy_minus_sign: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | | `created` | *string* | :heavy_check_mark: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | | `dataConnectionErrors` | [shared.DataConnectionError](../../../sdk/models/shared/dataconnectionerror.md)[] | :heavy_minus_sign: | N/A | | -| `connectionInfo` | Record | :heavy_minus_sign: | N/A | | -| `additionalProperties` | *any* | :heavy_minus_sign: | N/A | | \ No newline at end of file +| `connectionInfo` | Record | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/connections.md b/sync-for-commerce/docs/sdk/models/shared/connections.md index 2e78b5f60..024a3b708 100644 --- a/sync-for-commerce/docs/sdk/models/shared/connections.md +++ b/sync-for-commerce/docs/sdk/models/shared/connections.md @@ -1,5 +1,24 @@ # Connections +## Example Usage + +```typescript +import { Connections } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: Connections = { + pageNumber: 1, + pageSize: 10, + totalResults: 1, + links: { + self: { + href: "/companies/{id}/data/{dataType}", + }, + current: { + href: "/companies/{id}/data/{dataType}?page=1&pageSize=10", + }, + }, +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/connectionwebhook.md b/sync-for-commerce/docs/sdk/models/shared/connectionwebhook.md new file mode 100644 index 000000000..983a99bba --- /dev/null +++ b/sync-for-commerce/docs/sdk/models/shared/connectionwebhook.md @@ -0,0 +1,42 @@ +# ConnectionWebhook + +## Example Usage + +```typescript +import { ConnectionWebhook } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: ConnectionWebhook = { + id: "ba29118f-5406-4e59-b05c-ba307ca38d01", + eventType: "connection.deleted", + generatedDate: "2022-10-23T00:00:00Z", + payload: { + referenceCompany: { + id: "8a210b68-6988-11ed-a1eb-0242ac120002", + name: "Codat Ltd.", + description: "Requested early access to the new financing scheme.", + }, + connection: { + id: "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", + integrationId: "bf083d72-62c7-493e-aec9-81b4dbba7e2c", + integrationKey: "dfxm", + sourceId: "bdd831ce-eebd-4896-89a7-20e5ee8989ee", + sourceType: "Banking", + platformName: "Basiq", + linkUrl: + "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", + status: "Linked", + lastSync: "2022-10-27T10:22:43.6464237Z", + created: "2022-10-27T09:53:29Z", + }, + }, +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | *string* | :heavy_minus_sign: | Unique identifier of the event. | ba29118f-5406-4e59-b05c-ba307ca38d01 | +| `eventType` | *string* | :heavy_minus_sign: | The type of event. | connection.created | +| `generatedDate` | *string* | :heavy_minus_sign: | In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:

```
2020-10-08T22:40:50Z
2021-01-01T00:00:00
```



When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:

- Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
- Unqualified local time: `2021-11-15T01:00:00`
- UTC time offsets: `2021-11-15T01:00:00-05:00`

> Time zones
>
> Not all dates from Codat will contain information about time zones.
> Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. | 2022-10-23 00:00:00 +0000 UTC | +| `payload` | [shared.ConnectionWebhookPayload](../../../sdk/models/shared/connectionwebhookpayload.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/connectionwebhookpayload.md b/sync-for-commerce/docs/sdk/models/shared/connectionwebhookpayload.md new file mode 100644 index 000000000..96298a0e8 --- /dev/null +++ b/sync-for-commerce/docs/sdk/models/shared/connectionwebhookpayload.md @@ -0,0 +1,35 @@ +# ConnectionWebhookPayload + +## Example Usage + +```typescript +import { ConnectionWebhookPayload } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: ConnectionWebhookPayload = { + referenceCompany: { + id: "8a210b68-6988-11ed-a1eb-0242ac120002", + name: "Codat Ltd.", + description: "Requested early access to the new financing scheme.", + }, + connection: { + id: "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", + integrationId: "bf083d72-62c7-493e-aec9-81b4dbba7e2c", + integrationKey: "dfxm", + sourceId: "bdd831ce-eebd-4896-89a7-20e5ee8989ee", + sourceType: "Banking", + platformName: "Basiq", + linkUrl: + "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", + status: "Linked", + lastSync: "2022-10-27T10:22:43.6464237Z", + created: "2022-10-27T09:53:29Z", + }, +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `referenceCompany` | [shared.CompanyReference](../../../sdk/models/shared/companyreference.md) | :heavy_minus_sign: | N/A | | +| `connection` | [shared.Connection](../../../sdk/models/shared/connection.md) | :heavy_minus_sign: | A connection represents a [company's](https://docs.codat.io/sync-for-sync-for-commerce-api#/schemas/Company) connection to a data source and allows you to synchronize data (pull and/or push) with that source.

A company can have multiple data connections depending on the type of data source it is connecting to. For example, a single company can link to:

- [Accounting data](https://docs.codat.io/accounting-api/overview) - 1 active connection.
- [Banking data](https://docs.codat.io/banking-api/overview) - Multiple active connections.
- [Commerce data](https://docs.codat.io/commerce-api/overview) - Multiple active connections.
Any combination of accounting, banking, and commerce data connections is allowed.

Before you can use a data connection to pull or push data, the company must grant you access to their business data by [linking the connection](https://docs.codat.io/auth-flow/overview). | {
"id": "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd",
"integrationId": "bf083d72-62c7-493e-aec9-81b4dbba7e2c",
"integrationKey": "dfxm",
"sourceId": "bdd831ce-eebd-4896-89a7-20e5ee8989ee",
"platformName": "Basiq",
"linkUrl": "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start",
"status": "Linked",
"lastSync": "2022-10-27T10:22:43.6464237Z",
"created": "2022-10-27T09:53:29Z",
"sourceType": "Banking"
} | \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/createcompany.md b/sync-for-commerce/docs/sdk/models/shared/createcompany.md index 44abf0ab0..db3b20b35 100644 --- a/sync-for-commerce/docs/sdk/models/shared/createcompany.md +++ b/sync-for-commerce/docs/sdk/models/shared/createcompany.md @@ -1,5 +1,15 @@ # CreateCompany +## Example Usage + +```typescript +import { CreateCompany } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: CreateCompany = { + name: "Bank of Dave", + description: "Requested early access to the new financing scheme.", +}; +``` ## Fields @@ -7,4 +17,4 @@ | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | | `name` | *string* | :heavy_check_mark: | Name of company being connected. | Bank of Dave | | `description` | *string* | :heavy_minus_sign: | Additional information about the company. This can be used to store foreign IDs, references, etc. | Requested early access to the new financing scheme. | -| `groups` | [shared.Items](../../../sdk/models/shared/items.md)[] | :heavy_minus_sign: | Reference to the groups that the company is assigned to. | | \ No newline at end of file +| `tags` | Record | :heavy_minus_sign: | A collection of user-defined key-value pairs that store custom metadata against the company. | | \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/dataconnectionerror.md b/sync-for-commerce/docs/sdk/models/shared/dataconnectionerror.md index 265093f1d..8cf91c002 100644 --- a/sync-for-commerce/docs/sdk/models/shared/dataconnectionerror.md +++ b/sync-for-commerce/docs/sdk/models/shared/dataconnectionerror.md @@ -1,5 +1,15 @@ # DataConnectionError +## Example Usage + +```typescript +import { DataConnectionError } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: DataConnectionError = { + erroredOnUtc: "2022-10-23T00:00:00Z", + resolvedOnUtc: "2022-10-23T00:00:00Z", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/dataconnectionstatus.md b/sync-for-commerce/docs/sdk/models/shared/dataconnectionstatus.md index 5d13bea51..8f4844d15 100644 --- a/sync-for-commerce/docs/sdk/models/shared/dataconnectionstatus.md +++ b/sync-for-commerce/docs/sdk/models/shared/dataconnectionstatus.md @@ -2,12 +2,16 @@ The current authorization status of the data connection. +## Example Usage + +```typescript +import { DataConnectionStatus } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: DataConnectionStatus = "Unlinked"; +``` ## Values -| Name | Value | -| -------------- | -------------- | -| `PendingAuth` | PendingAuth | -| `Linked` | Linked | -| `Unlinked` | Unlinked | -| `Deauthorized` | Deauthorized | \ No newline at end of file +```typescript +"PendingAuth" | "Linked" | "Unlinked" | "Deauthorized" +``` \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/datatypefeature.md b/sync-for-commerce/docs/sdk/models/shared/datatypefeature.md index ca4ef02bc..2990300f2 100644 --- a/sync-for-commerce/docs/sdk/models/shared/datatypefeature.md +++ b/sync-for-commerce/docs/sdk/models/shared/datatypefeature.md @@ -2,6 +2,20 @@ Describes support for a given datatype and associated operations +## Example Usage + +```typescript +import { DataTypeFeature } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: DataTypeFeature = { + supportedFeatures: [ + { + featureType: "Get", + featureState: "Release", + }, + ], +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/datatypes.md b/sync-for-commerce/docs/sdk/models/shared/datatypes.md index 3ea6fa56e..51f221113 100644 --- a/sync-for-commerce/docs/sdk/models/shared/datatypes.md +++ b/sync-for-commerce/docs/sdk/models/shared/datatypes.md @@ -2,51 +2,16 @@ Available data types +## Example Usage + +```typescript +import { DataTypes } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: DataTypes = "invoices"; +``` ## Values -| Name | Value | -| ------------------------------ | ------------------------------ | -| `AccountTransactions` | accountTransactions | -| `BalanceSheet` | balanceSheet | -| `BankAccounts` | bankAccounts | -| `BankTransactions` | bankTransactions | -| `BillCreditNotes` | billCreditNotes | -| `BillPayments` | billPayments | -| `Bills` | bills | -| `CashFlowStatement` | cashFlowStatement | -| `ChartOfAccounts` | chartOfAccounts | -| `Company` | company | -| `CreditNotes` | creditNotes | -| `Customers` | customers | -| `DirectCosts` | directCosts | -| `DirectIncomes` | directIncomes | -| `Invoices` | invoices | -| `ItemReceipts` | itemReceipts | -| `Items` | items | -| `JournalEntries` | journalEntries | -| `Journals` | journals | -| `PaymentMethods` | paymentMethods | -| `Payments` | payments | -| `ProfitAndLoss` | profitAndLoss | -| `PurchaseOrders` | purchaseOrders | -| `SalesOrders` | salesOrders | -| `Suppliers` | suppliers | -| `TaxRates` | taxRates | -| `TrackingCategories` | trackingCategories | -| `Transfers` | transfers | -| `BankingAccountBalances` | banking-accountBalances | -| `BankingAccounts` | banking-accounts | -| `BankingTransactionCategories` | banking-transactionCategories | -| `BankingTransactions` | banking-transactions | -| `CommerceCompanyInfo` | commerce-companyInfo | -| `CommerceCustomers` | commerce-customers | -| `CommerceDisputes` | commerce-disputes | -| `CommerceLocations` | commerce-locations | -| `CommerceOrders` | commerce-orders | -| `CommercePaymentMethods` | commerce-paymentMethods | -| `CommercePayments` | commerce-payments | -| `CommerceProductCategories` | commerce-productCategories | -| `CommerceProducts` | commerce-products | -| `CommerceTaxComponents` | commerce-taxComponents | -| `CommerceTransactions` | commerce-transactions | \ No newline at end of file +```typescript +"accountTransactions" | "balanceSheet" | "bankAccounts" | "bankTransactions" | "billCreditNotes" | "billPayments" | "bills" | "cashFlowStatement" | "chartOfAccounts" | "company" | "creditNotes" | "customers" | "directCosts" | "directIncomes" | "invoices" | "itemReceipts" | "items" | "journalEntries" | "journals" | "paymentMethods" | "payments" | "profitAndLoss" | "purchaseOrders" | "salesOrders" | "suppliers" | "taxRates" | "trackingCategories" | "transfers" | "banking-accountBalances" | "banking-accounts" | "banking-transactionCategories" | "banking-transactions" | "commerce-companyInfo" | "commerce-customers" | "commerce-disputes" | "commerce-locations" | "commerce-orders" | "commerce-paymentMethods" | "commerce-payments" | "commerce-productCategories" | "commerce-products" | "commerce-taxComponents" | "commerce-transactions" +``` \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/daterange.md b/sync-for-commerce/docs/sdk/models/shared/daterange.md index d4f8ffe75..1a5a7f727 100644 --- a/sync-for-commerce/docs/sdk/models/shared/daterange.md +++ b/sync-for-commerce/docs/sdk/models/shared/daterange.md @@ -1,5 +1,15 @@ # DateRange +## Example Usage + +```typescript +import { DateRange } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: DateRange = { + start: "2022-10-23T00:00:00Z", + finish: "2022-10-23T00:00:00Z", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/errorstatus.md b/sync-for-commerce/docs/sdk/models/shared/errorstatus.md index 9dc662553..e344274ed 100644 --- a/sync-for-commerce/docs/sdk/models/shared/errorstatus.md +++ b/sync-for-commerce/docs/sdk/models/shared/errorstatus.md @@ -2,10 +2,16 @@ The current status of a transient error. Null statuses indicate that the error is not transient. +## Example Usage + +```typescript +import { ErrorStatus } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: ErrorStatus = "Resolved"; +``` ## Values -| Name | Value | -| ---------- | ---------- | -| `Active` | Active | -| `Resolved` | Resolved | \ No newline at end of file +```typescript +"Active" | "Resolved" +``` \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/errorvalidation.md b/sync-for-commerce/docs/sdk/models/shared/errorvalidation.md index 232c51fd9..fe13c3a41 100644 --- a/sync-for-commerce/docs/sdk/models/shared/errorvalidation.md +++ b/sync-for-commerce/docs/sdk/models/shared/errorvalidation.md @@ -2,6 +2,13 @@ A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. +## Example Usage + +```typescript +import { ErrorValidation } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: ErrorValidation = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/errorvalidationitem.md b/sync-for-commerce/docs/sdk/models/shared/errorvalidationitem.md index 257d78187..c75e0b4b8 100644 --- a/sync-for-commerce/docs/sdk/models/shared/errorvalidationitem.md +++ b/sync-for-commerce/docs/sdk/models/shared/errorvalidationitem.md @@ -1,5 +1,12 @@ # ErrorValidationItem +## Example Usage + +```typescript +import { ErrorValidationItem } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: ErrorValidationItem = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/featurestate.md b/sync-for-commerce/docs/sdk/models/shared/featurestate.md index 58431e74e..65794ad76 100644 --- a/sync-for-commerce/docs/sdk/models/shared/featurestate.md +++ b/sync-for-commerce/docs/sdk/models/shared/featurestate.md @@ -2,14 +2,16 @@ The current release state of the feature. +## Example Usage + +```typescript +import { FeatureState } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: FeatureState = "Release"; +``` ## Values -| Name | Value | -| ---------------- | ---------------- | -| `Release` | Release | -| `Alpha` | Alpha | -| `Beta` | Beta | -| `Deprecated` | Deprecated | -| `NotSupported` | NotSupported | -| `NotImplemented` | NotImplemented | \ No newline at end of file +```typescript +"Release" | "Alpha" | "Beta" | "Deprecated" | "NotSupported" | "NotImplemented" +``` \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/featuretype.md b/sync-for-commerce/docs/sdk/models/shared/featuretype.md index 358892c67..b2b9386bb 100644 --- a/sync-for-commerce/docs/sdk/models/shared/featuretype.md +++ b/sync-for-commerce/docs/sdk/models/shared/featuretype.md @@ -2,18 +2,16 @@ The type of feature. +## Example Usage + +```typescript +import { FeatureType } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: FeatureType = "Get"; +``` ## Values -| Name | Value | -| -------------------- | -------------------- | -| `Get` | Get | -| `Post` | Post | -| `Categorization` | Categorization | -| `Delete` | Delete | -| `Put` | Put | -| `GetAsPdf` | GetAsPdf | -| `DownloadAttachment` | DownloadAttachment | -| `GetAttachment` | GetAttachment | -| `GetAttachments` | GetAttachments | -| `UploadAttachment` | UploadAttachment | \ No newline at end of file +```typescript +"Get" | "Post" | "Categorization" | "Delete" | "Put" | "GetAsPdf" | "DownloadAttachment" | "GetAttachment" | "GetAttachments" | "UploadAttachment" +``` \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/feesconfiguration.md b/sync-for-commerce/docs/sdk/models/shared/feesconfiguration.md index 10f7a9ef1..09dbb8e05 100644 --- a/sync-for-commerce/docs/sdk/models/shared/feesconfiguration.md +++ b/sync-for-commerce/docs/sdk/models/shared/feesconfiguration.md @@ -1,5 +1,22 @@ # FeesConfiguration +## Example Usage + +```typescript +import { FeesConfiguration } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: FeesConfiguration = { + accounts: { + "key": { + accountOptions: [ + { + classification: "Bank Nominal", + }, + ], + }, + }, +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/feessupplier.md b/sync-for-commerce/docs/sdk/models/shared/feessupplier.md index 85a2f0d58..ef05bb3b8 100644 --- a/sync-for-commerce/docs/sdk/models/shared/feessupplier.md +++ b/sync-for-commerce/docs/sdk/models/shared/feessupplier.md @@ -1,5 +1,12 @@ # FeesSupplier +## Example Usage + +```typescript +import { FeesSupplier } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: FeesSupplier = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/grouping.md b/sync-for-commerce/docs/sdk/models/shared/grouping.md index f8ec9552d..b3a71d404 100644 --- a/sync-for-commerce/docs/sdk/models/shared/grouping.md +++ b/sync-for-commerce/docs/sdk/models/shared/grouping.md @@ -1,5 +1,12 @@ # Grouping +## Example Usage + +```typescript +import { Grouping } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: Grouping = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/groupinglevels.md b/sync-for-commerce/docs/sdk/models/shared/groupinglevels.md index e8f91dc78..5149170d0 100644 --- a/sync-for-commerce/docs/sdk/models/shared/groupinglevels.md +++ b/sync-for-commerce/docs/sdk/models/shared/groupinglevels.md @@ -1,5 +1,12 @@ # GroupingLevels +## Example Usage + +```typescript +import { GroupingLevels } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: GroupingLevels = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/groupingperiod.md b/sync-for-commerce/docs/sdk/models/shared/groupingperiod.md index 42bf0c902..4c7bd4a48 100644 --- a/sync-for-commerce/docs/sdk/models/shared/groupingperiod.md +++ b/sync-for-commerce/docs/sdk/models/shared/groupingperiod.md @@ -1,5 +1,12 @@ # GroupingPeriod +## Example Usage + +```typescript +import { GroupingPeriod } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: GroupingPeriod = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/groupreference.md b/sync-for-commerce/docs/sdk/models/shared/groupreference.md deleted file mode 100644 index 8cf39ba1a..000000000 --- a/sync-for-commerce/docs/sdk/models/shared/groupreference.md +++ /dev/null @@ -1,8 +0,0 @@ -# GroupReference - - -## Fields - -| Field | Type | Required | Description | Example | -| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | -| `id` | *string* | :heavy_minus_sign: | Unique identifier for the group. | 60d2fa12-8a04-11ee-b9d1-0242ac120002 | \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/halref.md b/sync-for-commerce/docs/sdk/models/shared/halref.md index a19023707..63e680e6e 100644 --- a/sync-for-commerce/docs/sdk/models/shared/halref.md +++ b/sync-for-commerce/docs/sdk/models/shared/halref.md @@ -1,5 +1,12 @@ # HalRef +## Example Usage + +```typescript +import { HalRef } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: HalRef = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/imagereference.md b/sync-for-commerce/docs/sdk/models/shared/imagereference.md index 1213ab843..e1df2e72d 100644 --- a/sync-for-commerce/docs/sdk/models/shared/imagereference.md +++ b/sync-for-commerce/docs/sdk/models/shared/imagereference.md @@ -2,6 +2,13 @@ Image reference. +## Example Usage + +```typescript +import { ImageReference } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: ImageReference = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/integration.md b/sync-for-commerce/docs/sdk/models/shared/integration.md index 94c4c6c5b..767341a0b 100644 --- a/sync-for-commerce/docs/sdk/models/shared/integration.md +++ b/sync-for-commerce/docs/sdk/models/shared/integration.md @@ -2,6 +2,34 @@ An integration that Codat supports +## Example Usage + +```typescript +import { Integration } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: Integration = { + key: "gbol", + logoUrl: "http://example.com", + name: "Xero", + enabled: true, + sourceId: "accounting", + sourceType: "Unknown", + integrationId: "497a18ca-284e-40c0-985d-f72be35d468e", + isOfflineConnector: true, + isBeta: true, + dataProvidedBy: "string", + datatypeFeatures: [ + { + supportedFeatures: [ + { + featureType: "UploadAttachment", + featureState: "Beta", + }, + ], + }, + ], +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/integrations.md b/sync-for-commerce/docs/sdk/models/shared/integrations.md index 105260c04..de409de0f 100644 --- a/sync-for-commerce/docs/sdk/models/shared/integrations.md +++ b/sync-for-commerce/docs/sdk/models/shared/integrations.md @@ -1,5 +1,24 @@ # Integrations +## Example Usage + +```typescript +import { Integrations } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: Integrations = { + pageNumber: 1, + pageSize: 10, + totalResults: 1, + links: { + self: { + href: "/companies/{id}/data/{dataType}", + }, + current: { + href: "/companies/{id}/data/{dataType}?page=1&pageSize=10", + }, + }, +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/invoicelevelselection.md b/sync-for-commerce/docs/sdk/models/shared/invoicelevelselection.md index bf5d8f3f8..e2d1eebea 100644 --- a/sync-for-commerce/docs/sdk/models/shared/invoicelevelselection.md +++ b/sync-for-commerce/docs/sdk/models/shared/invoicelevelselection.md @@ -1,5 +1,12 @@ # InvoiceLevelSelection +## Example Usage + +```typescript +import { InvoiceLevelSelection } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: InvoiceLevelSelection = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/invoicelinelevelselection.md b/sync-for-commerce/docs/sdk/models/shared/invoicelinelevelselection.md index ff0f34262..93bcf869c 100644 --- a/sync-for-commerce/docs/sdk/models/shared/invoicelinelevelselection.md +++ b/sync-for-commerce/docs/sdk/models/shared/invoicelinelevelselection.md @@ -1,5 +1,12 @@ # InvoiceLineLevelSelection +## Example Usage + +```typescript +import { InvoiceLineLevelSelection } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: InvoiceLineLevelSelection = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/invoicestatus.md b/sync-for-commerce/docs/sdk/models/shared/invoicestatus.md index 1f65bc28c..c011a11a4 100644 --- a/sync-for-commerce/docs/sdk/models/shared/invoicestatus.md +++ b/sync-for-commerce/docs/sdk/models/shared/invoicestatus.md @@ -1,5 +1,14 @@ # InvoiceStatus +## Example Usage + +```typescript +import { InvoiceStatus } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: InvoiceStatus = { + selectedInvoiceStatus: "Submitted", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/items.md b/sync-for-commerce/docs/sdk/models/shared/items.md deleted file mode 100644 index 0998d9854..000000000 --- a/sync-for-commerce/docs/sdk/models/shared/items.md +++ /dev/null @@ -1,8 +0,0 @@ -# Items - - -## Fields - -| Field | Type | Required | Description | Example | -| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | -| `id` | *string* | :heavy_minus_sign: | Unique identifier for the group. | 60d2fa12-8a04-11ee-b9d1-0242ac120002 | \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/links.md b/sync-for-commerce/docs/sdk/models/shared/links.md index 5f0c7cf35..efb92936d 100644 --- a/sync-for-commerce/docs/sdk/models/shared/links.md +++ b/sync-for-commerce/docs/sdk/models/shared/links.md @@ -1,5 +1,19 @@ # Links +## Example Usage + +```typescript +import { Links } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: Links = { + self: { + href: "/companies", + }, + current: { + href: "/companies?page=1&pageSize=10", + }, +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/locale.md b/sync-for-commerce/docs/sdk/models/shared/locale.md index 6f9cd7f8c..87f5d47fb 100644 --- a/sync-for-commerce/docs/sdk/models/shared/locale.md +++ b/sync-for-commerce/docs/sdk/models/shared/locale.md @@ -1,9 +1,15 @@ # Locale +## Example Usage + +```typescript +import { Locale } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: Locale = "en-us"; +``` ## Values -| Name | Value | -| ------ | ------ | -| `EnUs` | en-us | -| `FrFr` | fr-fr | \ No newline at end of file +```typescript +"en-us" | "fr-fr" +``` \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/localization.md b/sync-for-commerce/docs/sdk/models/shared/localization.md index a7d456641..d7ce7b9c2 100644 --- a/sync-for-commerce/docs/sdk/models/shared/localization.md +++ b/sync-for-commerce/docs/sdk/models/shared/localization.md @@ -1,5 +1,12 @@ # Localization +## Example Usage + +```typescript +import { Localization } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: Localization = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/newpaymentsconfiguration.md b/sync-for-commerce/docs/sdk/models/shared/newpaymentsconfiguration.md index fe0f5fad2..dcb44a0b7 100644 --- a/sync-for-commerce/docs/sdk/models/shared/newpaymentsconfiguration.md +++ b/sync-for-commerce/docs/sdk/models/shared/newpaymentsconfiguration.md @@ -1,5 +1,22 @@ # NewPaymentsConfiguration +## Example Usage + +```typescript +import { NewPaymentsConfiguration } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: NewPaymentsConfiguration = { + accounts: { + "key": { + accountOptions: [ + { + classification: "Bank Nominal", + }, + ], + }, + }, +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/newtaxrates.md b/sync-for-commerce/docs/sdk/models/shared/newtaxrates.md index b1652f637..92f537672 100644 --- a/sync-for-commerce/docs/sdk/models/shared/newtaxrates.md +++ b/sync-for-commerce/docs/sdk/models/shared/newtaxrates.md @@ -1,5 +1,12 @@ # NewTaxRates +## Example Usage + +```typescript +import { NewTaxRates } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: NewTaxRates = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/outputformat.md b/sync-for-commerce/docs/sdk/models/shared/outputformat.md index e70dda284..b1c74f4f5 100644 --- a/sync-for-commerce/docs/sdk/models/shared/outputformat.md +++ b/sync-for-commerce/docs/sdk/models/shared/outputformat.md @@ -1,10 +1,17 @@ # OutputFormat -The format commerce transactions are stored in the accounting platform. +The format commerce transactions are stored in the accounting software. +## Example Usage + +```typescript +import { OutputFormat } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: OutputFormat = "JournalEntry"; +``` ## Values -| Name | Value | -| -------------- | -------------- | -| `JournalEntry` | JournalEntry | \ No newline at end of file +```typescript +"JournalEntry" +``` \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/paymentsconfiguration.md b/sync-for-commerce/docs/sdk/models/shared/paymentsconfiguration.md index 13e95d4d2..4b0ee7118 100644 --- a/sync-for-commerce/docs/sdk/models/shared/paymentsconfiguration.md +++ b/sync-for-commerce/docs/sdk/models/shared/paymentsconfiguration.md @@ -1,5 +1,22 @@ # PaymentsConfiguration +## Example Usage + +```typescript +import { PaymentsConfiguration } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: PaymentsConfiguration = { + accounts: { + "key": { + accountOptions: [ + { + classification: "Bank Nominal", + }, + ], + }, + }, +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/salesconfiguration.md b/sync-for-commerce/docs/sdk/models/shared/salesconfiguration.md index 840e99790..f6d66dad1 100644 --- a/sync-for-commerce/docs/sdk/models/shared/salesconfiguration.md +++ b/sync-for-commerce/docs/sdk/models/shared/salesconfiguration.md @@ -1,5 +1,25 @@ # SalesConfiguration +## Example Usage + +```typescript +import { SalesConfiguration } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: SalesConfiguration = { + accounts: { + "key": { + accountOptions: [ + { + classification: "Bank Nominal", + }, + ], + }, + }, + invoiceStatus: { + selectedInvoiceStatus: "Submitted", + }, +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/salescustomer.md b/sync-for-commerce/docs/sdk/models/shared/salescustomer.md index 5ee33cb8a..9e2a660f6 100644 --- a/sync-for-commerce/docs/sdk/models/shared/salescustomer.md +++ b/sync-for-commerce/docs/sdk/models/shared/salescustomer.md @@ -1,5 +1,12 @@ # SalesCustomer +## Example Usage + +```typescript +import { SalesCustomer } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: SalesCustomer = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/security.md b/sync-for-commerce/docs/sdk/models/shared/security.md index 30160fe18..02d69a651 100644 --- a/sync-for-commerce/docs/sdk/models/shared/security.md +++ b/sync-for-commerce/docs/sdk/models/shared/security.md @@ -1,5 +1,14 @@ # Security +## Example Usage + +```typescript +import { Security } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: Security = { + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/sourcetype.md b/sync-for-commerce/docs/sdk/models/shared/sourcetype.md index 3ddd34f70..eec3b4491 100644 --- a/sync-for-commerce/docs/sdk/models/shared/sourcetype.md +++ b/sync-for-commerce/docs/sdk/models/shared/sourcetype.md @@ -2,15 +2,16 @@ The type of platform of the connection. +## Example Usage + +```typescript +import { SourceType } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: SourceType = "Accounting"; +``` ## Values -| Name | Value | -| ------------ | ------------ | -| `Accounting` | Accounting | -| `Banking` | Banking | -| `BankFeed` | BankFeed | -| `Commerce` | Commerce | -| `Expense` | Expense | -| `Other` | Other | -| `Unknown` | Unknown | \ No newline at end of file +```typescript +"Accounting" | "Banking" | "BankFeed" | "Commerce" | "Expense" | "Other" | "Unknown" +``` \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/supportedfeature.md b/sync-for-commerce/docs/sdk/models/shared/supportedfeature.md index 3df895f91..bf2c0b44d 100644 --- a/sync-for-commerce/docs/sdk/models/shared/supportedfeature.md +++ b/sync-for-commerce/docs/sdk/models/shared/supportedfeature.md @@ -1,5 +1,15 @@ # SupportedFeature +## Example Usage + +```typescript +import { SupportedFeature } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: SupportedFeature = { + featureType: "Get", + featureState: "Release", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/syncconnectiondeletedwebhook.md b/sync-for-commerce/docs/sdk/models/shared/syncconnectiondeletedwebhook.md index 3a9ed7afa..1764d72f4 100644 --- a/sync-for-commerce/docs/sdk/models/shared/syncconnectiondeletedwebhook.md +++ b/sync-for-commerce/docs/sdk/models/shared/syncconnectiondeletedwebhook.md @@ -2,6 +2,22 @@ A Sync for Commerce connection is deleted. +## Example Usage + +```typescript +import { SyncConnectionDeletedWebhook } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: SyncConnectionDeletedWebhook = { + clientId: "bae71d36-ff47-420a-b4a6-f8c9ddf41140", + clientName: "Bank of Dave", + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + ruleId: "70af3071-65d9-4ec3-b3cb-5283e8d55dac", + ruleType: "Sync Connection Deleted", + alertId: "a9367074-b5c3-42c4-9be4-be129f43577e", + message: + "Sync connection for company Tesco (8a210b68-6988-11ed-a1eb-0242ac120002) deleted", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/syncdaterangeutc.md b/sync-for-commerce/docs/sdk/models/shared/syncdaterangeutc.md index b575fd341..5a10dbc5b 100644 --- a/sync-for-commerce/docs/sdk/models/shared/syncdaterangeutc.md +++ b/sync-for-commerce/docs/sdk/models/shared/syncdaterangeutc.md @@ -1,5 +1,15 @@ # SyncDateRangeUtc +## Example Usage + +```typescript +import { SyncDateRangeUtc } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: SyncDateRangeUtc = { + start: "2022-10-23T00:00:00Z", + finish: "2022-10-23T00:00:00Z", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/syncflowurl.md b/sync-for-commerce/docs/sdk/models/shared/syncflowurl.md index b50a80b6a..662c98346 100644 --- a/sync-for-commerce/docs/sdk/models/shared/syncflowurl.md +++ b/sync-for-commerce/docs/sdk/models/shared/syncflowurl.md @@ -1,5 +1,15 @@ # SyncFlowUrl +## Example Usage + +```typescript +import { SyncFlowUrl } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: SyncFlowUrl = { + url: + "https://sync-flow-integration.codat.io/57b6fad9-e3ca-447b-89db-e4ffa21e6ef3/aiwb/mqjo/start?otp=836415", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/syncfrequency.md b/sync-for-commerce/docs/sdk/models/shared/syncfrequency.md index c389222fc..6701d2fa1 100644 --- a/sync-for-commerce/docs/sdk/models/shared/syncfrequency.md +++ b/sync-for-commerce/docs/sdk/models/shared/syncfrequency.md @@ -2,10 +2,16 @@ The frequency in which you want data to be synced. +## Example Usage + +```typescript +import { SyncFrequency } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: SyncFrequency = "Daily"; +``` ## Values -| Name | Value | -| --------- | --------- | -| `Daily` | Daily | -| `Monthly` | Monthly | \ No newline at end of file +```typescript +"Daily" | "Monthly" +``` \ No newline at end of file diff --git a/sync-for-commerce/docs/sdk/models/shared/syncrange.md b/sync-for-commerce/docs/sdk/models/shared/syncrange.md index dfe121a54..b8cfa8ca6 100644 --- a/sync-for-commerce/docs/sdk/models/shared/syncrange.md +++ b/sync-for-commerce/docs/sdk/models/shared/syncrange.md @@ -1,5 +1,17 @@ # SyncRange +## Example Usage + +```typescript +import { SyncRange } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: SyncRange = { + dateRange: { + start: "2022-10-23T00:00:00Z", + finish: "2022-10-23T00:00:00Z", + }, +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/syncschedule.md b/sync-for-commerce/docs/sdk/models/shared/syncschedule.md index 28058295c..6298ce766 100644 --- a/sync-for-commerce/docs/sdk/models/shared/syncschedule.md +++ b/sync-for-commerce/docs/sdk/models/shared/syncschedule.md @@ -1,5 +1,15 @@ # SyncSchedule +## Example Usage + +```typescript +import { SyncSchedule } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: SyncSchedule = { + startDate: "2022-10-23T00:00:00Z", + timeZone: "Europe/London", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/syncstatus.md b/sync-for-commerce/docs/sdk/models/shared/syncstatus.md index 8348e26d4..32d2f35ef 100644 --- a/sync-for-commerce/docs/sdk/models/shared/syncstatus.md +++ b/sync-for-commerce/docs/sdk/models/shared/syncstatus.md @@ -2,6 +2,39 @@ The status of syncing for a company and its connections. +## Example Usage + +```typescript +import { SyncStatus } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: SyncStatus = { + commerceSyncId: "8d0a044e-b683-4fc9-bd0d-bfb2ca5731b7", + syncId: "730dcf2e-3afc-4d83-bb90-9f4b95dddf68", + syncStatusCode: 4000, + syncStatus: "ValidateError, Pending", + errorMessage: + "Customer 3b9bf2ed-a618-4af2-80f2-f2b57fddc748 is not in an Active state. (Archived)", + syncExceptionMessage: + "Customer 3b9bf2ed-a618-4af2-80f2-f2b57fddc748 is not in an Active state. (Archived)", + syncUtc: "2022-10-23T00:00:00Z", + dataPushed: true, + dataConnections: [ + { + id: "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", + integrationId: "bf083d72-62c7-493e-aec9-81b4dbba7e2c", + integrationKey: "dfxm", + sourceId: "bdd831ce-eebd-4896-89a7-20e5ee8989ee", + sourceType: "Banking", + platformName: "Basiq", + linkUrl: + "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", + status: "Linked", + lastSync: "2022-10-27T10:22:43.6464237Z", + created: "2022-10-27T09:53:29Z", + }, + ], +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/syncsummary.md b/sync-for-commerce/docs/sdk/models/shared/syncsummary.md index f2c46c341..02d17d4a6 100644 --- a/sync-for-commerce/docs/sdk/models/shared/syncsummary.md +++ b/sync-for-commerce/docs/sdk/models/shared/syncsummary.md @@ -1,5 +1,42 @@ # SyncSummary +## Example Usage + +```typescript +import { SyncSummary } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: SyncSummary = { + syncDateRangeUtc: { + start: "2022-10-23T00:00:00Z", + finish: "2022-10-23T00:00:00Z", + }, + companyId: "f4637ec9-9fc0-4a02-8df0-c90d6dc86208", + commerceSyncId: "8d0a044e-b683-4fc9-bd0d-bfb2ca5731b7", + syncStatusCode: 4000, + syncStatus: "ValidateError, Pending", + errorMessage: + "Customer 3b9bf2ed-a618-4af2-80f2-f2b57fddc748 is not in an Active state. (Archived)", + syncExceptionMessage: + "Customer 3b9bf2ed-a618-4af2-80f2-f2b57fddc748 is not in an Active state. (Archived)", + syncUtc: "2022-10-23T00:00:00Z", + dataConnections: [ + { + id: "ee2eb431-c0fa-4dc9-93fa-d29781c12bcd", + integrationId: "bf083d72-62c7-493e-aec9-81b4dbba7e2c", + integrationKey: "dfxm", + sourceId: "bdd831ce-eebd-4896-89a7-20e5ee8989ee", + sourceType: "Banking", + platformName: "Basiq", + linkUrl: + "https://link-api.codat.io/companies/86bd88cb-44ab-4dfb-b32f-87b19b14287f/connections/ee2eb431-c0fa-4dc9-93fa-d29781c12bcd/start", + status: "Linked", + lastSync: "2022-10-27T10:22:43.6464237Z", + created: "2022-10-27T09:53:29Z", + }, + ], + dataPushed: true, +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/synctolatestargs.md b/sync-for-commerce/docs/sdk/models/shared/synctolatestargs.md index 8589d631d..1199bb21c 100644 --- a/sync-for-commerce/docs/sdk/models/shared/synctolatestargs.md +++ b/sync-for-commerce/docs/sdk/models/shared/synctolatestargs.md @@ -1,5 +1,14 @@ # SyncToLatestArgs +## Example Usage + +```typescript +import { SyncToLatestArgs } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: SyncToLatestArgs = { + syncTo: "2022-10-23T00:00:00Z", +}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/taxrateamount.md b/sync-for-commerce/docs/sdk/models/shared/taxrateamount.md index 996d05b84..bc361f30a 100644 --- a/sync-for-commerce/docs/sdk/models/shared/taxrateamount.md +++ b/sync-for-commerce/docs/sdk/models/shared/taxrateamount.md @@ -1,5 +1,12 @@ # TaxRateAmount +## Example Usage + +```typescript +import { TaxRateAmount } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: TaxRateAmount = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/taxratemapping.md b/sync-for-commerce/docs/sdk/models/shared/taxratemapping.md index c48285a61..6e4cb445b 100644 --- a/sync-for-commerce/docs/sdk/models/shared/taxratemapping.md +++ b/sync-for-commerce/docs/sdk/models/shared/taxratemapping.md @@ -1,5 +1,12 @@ # TaxRateMapping +## Example Usage + +```typescript +import { TaxRateMapping } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: TaxRateMapping = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/updateconnection.md b/sync-for-commerce/docs/sdk/models/shared/updateconnection.md index 7626eebfc..5452f343d 100644 --- a/sync-for-commerce/docs/sdk/models/shared/updateconnection.md +++ b/sync-for-commerce/docs/sdk/models/shared/updateconnection.md @@ -1,5 +1,12 @@ # UpdateConnection +## Example Usage + +```typescript +import { UpdateConnection } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: UpdateConnection = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdk/models/shared/visibleaccounts.md b/sync-for-commerce/docs/sdk/models/shared/visibleaccounts.md index f8c2dd61e..125ea7c98 100644 --- a/sync-for-commerce/docs/sdk/models/shared/visibleaccounts.md +++ b/sync-for-commerce/docs/sdk/models/shared/visibleaccounts.md @@ -1,5 +1,12 @@ # VisibleAccounts +## Example Usage + +```typescript +import { VisibleAccounts } from "@codat/sync-for-commerce/sdk/models/shared"; + +let value: VisibleAccounts = {}; +``` ## Fields diff --git a/sync-for-commerce/docs/sdks/advancedcontrols/README.md b/sync-for-commerce/docs/sdks/advancedcontrols/README.md index 867c2e7dc..c3b9aac71 100644 --- a/sync-for-commerce/docs/sdks/advancedcontrols/README.md +++ b/sync-for-commerce/docs/sdks/advancedcontrols/README.md @@ -34,7 +34,42 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { advancedControlsListCompanies } from "@codat/sync-for-commerce/funcs/advancedControlsListCompanies.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await advancedControlsListCompanies(codatSyncCommerce, { + page: 1, + pageSize: 100, + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + orderBy: "-modifiedDate", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -49,16 +84,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.Companies](../../sdk/models/shared/companies.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| errors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | +| errors.ErrorMessage | 400, 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## createCompany @@ -76,16 +111,42 @@ const codatSyncCommerce = new CodatSyncCommerce({ async function run() { const result = await codatSyncCommerce.advancedControls.createCompany({ name: "string", - description: "Requested early access to the new financing scheme.", - groups: [ - { - id: "60d2fa12-8a04-11ee-b9d1-0242ac120002", - }, - ], }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { advancedControlsCreateCompany } from "@codat/sync-for-commerce/funcs/advancedControlsCreateCompany.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await advancedControlsCreateCompany(codatSyncCommerce, { + name: "string", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -100,16 +161,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.Company](../../sdk/models/shared/company.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| errors.ErrorMessage | 400,401,402,403,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| errors.ErrorMessage | 400, 401, 402, 403, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## getConfiguration @@ -130,7 +191,39 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { advancedControlsGetConfiguration } from "@codat/sync-for-commerce/funcs/advancedControlsGetConfiguration.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await advancedControlsGetConfiguration(codatSyncCommerce, { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -145,16 +238,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.Configuration](../../sdk/models/shared/configuration.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| errors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| errors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## setConfiguration @@ -175,7 +268,39 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { advancedControlsSetConfiguration } from "@codat/sync-for-commerce/funcs/advancedControlsSetConfiguration.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await advancedControlsSetConfiguration(codatSyncCommerce, { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -190,13 +315,13 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.Configuration](../../sdk/models/shared/configuration.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| ----------------------------------- | ----------------------------------- | ----------------------------------- | -| errors.ErrorMessage | 400,401,402,403,404,409,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| errors.ErrorMessage | 400, 401, 402, 403, 404, 409, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/sync-for-commerce/docs/sdks/codatsynccommerce/README.md b/sync-for-commerce/docs/sdks/codatsynccommerce/README.md index 09f0b52b3..dc0d5fcd3 100644 --- a/sync-for-commerce/docs/sdks/codatsynccommerce/README.md +++ b/sync-for-commerce/docs/sdks/codatsynccommerce/README.md @@ -1,6 +1,5 @@ # CodatSyncCommerce SDK - ## Overview Sync for Commerce: The API for Sync for Commerce. @@ -26,4 +25,3 @@ Not seeing the endpoints you're expecting? We've [reorganized our products](http ### Available Operations - diff --git a/sync-for-commerce/docs/sdks/connections/README.md b/sync-for-commerce/docs/sdks/connections/README.md index 088eb5393..436948d31 100644 --- a/sync-for-commerce/docs/sdks/connections/README.md +++ b/sync-for-commerce/docs/sdks/connections/README.md @@ -33,7 +33,40 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { connectionsGetSyncFlowUrl } from "@codat/sync-for-commerce/funcs/connectionsGetSyncFlowUrl.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await connectionsGetSyncFlowUrl(codatSyncCommerce, { + commerceKey: "", + accountingKey: "", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -48,16 +81,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.SyncFlowUrl](../../sdk/models/shared/syncflowurl.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| errors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | +| errors.ErrorMessage | 400, 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## list @@ -82,7 +115,43 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { connectionsList } from "@codat/sync-for-commerce/funcs/connectionsList.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await connectionsList(codatSyncCommerce, { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + page: 1, + pageSize: 100, + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + orderBy: "-modifiedDate", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -97,22 +166,22 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.Connections](../../sdk/models/shared/connections.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| errors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | +| errors.ErrorMessage | 400, 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## create Creates a connection for the company by providing a valid `platformKey`. -Use the [List Integrations](https://docs.codat.io/sync-for-sync-for-commerce-api#/operations/list-integrations) endpoint to access valid platform keys. +Use the [List Integrations](https://docs.codat.io/platform-api#/operations/list-integrations) endpoint to access valid platform keys. ### Example Usage @@ -132,7 +201,42 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { connectionsCreate } from "@codat/sync-for-commerce/funcs/connectionsCreate.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await connectionsCreate(codatSyncCommerce, { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + requestBody: { + platformKey: "gbol", + }, + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -147,16 +251,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.Connection](../../sdk/models/shared/connection.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| errors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| errors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## updateConnection @@ -178,7 +282,40 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { connectionsUpdateConnection } from "@codat/sync-for-commerce/funcs/connectionsUpdateConnection.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await connectionsUpdateConnection(codatSyncCommerce, { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -193,16 +330,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.Connection](../../sdk/models/shared/connection.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| errors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| errors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## updateAuthorization @@ -224,7 +361,40 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { connectionsUpdateAuthorization } from "@codat/sync-for-commerce/funcs/connectionsUpdateAuthorization.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await connectionsUpdateAuthorization(codatSyncCommerce, { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -239,13 +409,13 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.Connection](../../sdk/models/shared/connection.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| errors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| errors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/sync-for-commerce/docs/sdks/integrations/README.md b/sync-for-commerce/docs/sdks/integrations/README.md index 68d96ede8..6b2e27711 100644 --- a/sync-for-commerce/docs/sdks/integrations/README.md +++ b/sync-for-commerce/docs/sdks/integrations/README.md @@ -32,7 +32,42 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { integrationsList } from "@codat/sync-for-commerce/funcs/integrationsList.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await integrationsList(codatSyncCommerce, { + page: 1, + pageSize: 100, + query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee", + orderBy: "-modifiedDate", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -47,16 +82,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.Integrations](../../sdk/models/shared/integrations.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| errors.ErrorMessage | 400,401,402,403,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| errors.ErrorMessage | 400, 401, 402, 403, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## getBranding @@ -77,7 +112,39 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { integrationsGetBranding } from "@codat/sync-for-commerce/funcs/integrationsGetBranding.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await integrationsGetBranding(codatSyncCommerce, { + platformKey: "gbol", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -92,13 +159,13 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.Branding](../../sdk/models/shared/branding.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| errors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| errors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/sync-for-commerce/docs/sdks/sync/README.md b/sync-for-commerce/docs/sdks/sync/README.md index 908739c77..927adfa42 100644 --- a/sync-for-commerce/docs/sdks/sync/README.md +++ b/sync-for-commerce/docs/sdks/sync/README.md @@ -37,7 +37,42 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { syncRequest } from "@codat/sync-for-commerce/funcs/syncRequest.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await syncRequest(codatSyncCommerce, { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + syncToLatestArgs: { + syncTo: "2022-10-23T00:00:00Z", + }, + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -52,16 +87,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.SyncSummary](../../sdk/models/shared/syncsummary.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| errors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | +| errors.ErrorMessage | 400, 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## requestForDateRange @@ -88,7 +123,45 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { syncRequestForDateRange } from "@codat/sync-for-commerce/funcs/syncRequestForDateRange.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await syncRequestForDateRange(codatSyncCommerce, { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + syncRange: { + dateRange: { + start: "2022-10-23T00:00:00Z", + finish: "2022-10-23T00:00:00Z", + }, + }, + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -103,16 +176,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.SyncSummary](../../sdk/models/shared/syncsummary.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| errors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | +| errors.ErrorMessage | 400, 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## getStatus @@ -133,7 +206,39 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { syncGetStatus } from "@codat/sync-for-commerce/funcs/syncGetStatus.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await syncGetStatus(codatSyncCommerce, { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -148,16 +253,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.SyncStatus](../../sdk/models/shared/syncstatus.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| errors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| errors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## getLastSuccessfulSync @@ -178,7 +283,39 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { syncGetLastSuccessfulSync } from "@codat/sync-for-commerce/funcs/syncGetLastSuccessfulSync.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await syncGetLastSuccessfulSync(codatSyncCommerce, { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -193,16 +330,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.CompanySyncStatus](../../sdk/models/shared/companysyncstatus.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| errors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| errors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## getLatestSync @@ -223,7 +360,39 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { syncGetLatestSync } from "@codat/sync-for-commerce/funcs/syncGetLatestSync.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await syncGetLatestSync(codatSyncCommerce, { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -238,16 +407,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.CompanySyncStatus](../../sdk/models/shared/companysyncstatus.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| errors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| errors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## get @@ -269,7 +438,40 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { syncGet } from "@codat/sync-for-commerce/funcs/syncGet.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await syncGet(codatSyncCommerce, { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + syncId: "6fb40d5e-b13e-11ed-afa1-0242ac120002", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -284,16 +486,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.CompanySyncStatus](../../sdk/models/shared/companysyncstatus.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| errors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| errors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## list @@ -314,7 +516,39 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { syncList } from "@codat/sync-for-commerce/funcs/syncList.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await syncList(codatSyncCommerce, { + companyId: "8a210b68-6988-11ed-a1eb-0242ac120002", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -329,13 +563,13 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.CompanySyncStatus[]](../../models/.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| errors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| errors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/sync-for-commerce/docs/sdks/syncflowsettings/README.md b/sync-for-commerce/docs/sdks/syncflowsettings/README.md index d0318d100..6c79edd9e 100644 --- a/sync-for-commerce/docs/sdks/syncflowsettings/README.md +++ b/sync-for-commerce/docs/sdks/syncflowsettings/README.md @@ -31,7 +31,39 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { syncFlowSettingsGetConfigTextSyncFlow } from "@codat/sync-for-commerce/funcs/syncFlowSettingsGetConfigTextSyncFlow.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await syncFlowSettingsGetConfigTextSyncFlow(codatSyncCommerce, { + locale: "en-us", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -46,16 +78,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[{ [k: string]: shared.Localization }](../../models/.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| ----------------------- | ----------------------- | ----------------------- | -| errors.ErrorMessage | 401,402,403,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| ---------------------------- | ---------------------------- | ---------------------------- | +| errors.ErrorMessage | 401, 402, 403, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## updateConfigTextSyncFlow @@ -76,7 +108,39 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { syncFlowSettingsUpdateConfigTextSyncFlow } from "@codat/sync-for-commerce/funcs/syncFlowSettingsUpdateConfigTextSyncFlow.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await syncFlowSettingsUpdateConfigTextSyncFlow(codatSyncCommerce, { + locale: "en-us", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -91,16 +155,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[{ [k: string]: shared.Localization }](../../models/.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| errors.ErrorMessage | 400,401,402,403,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| errors.ErrorMessage | 400, 401, 402, 403, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## getVisibleAccounts @@ -117,12 +181,45 @@ const codatSyncCommerce = new CodatSyncCommerce({ async function run() { const result = await codatSyncCommerce.syncFlowSettings.getVisibleAccounts({ - clientId: "86fe9741-738d-4f2c-8e96-9c3f84156e91", + clientId: "8f9478fc-e6cf-445e-b122-74136f8fd7ab", platformKey: "gbol", }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { syncFlowSettingsGetVisibleAccounts } from "@codat/sync-for-commerce/funcs/syncFlowSettingsGetVisibleAccounts.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await syncFlowSettingsGetVisibleAccounts(codatSyncCommerce, { + clientId: "8f9478fc-e6cf-445e-b122-74136f8fd7ab", + platformKey: "gbol", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -137,16 +234,16 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.VisibleAccounts](../../sdk/models/shared/visibleaccounts.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------- | --------------------------- | --------------------------- | -| errors.ErrorMessage | 401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| errors.ErrorMessage | 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ## updateVisibleAccountsSyncFlow @@ -167,7 +264,39 @@ async function run() { }); // Handle the result - console.log(result) + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { CodatSyncCommerceCore } from "@codat/sync-for-commerce/core.js"; +import { syncFlowSettingsUpdateVisibleAccountsSyncFlow } from "@codat/sync-for-commerce/funcs/syncFlowSettingsUpdateVisibleAccountsSyncFlow.js"; + +// Use `CodatSyncCommerceCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const codatSyncCommerce = new CodatSyncCommerceCore({ + authHeader: "Basic BASE_64_ENCODED(API_KEY)", +}); + +async function run() { + const res = await syncFlowSettingsUpdateVisibleAccountsSyncFlow(codatSyncCommerce, { + platformKey: "gbol", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); } run(); @@ -182,13 +311,13 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[shared.VisibleAccounts](../../sdk/models/shared/visibleaccounts.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| errors.ErrorMessage | 400,401,402,403,404,429,500,503 | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Type | Status Code | Content Type | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | +| errors.ErrorMessage | 400, 401, 402, 403, 404, 429, 500, 503 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/sync-for-commerce/jsr.json b/sync-for-commerce/jsr.json index f080b6b58..8137041f5 100644 --- a/sync-for-commerce/jsr.json +++ b/sync-for-commerce/jsr.json @@ -2,7 +2,7 @@ { "name": "@codat/sync-for-commerce", - "version": "4.0.0", + "version": "5.0.0", "exports": { ".": "./src/index.ts", "./sdk/models/errors": "./src/sdk/models/errors/index.ts", diff --git a/sync-for-commerce/package-lock.json b/sync-for-commerce/package-lock.json index 0e4277bc2..676383530 100644 --- a/sync-for-commerce/package-lock.json +++ b/sync-for-commerce/package-lock.json @@ -1,12 +1,12 @@ { "name": "@codat/sync-for-commerce", - "version": "4.0.0", + "version": "5.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@codat/sync-for-commerce", - "version": "4.0.0", + "version": "5.0.0", "devDependencies": { "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", diff --git a/sync-for-commerce/package.json b/sync-for-commerce/package.json index 5495d9cca..7e3f53879 100644 --- a/sync-for-commerce/package.json +++ b/sync-for-commerce/package.json @@ -1,6 +1,6 @@ { "name": "@codat/sync-for-commerce", - "version": "4.0.0", + "version": "5.0.0", "author": "Codat", "main": "./index.js", "sideEffects": false, @@ -12,7 +12,7 @@ "scripts": { "lint": "eslint --max-warnings=0 src", "build": "tsc", - "prepare": "npm run build" + "prepublishOnly": "npm run build" }, "peerDependencies": { "zod": ">= 3" diff --git a/sync-for-commerce/src/core.ts b/sync-for-commerce/src/core.ts new file mode 100644 index 000000000..8f918da48 --- /dev/null +++ b/sync-for-commerce/src/core.ts @@ -0,0 +1,13 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { ClientSDK } from "./lib/sdks.js"; + +/** + * A minimal client to use when calling standalone SDK functions. Typically, an + * instance of this class would be instantiated once at the start of an + * application and passed around through some dependency injection mechanism to + * parts of an application that need to make SDK calls. + */ +export class CodatSyncCommerceCore extends ClientSDK {} diff --git a/sync-for-commerce/src/funcs/advancedControlsCreateCompany.ts b/sync-for-commerce/src/funcs/advancedControlsCreateCompany.ts new file mode 100644 index 000000000..70d1cc91c --- /dev/null +++ b/sync-for-commerce/src/funcs/advancedControlsCreateCompany.ts @@ -0,0 +1,146 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeJSON } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Create company + * + * @remarks + * Creates a Codat company + */ +export async function advancedControlsCreateCompany( + client: CodatSyncCommerceCore, + request?: shared.CreateCompany | undefined, + options?: RequestOptions, +): Promise< + Result< + shared.Company, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => shared.CreateCompany$outboundSchema.optional().parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = payload === undefined + ? null + : encodeJSON("body", payload, { explode: true }); + + const path = pathToFunc("/companies")(); + + const headers = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "create-company", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["400", "401", "402", "403", "429", "4XX", "500", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.Company, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.Company$inboundSchema), + M.jsonErr( + [400, 401, 402, 403, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/advancedControlsGetConfiguration.ts b/sync-for-commerce/src/funcs/advancedControlsGetConfiguration.ts new file mode 100644 index 000000000..7519084f3 --- /dev/null +++ b/sync-for-commerce/src/funcs/advancedControlsGetConfiguration.ts @@ -0,0 +1,153 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Get company configuration + * + * @remarks + * Returns a company's commerce sync configuration'. + */ +export async function advancedControlsGetConfiguration( + client: CodatSyncCommerceCore, + request: operations.GetConfigurationRequest, + options?: RequestOptions, +): Promise< + Result< + shared.Configuration, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => operations.GetConfigurationRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const pathParams = { + companyId: encodeSimple("companyId", payload.companyId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc("/config/companies/{companyId}/sync/commerce")( + pathParams, + ); + + const headers = new Headers({ + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "get-configuration", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.Configuration, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.Configuration$inboundSchema), + M.jsonErr( + [401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/advancedControlsListCompanies.ts b/sync-for-commerce/src/funcs/advancedControlsListCompanies.ts new file mode 100644 index 000000000..b6fc40850 --- /dev/null +++ b/sync-for-commerce/src/funcs/advancedControlsListCompanies.ts @@ -0,0 +1,164 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeFormQuery } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * List companies + * + * @remarks + * Returns a list of companies. + */ +export async function advancedControlsListCompanies( + client: CodatSyncCommerceCore, + request?: operations.ListCompaniesRequest | undefined, + options?: RequestOptions, +): Promise< + Result< + shared.Companies, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => + operations.ListCompaniesRequest$outboundSchema.optional().parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const path = pathToFunc("/companies")(); + + const query = encodeFormQuery({ + "orderBy": payload?.orderBy, + "page": payload?.page, + "pageSize": payload?.pageSize, + "query": payload?.query, + }); + + const headers = new Headers({ + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "list-companies", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + path: path, + headers: headers, + query: query, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: [ + "400", + "401", + "402", + "403", + "404", + "429", + "4XX", + "500", + "503", + "5XX", + ], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.Companies, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.Companies$inboundSchema), + M.jsonErr( + [400, 401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/advancedControlsSetConfiguration.ts b/sync-for-commerce/src/funcs/advancedControlsSetConfiguration.ts new file mode 100644 index 000000000..ad5b7cfb3 --- /dev/null +++ b/sync-for-commerce/src/funcs/advancedControlsSetConfiguration.ts @@ -0,0 +1,165 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Set configuration + * + * @remarks + * Sets a company's commerce sync configuration. + */ +export async function advancedControlsSetConfiguration( + client: CodatSyncCommerceCore, + request: operations.SetConfigurationRequest, + options?: RequestOptions, +): Promise< + Result< + shared.Configuration, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => operations.SetConfigurationRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const pathParams = { + companyId: encodeSimple("companyId", payload.companyId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc("/config/companies/{companyId}/sync/commerce")( + pathParams, + ); + + const headers = new Headers({ + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "set-configuration", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: [ + "400", + "401", + "402", + "403", + "404", + "409", + "429", + "4XX", + "500", + "503", + "5XX", + ], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.Configuration, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.Configuration$inboundSchema), + M.jsonErr( + [400, 401, 402, 403, 404, 409, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/connectionsCreate.ts b/sync-for-commerce/src/funcs/connectionsCreate.ts new file mode 100644 index 000000000..7bead6e0d --- /dev/null +++ b/sync-for-commerce/src/funcs/connectionsCreate.ts @@ -0,0 +1,154 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeJSON, encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Create connection + * + * @remarks + * Creates a connection for the company by providing a valid `platformKey`. + * + * Use the [List Integrations](https://docs.codat.io/platform-api#/operations/list-integrations) endpoint to access valid platform keys. + */ +export async function connectionsCreate( + client: CodatSyncCommerceCore, + request: operations.CreateConnectionRequest, + options?: RequestOptions, +): Promise< + Result< + shared.Connection, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => operations.CreateConnectionRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = encodeJSON("body", payload.RequestBody, { explode: true }); + + const pathParams = { + companyId: encodeSimple("companyId", payload.companyId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc("/companies/{companyId}/connections")(pathParams); + + const headers = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "create-connection", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.Connection, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.Connection$inboundSchema), + M.jsonErr( + [401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/connectionsGetSyncFlowUrl.ts b/sync-for-commerce/src/funcs/connectionsGetSyncFlowUrl.ts new file mode 100644 index 000000000..04b333705 --- /dev/null +++ b/sync-for-commerce/src/funcs/connectionsGetSyncFlowUrl.ts @@ -0,0 +1,173 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeFormQuery, encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Start new sync flow + * + * @remarks + * Create a new company and connections. Get a URL for Sync Flow, including a one time passcode. + */ +export async function connectionsGetSyncFlowUrl( + client: CodatSyncCommerceCore, + request: operations.GetSyncFlowUrlRequest, + options?: RequestOptions, +): Promise< + Result< + shared.SyncFlowUrl, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => operations.GetSyncFlowUrlRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const pathParams = { + accountingKey: encodeSimple("accountingKey", payload.accountingKey, { + explode: false, + charEncoding: "percent", + }), + commerceKey: encodeSimple("commerceKey", payload.commerceKey, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc( + "/config/sync/commerce/{commerceKey}/{accountingKey}/start", + )(pathParams); + + const query = encodeFormQuery({ + "merchantIdentifier": payload.merchantIdentifier, + }); + + const headers = new Headers({ + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "get-sync-flow-url", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + path: path, + headers: headers, + query: query, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: [ + "400", + "401", + "402", + "403", + "404", + "429", + "4XX", + "500", + "503", + "5XX", + ], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.SyncFlowUrl, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.SyncFlowUrl$inboundSchema), + M.jsonErr( + [400, 401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/connectionsList.ts b/sync-for-commerce/src/funcs/connectionsList.ts new file mode 100644 index 000000000..fe63ed868 --- /dev/null +++ b/sync-for-commerce/src/funcs/connectionsList.ts @@ -0,0 +1,170 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeFormQuery, encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * List connections + * + * @remarks + * List the connections for a company. + */ +export async function connectionsList( + client: CodatSyncCommerceCore, + request: operations.ListConnectionsRequest, + options?: RequestOptions, +): Promise< + Result< + shared.Connections, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => operations.ListConnectionsRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const pathParams = { + companyId: encodeSimple("companyId", payload.companyId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc("/companies/{companyId}/connections")(pathParams); + + const query = encodeFormQuery({ + "orderBy": payload.orderBy, + "page": payload.page, + "pageSize": payload.pageSize, + "query": payload.query, + }); + + const headers = new Headers({ + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "list-connections", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + path: path, + headers: headers, + query: query, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: [ + "400", + "401", + "402", + "403", + "404", + "429", + "4XX", + "500", + "503", + "5XX", + ], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.Connections, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.Connections$inboundSchema), + M.jsonErr( + [400, 401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/connectionsUpdateAuthorization.ts b/sync-for-commerce/src/funcs/connectionsUpdateAuthorization.ts new file mode 100644 index 000000000..82aa20294 --- /dev/null +++ b/sync-for-commerce/src/funcs/connectionsUpdateAuthorization.ts @@ -0,0 +1,161 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeJSON, encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Update authorization + * + * @remarks + * Update data connection's authorization. + */ +export async function connectionsUpdateAuthorization( + client: CodatSyncCommerceCore, + request: operations.UpdateConnectionAuthorizationRequest, + options?: RequestOptions, +): Promise< + Result< + shared.Connection, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => + operations.UpdateConnectionAuthorizationRequest$outboundSchema.parse( + value, + ), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = encodeJSON("body", payload.RequestBody, { explode: true }); + + const pathParams = { + companyId: encodeSimple("companyId", payload.companyId, { + explode: false, + charEncoding: "percent", + }), + connectionId: encodeSimple("connectionId", payload.connectionId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc( + "/companies/{companyId}/connections/{connectionId}/authorization", + )(pathParams); + + const headers = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "update-connection-authorization", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "PUT", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.Connection, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.Connection$inboundSchema), + M.jsonErr( + [401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/connectionsUpdateConnection.ts b/sync-for-commerce/src/funcs/connectionsUpdateConnection.ts new file mode 100644 index 000000000..2688594b4 --- /dev/null +++ b/sync-for-commerce/src/funcs/connectionsUpdateConnection.ts @@ -0,0 +1,158 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeJSON, encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Update connection + * + * @remarks + * Update a data connection + */ +export async function connectionsUpdateConnection( + client: CodatSyncCommerceCore, + request: operations.UpdateConnectionRequest, + options?: RequestOptions, +): Promise< + Result< + shared.Connection, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => operations.UpdateConnectionRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = encodeJSON("body", payload.UpdateConnection, { explode: true }); + + const pathParams = { + companyId: encodeSimple("companyId", payload.companyId, { + explode: false, + charEncoding: "percent", + }), + connectionId: encodeSimple("connectionId", payload.connectionId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc("/companies/{companyId}/connections/{connectionId}")( + pathParams, + ); + + const headers = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "update-connection", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "PATCH", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.Connection, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.Connection$inboundSchema), + M.jsonErr( + [401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/integrationsGetBranding.ts b/sync-for-commerce/src/funcs/integrationsGetBranding.ts new file mode 100644 index 000000000..e0f28ae7a --- /dev/null +++ b/sync-for-commerce/src/funcs/integrationsGetBranding.ts @@ -0,0 +1,154 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Get branding for an integration + * + * @remarks + * Retrieve Integration branding assets. + */ +export async function integrationsGetBranding( + client: CodatSyncCommerceCore, + request: operations.GetIntegrationBrandingRequest, + options?: RequestOptions, +): Promise< + Result< + shared.Branding, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => + operations.GetIntegrationBrandingRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const pathParams = { + platformKey: encodeSimple("platformKey", payload.platformKey, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc("/config/integrations/{platformKey}/branding")( + pathParams, + ); + + const headers = new Headers({ + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "get-integration-branding", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.Branding, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.Branding$inboundSchema), + M.jsonErr( + [401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/integrationsList.ts b/sync-for-commerce/src/funcs/integrationsList.ts new file mode 100644 index 000000000..5dbe37a8a --- /dev/null +++ b/sync-for-commerce/src/funcs/integrationsList.ts @@ -0,0 +1,153 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeFormQuery } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * List integrations + * + * @remarks + * Retrieve a list of available integrations support by data type and state of release. + */ +export async function integrationsList( + client: CodatSyncCommerceCore, + request?: operations.ListIntegrationsRequest | undefined, + options?: RequestOptions, +): Promise< + Result< + shared.Integrations, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => + operations.ListIntegrationsRequest$outboundSchema.optional().parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const path = pathToFunc("/config/integrations")(); + + const query = encodeFormQuery({ + "orderBy": payload?.orderBy, + "page": payload?.page, + "pageSize": payload?.pageSize, + "query": payload?.query, + }); + + const headers = new Headers({ + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "list-integrations", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + path: path, + headers: headers, + query: query, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["400", "401", "402", "403", "429", "4XX", "500", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.Integrations, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.Integrations$inboundSchema), + M.jsonErr( + [400, 401, 402, 403, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/syncFlowSettingsGetConfigTextSyncFlow.ts b/sync-for-commerce/src/funcs/syncFlowSettingsGetConfigTextSyncFlow.ts new file mode 100644 index 000000000..c9e6a22c0 --- /dev/null +++ b/sync-for-commerce/src/funcs/syncFlowSettingsGetConfigTextSyncFlow.ts @@ -0,0 +1,151 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeFormQuery } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Get preferences for text fields + * + * @remarks + * Return preferences set for the text fields on sync flow. + */ +export async function syncFlowSettingsGetConfigTextSyncFlow( + client: CodatSyncCommerceCore, + request: operations.GetConfigTextSyncFlowRequest, + options?: RequestOptions, +): Promise< + Result< + { [k: string]: shared.Localization }, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => + operations.GetConfigTextSyncFlowRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const path = pathToFunc("/sync/commerce/config/ui/text")(); + + const query = encodeFormQuery({ + "locale": payload.locale, + }); + + const headers = new Headers({ + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "get-config-text-sync-flow", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + path: path, + headers: headers, + query: query, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["401", "402", "403", "429", "4XX", "500", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + { [k: string]: shared.Localization }, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, z.record(shared.Localization$inboundSchema)), + M.jsonErr( + [401, 402, 403, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/syncFlowSettingsGetVisibleAccounts.ts b/sync-for-commerce/src/funcs/syncFlowSettingsGetVisibleAccounts.ts new file mode 100644 index 000000000..fcb434ad6 --- /dev/null +++ b/sync-for-commerce/src/funcs/syncFlowSettingsGetVisibleAccounts.ts @@ -0,0 +1,157 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * List visible accounts + * + * @remarks + * Return accounts which are visible on sync flow. + */ +export async function syncFlowSettingsGetVisibleAccounts( + client: CodatSyncCommerceCore, + request: operations.GetVisibleAccountsRequest, + options?: RequestOptions, +): Promise< + Result< + shared.VisibleAccounts, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => operations.GetVisibleAccountsRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const pathParams = { + clientId: encodeSimple("clientId", payload.clientId, { + explode: false, + charEncoding: "percent", + }), + platformKey: encodeSimple("platformKey", payload.platformKey, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc( + "/clients/{clientId}/config/ui/accounts/platform/{platformKey}", + )(pathParams); + + const headers = new Headers({ + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "get-visible-accounts", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.VisibleAccounts, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.VisibleAccounts$inboundSchema), + M.jsonErr( + [401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/syncFlowSettingsUpdateConfigTextSyncFlow.ts b/sync-for-commerce/src/funcs/syncFlowSettingsUpdateConfigTextSyncFlow.ts new file mode 100644 index 000000000..451bbd5e1 --- /dev/null +++ b/sync-for-commerce/src/funcs/syncFlowSettingsUpdateConfigTextSyncFlow.ts @@ -0,0 +1,152 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeFormQuery, encodeJSON } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Update preferences for text fields + * + * @remarks + * Set preferences for the text fields on sync flow. + */ +export async function syncFlowSettingsUpdateConfigTextSyncFlow( + client: CodatSyncCommerceCore, + request: operations.UpdateConfigTextSyncFlowRequest, + options?: RequestOptions, +): Promise< + Result< + { [k: string]: shared.Localization }, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => + operations.UpdateConfigTextSyncFlowRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = encodeJSON("body", payload.RequestBody, { explode: true }); + + const path = pathToFunc("/sync/commerce/config/ui/text")(); + + const query = encodeFormQuery({ + "locale": payload.locale, + }); + + const headers = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "update-config-text-sync-flow", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "PATCH", + path: path, + headers: headers, + query: query, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["400", "401", "402", "403", "429", "4XX", "500", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + { [k: string]: shared.Localization }, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, z.record(shared.Localization$inboundSchema)), + M.jsonErr( + [400, 401, 402, 403, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/syncFlowSettingsUpdateVisibleAccountsSyncFlow.ts b/sync-for-commerce/src/funcs/syncFlowSettingsUpdateVisibleAccountsSyncFlow.ts new file mode 100644 index 000000000..2fa8fdb08 --- /dev/null +++ b/sync-for-commerce/src/funcs/syncFlowSettingsUpdateVisibleAccountsSyncFlow.ts @@ -0,0 +1,168 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeJSON, encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Update visible accounts + * + * @remarks + * Update which accounts are visible on sync flow. + */ +export async function syncFlowSettingsUpdateVisibleAccountsSyncFlow( + client: CodatSyncCommerceCore, + request: operations.UpdateVisibleAccountsSyncFlowRequest, + options?: RequestOptions, +): Promise< + Result< + shared.VisibleAccounts, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => + operations.UpdateVisibleAccountsSyncFlowRequest$outboundSchema.parse( + value, + ), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = encodeJSON("body", payload.VisibleAccounts, { explode: true }); + + const pathParams = { + platformKey: encodeSimple("platformKey", payload.platformKey, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc( + "/sync/commerce/config/ui/accounts/platform/{platformKey}", + )(pathParams); + + const headers = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "update-visible-accounts-sync-flow", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: [ + "400", + "401", + "402", + "403", + "404", + "429", + "4XX", + "500", + "503", + "5XX", + ], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.VisibleAccounts, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.VisibleAccounts$inboundSchema), + M.jsonErr( + [400, 401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/syncGet.ts b/sync-for-commerce/src/funcs/syncGet.ts new file mode 100644 index 000000000..f3f98d89d --- /dev/null +++ b/sync-for-commerce/src/funcs/syncGet.ts @@ -0,0 +1,157 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Get sync status + * + * @remarks + * Get the sync status for a specified sync + */ +export async function syncGet( + client: CodatSyncCommerceCore, + request: operations.GetSyncByIdRequest, + options?: RequestOptions, +): Promise< + Result< + shared.CompanySyncStatus, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => operations.GetSyncByIdRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const pathParams = { + companyId: encodeSimple("companyId", payload.companyId, { + explode: false, + charEncoding: "percent", + }), + syncId: encodeSimple("syncId", payload.syncId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc( + "/companies/{companyId}/sync/commerce/syncs/{syncId}/status", + )(pathParams); + + const headers = new Headers({ + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "get-sync-by-id", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.CompanySyncStatus, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.CompanySyncStatus$inboundSchema), + M.jsonErr( + [401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/syncGetLastSuccessfulSync.ts b/sync-for-commerce/src/funcs/syncGetLastSuccessfulSync.ts new file mode 100644 index 000000000..94d7c1260 --- /dev/null +++ b/sync-for-commerce/src/funcs/syncGetLastSuccessfulSync.ts @@ -0,0 +1,154 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Last successful sync + * + * @remarks + * Gets the status of the last successful sync + */ +export async function syncGetLastSuccessfulSync( + client: CodatSyncCommerceCore, + request: operations.GetLastSuccessfulSyncRequest, + options?: RequestOptions, +): Promise< + Result< + shared.CompanySyncStatus, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => + operations.GetLastSuccessfulSyncRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const pathParams = { + companyId: encodeSimple("companyId", payload.companyId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc( + "/companies/{companyId}/sync/commerce/syncs/lastSuccessful/status", + )(pathParams); + + const headers = new Headers({ + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "get-last-successful-sync", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.CompanySyncStatus, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.CompanySyncStatus$inboundSchema), + M.jsonErr( + [401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/syncGetLatestSync.ts b/sync-for-commerce/src/funcs/syncGetLatestSync.ts new file mode 100644 index 000000000..d2b29b3b5 --- /dev/null +++ b/sync-for-commerce/src/funcs/syncGetLatestSync.ts @@ -0,0 +1,153 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Latest sync status + * + * @remarks + * Gets the latest sync status + */ +export async function syncGetLatestSync( + client: CodatSyncCommerceCore, + request: operations.GetLatestSyncRequest, + options?: RequestOptions, +): Promise< + Result< + shared.CompanySyncStatus, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => operations.GetLatestSyncRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const pathParams = { + companyId: encodeSimple("companyId", payload.companyId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc( + "/companies/{companyId}/sync/commerce/syncs/latest/status", + )(pathParams); + + const headers = new Headers({ + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "get-latest-sync", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.CompanySyncStatus, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.CompanySyncStatus$inboundSchema), + M.jsonErr( + [401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/syncGetStatus.ts b/sync-for-commerce/src/funcs/syncGetStatus.ts new file mode 100644 index 000000000..90e799c96 --- /dev/null +++ b/sync-for-commerce/src/funcs/syncGetStatus.ts @@ -0,0 +1,153 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Get sync status + * + * @remarks + * Gets a list of sync statuses. + */ +export async function syncGetStatus( + client: CodatSyncCommerceCore, + request: operations.GetSyncStatusRequest, + options?: RequestOptions, +): Promise< + Result< + shared.SyncStatus, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => operations.GetSyncStatusRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const pathParams = { + companyId: encodeSimple("companyId", payload.companyId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc("/meta/companies/{companyId}/sync/commerce/status")( + pathParams, + ); + + const headers = new Headers({ + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "get-sync-status", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.SyncStatus, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.SyncStatus$inboundSchema), + M.jsonErr( + [401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/syncList.ts b/sync-for-commerce/src/funcs/syncList.ts new file mode 100644 index 000000000..805913476 --- /dev/null +++ b/sync-for-commerce/src/funcs/syncList.ts @@ -0,0 +1,154 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * List sync statuses + * + * @remarks + * Gets a list of sync statuses + */ +export async function syncList( + client: CodatSyncCommerceCore, + request: operations.ListSyncsRequest, + options?: RequestOptions, +): Promise< + Result< + Array, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => operations.ListSyncsRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const pathParams = { + companyId: encodeSimple("companyId", payload.companyId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc( + "/companies/{companyId}/sync/commerce/syncs/list/status", + )(pathParams); + + const headers = new Headers({ + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "list-syncs", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + Array, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, z.array(shared.CompanySyncStatus$inboundSchema)), + M.jsonErr( + [401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/syncRequest.ts b/sync-for-commerce/src/funcs/syncRequest.ts new file mode 100644 index 000000000..55dcec98e --- /dev/null +++ b/sync-for-commerce/src/funcs/syncRequest.ts @@ -0,0 +1,165 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeJSON, encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Initiate new sync + * + * @remarks + * Run a Commerce sync from the last successful sync up to the date provided (optional), otherwise UtcNow is used.\r\nIf there was no previously successful sync, the start date in the config is used. + */ +export async function syncRequest( + client: CodatSyncCommerceCore, + request: operations.RequestSyncRequest, + options?: RequestOptions, +): Promise< + Result< + shared.SyncSummary, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => operations.RequestSyncRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = encodeJSON("body", payload.SyncToLatestArgs, { explode: true }); + + const pathParams = { + companyId: encodeSimple("companyId", payload.companyId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc("/companies/{companyId}/sync/commerce/latest")( + pathParams, + ); + + const headers = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "request-sync", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: [ + "400", + "401", + "402", + "403", + "404", + "429", + "4XX", + "500", + "503", + "5XX", + ], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.SyncSummary, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.SyncSummary$inboundSchema), + M.jsonErr( + [400, 401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/funcs/syncRequestForDateRange.ts b/sync-for-commerce/src/funcs/syncRequestForDateRange.ts new file mode 100644 index 000000000..b42b06c70 --- /dev/null +++ b/sync-for-commerce/src/funcs/syncRequestForDateRange.ts @@ -0,0 +1,166 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { CodatSyncCommerceCore } from "../core.js"; +import { encodeJSON, encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import * as errors from "../sdk/models/errors/index.js"; +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import * as operations from "../sdk/models/operations/index.js"; +import * as shared from "../sdk/models/shared/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Initiate sync for specific range + * + * @remarks + * Initiate a sync for the specified start date to the specified finish date in the request payload. + */ +export async function syncRequestForDateRange( + client: CodatSyncCommerceCore, + request: operations.RequestSyncForDateRangeRequest, + options?: RequestOptions, +): Promise< + Result< + shared.SyncSummary, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => + operations.RequestSyncForDateRangeRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = encodeJSON("body", payload.SyncRange, { explode: true }); + + const pathParams = { + companyId: encodeSimple("companyId", payload.companyId, { + explode: false, + charEncoding: "percent", + }), + }; + + const path = pathToFunc("/meta/companies/{companyId}/sync/commerce/historic")( + pathParams, + ); + + const headers = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.authHeader); + const securityInput = secConfig == null ? {} : { authHeader: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "request-sync-for-date-range", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.authHeader, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: [ + "400", + "401", + "402", + "403", + "404", + "429", + "4XX", + "500", + "503", + "5XX", + ], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + shared.SyncSummary, + | errors.ErrorMessage + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, shared.SyncSummary$inboundSchema), + M.jsonErr( + [400, 401, 402, 403, 404, 429, 500, 503], + errors.ErrorMessage$inboundSchema, + ), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/sync-for-commerce/src/hooks/hooks.ts b/sync-for-commerce/src/hooks/hooks.ts index 6a1e31e06..d1b3396f5 100644 --- a/sync-for-commerce/src/hooks/hooks.ts +++ b/sync-for-commerce/src/hooks/hooks.ts @@ -1,103 +1,112 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { RequestInput } from "../lib/http.js"; import { - AfterErrorContext, - AfterErrorHook, - AfterSuccessContext, - AfterSuccessHook, - BeforeRequestContext, - BeforeRequestHook, - BeforeCreateRequestHook, - BeforeCreateRequestContext, - Hooks, - SDKInitHook, - SDKInitOptions, + AfterErrorContext, + AfterErrorHook, + AfterSuccessContext, + AfterSuccessHook, + BeforeCreateRequestContext, + BeforeCreateRequestHook, + BeforeRequestContext, + BeforeRequestHook, + Hooks, + SDKInitHook, + SDKInitOptions, } from "./types.js"; import { initHooks } from "./registration.js"; export class SDKHooks implements Hooks { - sdkInitHooks: SDKInitHook[] = []; - beforeCreateRequestHooks: BeforeCreateRequestHook[] = []; - beforeRequestHooks: BeforeRequestHook[] = []; - afterSuccessHooks: AfterSuccessHook[] = []; - afterErrorHooks: AfterErrorHook[] = []; - - constructor() { - initHooks(this); + sdkInitHooks: SDKInitHook[] = []; + beforeCreateRequestHooks: BeforeCreateRequestHook[] = []; + beforeRequestHooks: BeforeRequestHook[] = []; + afterSuccessHooks: AfterSuccessHook[] = []; + afterErrorHooks: AfterErrorHook[] = []; + + constructor() { + initHooks(this); + } + + registerSDKInitHook(hook: SDKInitHook) { + this.sdkInitHooks.push(hook); + } + + registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook) { + this.beforeCreateRequestHooks.push(hook); + } + + registerBeforeRequestHook(hook: BeforeRequestHook) { + this.beforeRequestHooks.push(hook); + } + + registerAfterSuccessHook(hook: AfterSuccessHook) { + this.afterSuccessHooks.push(hook); + } + + registerAfterErrorHook(hook: AfterErrorHook) { + this.afterErrorHooks.push(hook); + } + + sdkInit(opts: SDKInitOptions): SDKInitOptions { + return this.sdkInitHooks.reduce((opts, hook) => hook.sdkInit(opts), opts); + } + + beforeCreateRequest( + hookCtx: BeforeCreateRequestContext, + input: RequestInput, + ): RequestInput { + let inp = input; + + for (const hook of this.beforeCreateRequestHooks) { + inp = hook.beforeCreateRequest(hookCtx, inp); } - registerSDKInitHook(hook: SDKInitHook) { - this.sdkInitHooks.push(hook); - } + return inp; + } - registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook) { - this.beforeCreateRequestHooks.push(hook); - } + async beforeRequest( + hookCtx: BeforeRequestContext, + request: Request, + ): Promise { + let req = request; - registerBeforeRequestHook(hook: BeforeRequestHook) { - this.beforeRequestHooks.push(hook); + for (const hook of this.beforeRequestHooks) { + req = await hook.beforeRequest(hookCtx, req); } - registerAfterSuccessHook(hook: AfterSuccessHook) { - this.afterSuccessHooks.push(hook); - } + return req; + } - registerAfterErrorHook(hook: AfterErrorHook) { - this.afterErrorHooks.push(hook); - } + async afterSuccess( + hookCtx: AfterSuccessContext, + response: Response, + ): Promise { + let res = response; - sdkInit(opts: SDKInitOptions): SDKInitOptions { - return this.sdkInitHooks.reduce((opts, hook) => hook.sdkInit(opts), opts); + for (const hook of this.afterSuccessHooks) { + res = await hook.afterSuccess(hookCtx, res); } - beforeCreateRequest(hookCtx: BeforeCreateRequestContext, input: RequestInput): RequestInput { - let inp = input; - - for (const hook of this.beforeCreateRequestHooks) { - inp = hook.beforeCreateRequest(hookCtx, inp); - } - - return inp; + return res; + } + + async afterError( + hookCtx: AfterErrorContext, + response: Response | null, + error: unknown, + ): Promise<{ response: Response | null; error: unknown }> { + let res = response; + let err = error; + + for (const hook of this.afterErrorHooks) { + const result = await hook.afterError(hookCtx, res, err); + res = result.response; + err = result.error; } - async beforeRequest(hookCtx: BeforeRequestContext, request: Request): Promise { - let req = request; - - for (const hook of this.beforeRequestHooks) { - req = await hook.beforeRequest(hookCtx, req); - } - - return req; - } - - async afterSuccess(hookCtx: AfterSuccessContext, response: Response): Promise { - let res = response; - - for (const hook of this.afterSuccessHooks) { - res = await hook.afterSuccess(hookCtx, res); - } - - return res; - } - - async afterError( - hookCtx: AfterErrorContext, - response: Response | null, - error: unknown - ): Promise<{ response: Response | null; error: unknown }> { - let res = response; - let err = error; - - for (const hook of this.afterErrorHooks) { - const result = await hook.afterError(hookCtx, res, err); - res = result.response; - err = result.error; - } - - return { response: res, error: err }; - } + return { response: res, error: err }; + } } diff --git a/sync-for-commerce/src/hooks/index.ts b/sync-for-commerce/src/hooks/index.ts index d5fdd742f..f60ec7acd 100644 --- a/sync-for-commerce/src/hooks/index.ts +++ b/sync-for-commerce/src/hooks/index.ts @@ -1,6 +1,6 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export * from "./types.js"; export * from "./hooks.js"; +export * from "./types.js"; diff --git a/sync-for-commerce/src/hooks/types.ts b/sync-for-commerce/src/hooks/types.ts index dd23b024f..df5237dce 100644 --- a/sync-for-commerce/src/hooks/types.ts +++ b/sync-for-commerce/src/hooks/types.ts @@ -1,20 +1,24 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { HTTPClient, RequestInput } from "../lib/http.js"; +import { RetryConfig } from "../lib/retries.js"; +import { SecurityState } from "../lib/security.js"; export type HookContext = { - operationID: string; - oAuth2Scopes?: string[]; - securitySource?: any | (() => Promise); + operationID: string; + oAuth2Scopes?: string[]; + securitySource?: any | (() => Promise); + retryConfig: RetryConfig; + resolvedSecurity: SecurityState | null; }; export type Awaitable = T | Promise; export type SDKInitOptions = { - baseURL: URL | null; - client: HTTPClient; + baseURL: URL | null; + client: HTTPClient; }; export type BeforeCreateRequestContext = HookContext & {}; @@ -27,63 +31,72 @@ export type AfterErrorContext = HookContext & {}; * hook can return a new baseURL and HTTP client to be used by the SDK. */ export interface SDKInitHook { - sdkInit: (opts: SDKInitOptions) => SDKInitOptions; + sdkInit: (opts: SDKInitOptions) => SDKInitOptions; } export interface BeforeCreateRequestHook { - /** - * A hook that is called before the SDK creates a `Request` object. The hook - * can modify how a request is constructed since certain modifications, like - * changing the request URL, cannot be done on a request object directly. - */ - beforeCreateRequest: (hookCtx: BeforeCreateRequestContext, input: RequestInput) => RequestInput; + /** + * A hook that is called before the SDK creates a `Request` object. The hook + * can modify how a request is constructed since certain modifications, like + * changing the request URL, cannot be done on a request object directly. + */ + beforeCreateRequest: ( + hookCtx: BeforeCreateRequestContext, + input: RequestInput, + ) => RequestInput; } export interface BeforeRequestHook { - /** - * A hook that is called before the SDK sends a request. The hook can - * introduce instrumentation code such as logging, tracing and metrics or - * replace the request before it is sent or throw an error to stop the - * request from being sent. - */ - beforeRequest: (hookCtx: BeforeRequestContext, request: Request) => Awaitable; + /** + * A hook that is called before the SDK sends a request. The hook can + * introduce instrumentation code such as logging, tracing and metrics or + * replace the request before it is sent or throw an error to stop the + * request from being sent. + */ + beforeRequest: ( + hookCtx: BeforeRequestContext, + request: Request, + ) => Awaitable; } export interface AfterSuccessHook { - /** - * A hook that is called after the SDK receives a response. The hook can - * introduce instrumentation code such as logging, tracing and metrics or - * modify the response before it is handled or throw an error to stop the - * response from being handled. - */ - afterSuccess: (hookCtx: AfterSuccessContext, response: Response) => Awaitable; + /** + * A hook that is called after the SDK receives a response. The hook can + * introduce instrumentation code such as logging, tracing and metrics or + * modify the response before it is handled or throw an error to stop the + * response from being handled. + */ + afterSuccess: ( + hookCtx: AfterSuccessContext, + response: Response, + ) => Awaitable; } export interface AfterErrorHook { - /** - * A hook that is called after the SDK encounters an error, or a - * non-successful response. The hook can introduce instrumentation code such - * as logging, tracing and metrics or modify the response or error values. - */ - afterError: ( - hookCtx: AfterErrorContext, - response: Response | null, - error: unknown - ) => Awaitable<{ - response: Response | null; - error: unknown; - }>; + /** + * A hook that is called after the SDK encounters an error, or a + * non-successful response. The hook can introduce instrumentation code such + * as logging, tracing and metrics or modify the response or error values. + */ + afterError: ( + hookCtx: AfterErrorContext, + response: Response | null, + error: unknown, + ) => Awaitable<{ + response: Response | null; + error: unknown; + }>; } export interface Hooks { - /** Registers a hook to be used by the SDK for initialization event. */ - registerSDKInitHook(hook: SDKInitHook): void; - /** Registers a hook to be used by the SDK for to modify `Request` construction. */ - registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook): void; - /** Registers a hook to be used by the SDK for the before request event. */ - registerBeforeRequestHook(hook: BeforeRequestHook): void; - /** Registers a hook to be used by the SDK for the after success event. */ - registerAfterSuccessHook(hook: AfterSuccessHook): void; - /** Registers a hook to be used by the SDK for the after error event. */ - registerAfterErrorHook(hook: AfterErrorHook): void; + /** Registers a hook to be used by the SDK for initialization event. */ + registerSDKInitHook(hook: SDKInitHook): void; + /** Registers a hook to be used by the SDK for to modify `Request` construction. */ + registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook): void; + /** Registers a hook to be used by the SDK for the before request event. */ + registerBeforeRequestHook(hook: BeforeRequestHook): void; + /** Registers a hook to be used by the SDK for the after success event. */ + registerAfterSuccessHook(hook: AfterSuccessHook): void; + /** Registers a hook to be used by the SDK for the after error event. */ + registerAfterErrorHook(hook: AfterErrorHook): void; } diff --git a/sync-for-commerce/src/index.ts b/sync-for-commerce/src/index.ts index 8bc6ae3ed..5ddc765ed 100644 --- a/sync-for-commerce/src/index.ts +++ b/sync-for-commerce/src/index.ts @@ -1,6 +1,7 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export * from "./sdk/sdk.js"; export * from "./lib/config.js"; +export * as files from "./lib/files.js"; +export * from "./sdk/sdk.js"; diff --git a/sync-for-commerce/src/lib/base64.ts b/sync-for-commerce/src/lib/base64.ts index cda076411..c2d5b3898 100644 --- a/sync-for-commerce/src/lib/base64.ts +++ b/sync-for-commerce/src/lib/base64.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; diff --git a/sync-for-commerce/src/lib/config.ts b/sync-for-commerce/src/lib/config.ts index a167e570e..d2b75bb38 100644 --- a/sync-for-commerce/src/lib/config.ts +++ b/sync-for-commerce/src/lib/config.ts @@ -1,8 +1,9 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { HTTPClient } from "./http.js"; +import { Logger } from "./logger.js"; import { RetryConfig } from "./retries.js"; import { Params, pathToFunc } from "./url.js"; @@ -10,52 +11,54 @@ import { Params, pathToFunc } from "./url.js"; * Contains the list of servers available to the SDK */ export const ServerList = [ - /** - * Production - */ - "https://api.codat.io", + /** + * Production + */ + "https://api.codat.io", ] as const; export type SDKOptions = { - authHeader?: string | (() => Promise); - - httpClient?: HTTPClient; - /** - * Allows overriding the default server used by the SDK - */ - serverIdx?: number; - /** - * Allows overriding the default server URL used by the SDK - */ - serverURL?: string; - /** - * Allows overriding the default retry config used by the SDK - */ - retryConfig?: RetryConfig; - timeoutMs?: number; + authHeader?: string | (() => Promise); + + httpClient?: HTTPClient; + /** + * Allows overriding the default server used by the SDK + */ + serverIdx?: number; + /** + * Allows overriding the default server URL used by the SDK + */ + serverURL?: string; + /** + * Allows overriding the default retry config used by the SDK + */ + retryConfig?: RetryConfig; + timeoutMs?: number; + debugLogger?: Logger; }; export function serverURLFromOptions(options: SDKOptions): URL | null { - let serverURL = options.serverURL; + let serverURL = options.serverURL; - const params: Params = {}; + const params: Params = {}; - if (!serverURL) { - const serverIdx = options.serverIdx ?? 0; - if (serverIdx < 0 || serverIdx >= ServerList.length) { - throw new Error(`Invalid server index ${serverIdx}`); - } - serverURL = ServerList[serverIdx] || ""; + if (!serverURL) { + const serverIdx = options.serverIdx ?? 0; + if (serverIdx < 0 || serverIdx >= ServerList.length) { + throw new Error(`Invalid server index ${serverIdx}`); } + serverURL = ServerList[serverIdx] || ""; + } - const u = pathToFunc(serverURL)(params); - return new URL(u); + const u = pathToFunc(serverURL)(params); + return new URL(u); } export const SDK_METADATA = { - language: "typescript", - openapiDocVersion: "1.1", - sdkVersion: "4.0.0", - genVersion: "2.374.2", - userAgent: "speakeasy-sdk/typescript 4.0.0 2.374.2 1.1 @codat/sync-for-commerce", + language: "typescript", + openapiDocVersion: "1.1", + sdkVersion: "5.0.0", + genVersion: "2.462.1", + userAgent: + "speakeasy-sdk/typescript 5.0.0 2.462.1 1.1 @codat/sync-for-commerce", } as const; diff --git a/sync-for-commerce/src/lib/dlv.ts b/sync-for-commerce/src/lib/dlv.ts new file mode 100644 index 000000000..e81091f5e --- /dev/null +++ b/sync-for-commerce/src/lib/dlv.ts @@ -0,0 +1,53 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/* +MIT License + +Copyright (c) 2024 Jason Miller (http://jasonformat.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +/** + * @param obj The object to walk + * @param key The key path to walk the object with + * @param def A default value to return if the result is undefined + * + * @example + * dlv(obj, "a.b.c.d") + * @example + * dlv(object, ["a", "b", "c", "d"]) + * @example + * dlv(object, "foo.bar.baz", "Hello, default value!") + */ +export function dlv( + obj: any, + key: string | string[], + def?: T, + p?: number, + undef?: never, +): T | undefined { + key = Array.isArray(key) ? key : key.split("."); + for (p = 0; p < key.length; p++) { + const k = key[p]; + obj = k != null && obj ? obj[k] : undef; + } + return obj === undef ? def : obj; +} diff --git a/sync-for-commerce/src/lib/encodings.ts b/sync-for-commerce/src/lib/encodings.ts index 49f536b65..44fa72840 100644 --- a/sync-for-commerce/src/lib/encodings.ts +++ b/sync-for-commerce/src/lib/encodings.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { bytesToBase64 } from "./base64.js"; @@ -212,6 +212,24 @@ export function encodeDeepObject( return ""; } + if (!isPlainObject(value)) { + throw new EncodingError( + `Value of parameter '${key}' which uses deepObject encoding must be an object`, + ); + } + + return encodeDeepObjectObject(key, value, options); +} + +export function encodeDeepObjectObject( + key: string, + value: unknown, + options?: { charEncoding?: "percent" | "none" }, +): string { + if (value == null) { + return ""; + } + let out = ""; const encodeString = (v: string) => { @@ -219,9 +237,7 @@ export function encodeDeepObject( }; if (!isPlainObject(value)) { - throw new EncodingError( - `Value of parameter '${key}' which uses deepObject encoding must be an object`, - ); + throw new EncodingError(`Expected parameter '${key}' to be an object.`); } Object.entries(value).forEach(([ck, cv]) => { @@ -232,9 +248,11 @@ export function encodeDeepObject( const pk = `${key}[${ck}]`; if (isPlainObject(cv)) { - throw new EncodingError( - `Value of parameter field '${pk}' cannot be an array or object.`, - ); + const objOut = encodeDeepObjectObject(pk, cv, options); + + out += `&${objOut}`; + + return; } const pairs: unknown[] = Array.isArray(cv) ? cv : [cv]; diff --git a/sync-for-commerce/src/lib/files.ts b/sync-for-commerce/src/lib/files.ts new file mode 100644 index 000000000..19e08041f --- /dev/null +++ b/sync-for-commerce/src/lib/files.ts @@ -0,0 +1,40 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/** + * Consumes a stream and returns a concatenated array buffer. Useful in + * situations where we need to read the whole file because it forms part of a + * larger payload containing other fields, and we can't modify the underlying + * request structure. + */ +export async function readableStreamToArrayBuffer( + readable: ReadableStream, +): Promise { + const reader = readable.getReader(); + const chunks: Uint8Array[] = []; + + let totalLength = 0; + let done = false; + + while (!done) { + const { value, done: doneReading } = await reader.read(); + + if (doneReading) { + done = true; + } else { + chunks.push(value); + totalLength += value.length; + } + } + + const concatenatedChunks = new Uint8Array(totalLength); + let offset = 0; + + for (const chunk of chunks) { + concatenatedChunks.set(chunk, offset); + offset += chunk.length; + } + + return concatenatedChunks.buffer; +} diff --git a/sync-for-commerce/src/lib/http.ts b/sync-for-commerce/src/lib/http.ts index 83c3fd7a7..13cf1fd78 100644 --- a/sync-for-commerce/src/lib/http.ts +++ b/sync-for-commerce/src/lib/http.ts @@ -1,41 +1,39 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { never as znever } from "zod"; -import { parse } from "./schemas.js"; -import { isPlainObject } from "./is-plain-object.js"; -import { SDKError } from "../sdk/models/errors/sdkerror.js"; - -export type Fetcher = (input: RequestInfo | URL, init?: RequestInit) => Promise; +export type Fetcher = ( + input: RequestInfo | URL, + init?: RequestInit, +) => Promise; export type Awaitable = T | Promise; const DEFAULT_FETCHER: Fetcher = (input, init) => { - // If input is a Request and init is undefined, Bun will discard the method, - // headers, body and other options that were set on the request object. - // Node.js and browers would ignore an undefined init value. This check is - // therefore needed for interop with Bun. - if (init == null) { - return fetch(input); - } else { - return fetch(input, init); - } + // If input is a Request and init is undefined, Bun will discard the method, + // headers, body and other options that were set on the request object. + // Node.js and browers would ignore an undefined init value. This check is + // therefore needed for interop with Bun. + if (init == null) { + return fetch(input); + } else { + return fetch(input, init); + } }; export type RequestInput = { - /** - * The URL the request will use. - */ - url: URL; - /** - * Options used to create a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). - */ - options?: RequestInit | undefined; + /** + * The URL the request will use. + */ + url: URL; + /** + * Options used to create a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). + */ + options?: RequestInit | undefined; }; export interface HTTPClientOptions { - fetcher?: Fetcher; + fetcher?: Fetcher; } export type BeforeRequestHook = (req: Request) => Awaitable; @@ -43,114 +41,114 @@ export type RequestErrorHook = (err: unknown, req: Request) => Awaitable; export type ResponseHook = (res: Response, req: Request) => Awaitable; export class HTTPClient { - private fetcher: Fetcher; - private requestHooks: BeforeRequestHook[] = []; - private requestErrorHooks: RequestErrorHook[] = []; - private responseHooks: ResponseHook[] = []; - - constructor(private options: HTTPClientOptions = {}) { - this.fetcher = options.fetcher || DEFAULT_FETCHER; + private fetcher: Fetcher; + private requestHooks: BeforeRequestHook[] = []; + private requestErrorHooks: RequestErrorHook[] = []; + private responseHooks: ResponseHook[] = []; + + constructor(private options: HTTPClientOptions = {}) { + this.fetcher = options.fetcher || DEFAULT_FETCHER; + } + + async request(request: Request): Promise { + let req = request; + for (const hook of this.requestHooks) { + const nextRequest = await hook(req); + if (nextRequest) { + req = nextRequest; + } } - async request(request: Request): Promise { - let req = request; - for (const hook of this.requestHooks) { - const nextRequest = await hook(req); - if (nextRequest) { - req = nextRequest; - } - } - - try { - const res = await this.fetcher(req); - - for (const hook of this.responseHooks) { - await hook(res, req); - } - - return res; - } catch (err) { - for (const hook of this.requestErrorHooks) { - await hook(err, req); - } - - throw err; - } - } + try { + const res = await this.fetcher(req); + + for (const hook of this.responseHooks) { + await hook(res, req); + } + + return res; + } catch (err) { + for (const hook of this.requestErrorHooks) { + await hook(err, req); + } - /** - * Registers a hook that is called before a request is made. The hook function - * can mutate the request or return a new request. This may be useful to add - * additional information to request such as request IDs and tracing headers. - */ - addHook(hook: "beforeRequest", fn: BeforeRequestHook): this; - /** - * Registers a hook that is called when a request cannot be made due to a - * network error. - */ - addHook(hook: "requestError", fn: RequestErrorHook): this; - /** - * Registers a hook that is called when a response has been received from the - * server. - */ - addHook(hook: "response", fn: ResponseHook): this; - addHook( - ...args: - | [hook: "beforeRequest", fn: BeforeRequestHook] - | [hook: "requestError", fn: RequestErrorHook] - | [hook: "response", fn: ResponseHook] - ) { - if (args[0] === "beforeRequest") { - this.requestHooks.push(args[1]); - } else if (args[0] === "requestError") { - this.requestErrorHooks.push(args[1]); - } else if (args[0] === "response") { - this.responseHooks.push(args[1]); - } else { - throw new Error(`Invalid hook type: ${args[0]}`); - } - return this; + throw err; + } + } + + /** + * Registers a hook that is called before a request is made. The hook function + * can mutate the request or return a new request. This may be useful to add + * additional information to request such as request IDs and tracing headers. + */ + addHook(hook: "beforeRequest", fn: BeforeRequestHook): this; + /** + * Registers a hook that is called when a request cannot be made due to a + * network error. + */ + addHook(hook: "requestError", fn: RequestErrorHook): this; + /** + * Registers a hook that is called when a response has been received from the + * server. + */ + addHook(hook: "response", fn: ResponseHook): this; + addHook( + ...args: + | [hook: "beforeRequest", fn: BeforeRequestHook] + | [hook: "requestError", fn: RequestErrorHook] + | [hook: "response", fn: ResponseHook] + ) { + if (args[0] === "beforeRequest") { + this.requestHooks.push(args[1]); + } else if (args[0] === "requestError") { + this.requestErrorHooks.push(args[1]); + } else if (args[0] === "response") { + this.responseHooks.push(args[1]); + } else { + throw new Error(`Invalid hook type: ${args[0]}`); + } + return this; + } + + /** Removes a hook that was previously registered with `addHook`. */ + removeHook(hook: "beforeRequest", fn: BeforeRequestHook): this; + /** Removes a hook that was previously registered with `addHook`. */ + removeHook(hook: "requestError", fn: RequestErrorHook): this; + /** Removes a hook that was previously registered with `addHook`. */ + removeHook(hook: "response", fn: ResponseHook): this; + removeHook( + ...args: + | [hook: "beforeRequest", fn: BeforeRequestHook] + | [hook: "requestError", fn: RequestErrorHook] + | [hook: "response", fn: ResponseHook] + ): this { + let target: unknown[]; + if (args[0] === "beforeRequest") { + target = this.requestHooks; + } else if (args[0] === "requestError") { + target = this.requestErrorHooks; + } else if (args[0] === "response") { + target = this.responseHooks; + } else { + throw new Error(`Invalid hook type: ${args[0]}`); } - /** Removes a hook that was previously registered with `addHook`. */ - removeHook(hook: "beforeRequest", fn: BeforeRequestHook): this; - /** Removes a hook that was previously registered with `addHook`. */ - removeHook(hook: "requestError", fn: RequestErrorHook): this; - /** Removes a hook that was previously registered with `addHook`. */ - removeHook(hook: "response", fn: ResponseHook): this; - removeHook( - ...args: - | [hook: "beforeRequest", fn: BeforeRequestHook] - | [hook: "requestError", fn: RequestErrorHook] - | [hook: "response", fn: ResponseHook] - ): this { - let target: unknown[]; - if (args[0] === "beforeRequest") { - target = this.requestHooks; - } else if (args[0] === "requestError") { - target = this.requestErrorHooks; - } else if (args[0] === "response") { - target = this.responseHooks; - } else { - throw new Error(`Invalid hook type: ${args[0]}`); - } - - const index = target.findIndex((v) => v === args[1]); - if (index >= 0) { - target.splice(index, 1); - } - - return this; + const index = target.findIndex((v) => v === args[1]); + if (index >= 0) { + target.splice(index, 1); } - clone(): HTTPClient { - const child = new HTTPClient(this.options); - child.requestHooks = this.requestHooks.slice(); - child.requestErrorHooks = this.requestErrorHooks.slice(); - child.responseHooks = this.responseHooks.slice(); + return this; + } - return child; - } + clone(): HTTPClient { + const child = new HTTPClient(this.options); + child.requestHooks = this.requestHooks.slice(); + child.requestErrorHooks = this.requestErrorHooks.slice(); + child.responseHooks = this.responseHooks.slice(); + + return child; + } } export type StatusCodePredicate = number | string | (number | string)[]; @@ -159,351 +157,167 @@ export type StatusCodePredicate = number | string | (number | string)[]; // segments in a media type string. const mediaParamSeparator = /\s*;\s*/g; -function matchContentType(response: Response, pattern: string): boolean { - // `*` is a special case which means anything is acceptable. - if (pattern === "*") { - return true; +export function matchContentType(response: Response, pattern: string): boolean { + // `*` is a special case which means anything is acceptable. + if (pattern === "*") { + return true; + } + + let contentType = + response.headers.get("content-type")?.trim() || "application/octet-stream"; + contentType = contentType.toLowerCase(); + + const wantParts = pattern.toLowerCase().trim().split(mediaParamSeparator); + const [wantType = "", ...wantParams] = wantParts; + + if (wantType.split("/").length !== 2) { + return false; + } + + const gotParts = contentType.split(mediaParamSeparator); + const [gotType = "", ...gotParams] = gotParts; + + const [type = "", subtype = ""] = gotType.split("/"); + if (!type || !subtype) { + return false; + } + + if ( + wantType !== "*/*" && + gotType !== wantType && + `${type}/*` !== wantType && + `*/${subtype}` !== wantType + ) { + return false; + } + + if (gotParams.length < wantParams.length) { + return false; + } + + const params = new Set(gotParams); + for (const wantParam of wantParams) { + if (!params.has(wantParam)) { + return false; } + } - let contentType = response.headers.get("content-type")?.trim() || "application/octet-stream"; - contentType = contentType.toLowerCase(); + return true; +} - const wantParts = pattern.toLowerCase().trim().split(mediaParamSeparator); - const [wantType = "", ...wantParams] = wantParts; +const codeRangeRE = new RegExp("^[0-9]xx$", "i"); - if (wantType.split("/").length !== 2) { - return false; - } +export function matchStatusCode( + response: Response, + codes: StatusCodePredicate, +): boolean { + const actual = `${response.status}`; + const expectedCodes = Array.isArray(codes) ? codes : [codes]; + if (!expectedCodes.length) { + return false; + } - const gotParts = contentType.split(mediaParamSeparator); - const [gotType = "", ...gotParams] = gotParts; + return expectedCodes.some((ec) => { + const code = `${ec}`; - const [type = "", subtype = ""] = gotType.split("/"); - if (!type || !subtype) { - return false; + if (code === "default") { + return true; } - if ( - wantType !== "*/*" && - gotType !== wantType && - `${type}/*` !== wantType && - `*/${subtype}` !== wantType - ) { - return false; + if (!codeRangeRE.test(`${code}`)) { + return code === actual; } - if (gotParams.length < wantParams.length) { - return false; + const expectFamily = code.charAt(0); + if (!expectFamily) { + throw new Error("Invalid status code range"); } - const params = new Set(gotParams); - for (const wantParam of wantParams) { - if (!params.has(wantParam)) { - return false; - } + const actualFamily = actual.charAt(0); + if (!actualFamily) { + throw new Error(`Invalid response status code: ${actual}`); } - return true; -} - -const codeRangeRE = new RegExp("^[0-9]xx$", "i"); - -export function matchStatusCode(response: Response, codes: StatusCodePredicate): boolean { - const actual = `${response.status}`; - const expectedCodes = Array.isArray(codes) ? codes : [codes]; - if (!expectedCodes.length) { - return false; - } - - return expectedCodes.some((ec) => { - const code = `${ec}`; - - if (code === "default") { - return true; - } - - if (!codeRangeRE.test(`${code}`)) { - return code === actual; - } - - const expectFamily = code.charAt(0); - if (!expectFamily) { - throw new Error("Invalid status code range"); - } - - const actualFamily = actual.charAt(0); - if (!actualFamily) { - throw new Error(`Invalid response status code: ${actual}`); - } - - return actualFamily === expectFamily; - }); + return actualFamily === expectFamily; + }); } export function matchResponse( - response: Response, - code: StatusCodePredicate, - contentTypePattern: string + response: Response, + code: StatusCodePredicate, + contentTypePattern: string, ): boolean { - return matchStatusCode(response, code) && matchContentType(response, contentTypePattern); -} - -const headerValRE = /, */; -export function unpackHeaders(headers: Headers): Record { - const out: Record = {}; - - for (const [k, v] of headers.entries()) { - out[k] = v.split(headerValRE); - } - - return out; + return ( + matchStatusCode(response, code) && + matchContentType(response, contentTypePattern) + ); } -type ResponseMatcherSchema = - | { parse: (data: unknown) => T } - | { inboundSchema: { parse: (data: unknown) => T } }; +/** + * Uses various heurisitics to determine if an error is a connection error. + */ +export function isConnectionError(err: unknown): boolean { + if (typeof err !== "object" || err == null) { + return false; + } -type SerializationMethod = "sse" | "json" | "rawBytes" | "rawStream" | "text" | "void" | "fail"; + // Covers fetch in Deno as well + const isBrowserErr = + err instanceof TypeError && + err.message.toLowerCase().startsWith("failed to fetch"); -const defaultContentTypes: Record = { - sse: "text/event-stream", - json: "application/json", - rawBytes: "application/octet-stream", - rawStream: "application/octet-stream", - text: "text/plain", - void: "", - fail: "", -}; + const isNodeErr = + err instanceof TypeError && + err.message.toLowerCase().startsWith("fetch failed"); -type ResponsePredicateMatch = { - method: SerializationMethod; - codes: StatusCodePredicate; - ctype: string; - schema: ResponseMatcherSchema; - hdrs: boolean; - key: string | undefined; - err: boolean; - fail: boolean; - sseSentinel?: string | undefined; -}; + const isBunErr = "name" in err && err.name === "ConnectionError"; -type ResponsePredicateOptions = { - /** Content type to match on. */ - ctype?: string; - /** Pass HTTP headers to deserializer. */ - hdrs?: boolean; - /** A value for an SSE event's data field that indicates a stream should be terminated. */ - sseSentinel?: string; -} & ( - | { - /** The result key to store the deserialized value into. */ - key?: string; - fail?: never; - err?: never; - } - | { - /** Indicates the matched response must throw the built-in error. */ - fail: true; - key?: never; - err?: never; - } - | { - /** Indicates the matched response is a custom error. */ - err: true; - key?: never; - fail?: never; - } -); - -export class ResponseMatcher { - private predicates: ResponsePredicateMatch[] = []; - - #any( - method: SerializationMethod, - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ) { - const ctype = opts?.ctype || defaultContentTypes[method]; - const hdrs = !!opts?.hdrs; - const key = opts?.key; - const err = !!opts?.err; - const fail = !!opts?.fail; - const sseSentinel = opts?.sseSentinel; - this.predicates.push({ - method, - codes, - ctype, - schema, - hdrs, - key, - err, - fail, - sseSentinel, - }); - return this; - } + const isGenericErr = + "code" in err && + typeof err.code === "string" && + err.code.toLowerCase() === "econnreset"; - json( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("json", codes, schema, opts); - } - bytes( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("rawBytes", codes, schema, opts); - } - stream( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("rawStream", codes, schema, opts); - } - text( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("text", codes, schema, opts); - } - sse( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: Omit - ): this { - return this.#any("sse", codes, schema, opts); - } - void( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: Pick - ): this { - return this.#any("void", codes, schema, opts); - } - fail(codes: StatusCodePredicate): this { - return this.#any("fail", codes, znever(), { fail: true }); - } - - async match( - response: Response, - // flat - options?: { - resultKey?: string; - extraFields?: Record; - } - ): Promise<[result: Result, rawData: unknown]> { - let pred: ResponsePredicateMatch | undefined; - for (const predicate of this.predicates) { - const { codes, ctype } = predicate; - if (ctype && matchResponse(response, codes, ctype)) { - pred = predicate; - break; - } else if (!ctype && matchStatusCode(response, codes)) { - pred = predicate; - break; - } - } - if (pred == null) { - const responseBody = await response.text(); - throw new SDKError( - "Unexpected API response status or content-type", - response, - responseBody - ); - } - - const { method, schema } = pred; - - let raw: unknown; - switch (method) { - case "json": - raw = await response.json(); - break; - case "rawBytes": - raw = await response.arrayBuffer(); - break; - case "rawStream": - raw = response.body; - break; - case "text": - raw = await response.text(); - break; - case "sse": - raw = response.body; - break; - case "void": - raw = await discardResponseBody(response); - break; - case "fail": - raw = await response.text(); - break; - default: - method satisfies never; - throw new Error(`Unsupported response type: ${method}`); - } - - const resultKey = pred.key || options?.resultKey; - let data: unknown; - if (pred.fail) { - throw new SDKError("API error occurred", response, typeof raw === "string" ? raw : ""); - } else if (pred.err) { - data = { - ...options?.extraFields, - ...(pred.hdrs ? { Headers: unpackHeaders(response.headers) } : null), - ...(isPlainObject(raw) ? raw : null), - }; - } else if (resultKey) { - data = { - ...options?.extraFields, - ...(pred.hdrs ? { Headers: unpackHeaders(response.headers) } : null), - [resultKey]: raw, - }; - } else if (pred.hdrs) { - data = { - ...options?.extraFields, - ...(pred.hdrs ? { Headers: unpackHeaders(response.headers) } : null), - ...(isPlainObject(raw) ? raw : null), - }; - } else { - data = raw; - } - - const parser = "inboundSchema" in schema ? schema.inboundSchema : schema; - const body = parse(data, (v: unknown) => parser.parse(v), "Response validation failed"); - - if (body instanceof Error) { - throw body; - } - - return [body, raw]; - } + return isBrowserErr || isNodeErr || isGenericErr || isBunErr; } /** - * Discards the response body to free up resources. - * - * To learn why this is need, see the undici docs: - * https://undici.nodejs.org/#/?id=garbage-collection + * Uses various heurisitics to determine if an error is a timeout error. */ -export async function discardResponseBody(res: Response) { - const reader = res.body?.getReader(); - if (reader == null) { - return; - } +export function isTimeoutError(err: unknown): boolean { + if (typeof err !== "object" || err == null) { + return false; + } + + // Fetch in browser, Node.js, Bun, Deno + const isNative = "name" in err && err.name === "TimeoutError"; + const isLegacyNative = "code" in err && err.code === 23; + + // Node.js HTTP client and Axios + const isGenericErr = + "code" in err && + typeof err.code === "string" && + err.code.toLowerCase() === "econnaborted"; + + return isNative || isLegacyNative || isGenericErr; +} - try { - let done = false; - while (!done) { - const res = await reader.read(); - done = res.done; - } - } finally { - reader.releaseLock(); - } +/** + * Uses various heurisitics to determine if an error is a abort error. + */ +export function isAbortError(err: unknown): boolean { + if (typeof err !== "object" || err == null) { + return false; + } + + // Fetch in browser, Node.js, Bun, Deno + const isNative = "name" in err && err.name === "AbortError"; + const isLegacyNative = "code" in err && err.code === 20; + + // Node.js HTTP client and Axios + const isGenericErr = + "code" in err && + typeof err.code === "string" && + err.code.toLowerCase() === "econnaborted"; + + return isNative || isLegacyNative || isGenericErr; } diff --git a/sync-for-commerce/src/lib/is-plain-object.ts b/sync-for-commerce/src/lib/is-plain-object.ts index af0d6e7e4..61070d3d7 100644 --- a/sync-for-commerce/src/lib/is-plain-object.ts +++ b/sync-for-commerce/src/lib/is-plain-object.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ /* diff --git a/sync-for-commerce/src/lib/logger.ts b/sync-for-commerce/src/lib/logger.ts new file mode 100644 index 000000000..d181f2937 --- /dev/null +++ b/sync-for-commerce/src/lib/logger.ts @@ -0,0 +1,9 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +export interface Logger { + group(label?: string): void; + groupEnd(): void; + log(message: any, ...args: any[]): void; +} diff --git a/sync-for-commerce/src/lib/matchers.ts b/sync-for-commerce/src/lib/matchers.ts new file mode 100644 index 000000000..948c33240 --- /dev/null +++ b/sync-for-commerce/src/lib/matchers.ts @@ -0,0 +1,322 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { SDKError } from "../sdk/models/errors/sdkerror.js"; +import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import { Result } from "../sdk/types/fp.js"; +import { matchResponse, matchStatusCode, StatusCodePredicate } from "./http.js"; +import { isPlainObject } from "./is-plain-object.js"; +import { safeParse } from "./schemas.js"; + +export type Encoding = + | "json" + | "text" + | "bytes" + | "stream" + | "sse" + | "nil" + | "fail"; + +const DEFAULT_CONTENT_TYPES: Record = { + json: "application/json", + text: "text/plain", + bytes: "application/octet-stream", + stream: "application/octet-stream", + sse: "text/event-stream", + nil: "*", + fail: "*", +}; + +type Schema = { parse(raw: unknown): T }; + +type MatchOptions = { + ctype?: string; + hdrs?: boolean; + key?: string; + sseSentinel?: string; +}; + +export type ValueMatcher = MatchOptions & { + enc: Encoding; + codes: StatusCodePredicate; + schema: Schema; +}; + +export type ErrorMatcher = MatchOptions & { + enc: Encoding; + codes: StatusCodePredicate; + schema: Schema; + err: true; +}; + +export type FailMatcher = { + enc: "fail"; + codes: StatusCodePredicate; +}; + +export type Matcher = ValueMatcher | ErrorMatcher | FailMatcher; + +export function jsonErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "json", codes, schema }; +} +export function json( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "json", codes, schema }; +} + +export function textErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "text", codes, schema }; +} +export function text( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "text", codes, schema }; +} + +export function bytesErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "bytes", codes, schema }; +} +export function bytes( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "bytes", codes, schema }; +} + +export function streamErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "stream", codes, schema }; +} +export function stream( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "stream", codes, schema }; +} + +export function sseErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "sse", codes, schema }; +} +export function sse( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "sse", codes, schema }; +} + +export function nilErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "nil", codes, schema }; +} +export function nil( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "nil", codes, schema }; +} + +export function fail(codes: StatusCodePredicate): FailMatcher { + return { enc: "fail", codes }; +} + +export type MatchedValue = Matchers extends Matcher[] + ? T + : never; +export type MatchedError = Matchers extends Matcher[] + ? E + : never; +export type MatchFunc = ( + response: Response, + options?: { resultKey?: string; extraFields?: Record }, +) => Promise<[result: Result, raw: unknown]>; + +export function match( + ...matchers: Array> +): MatchFunc { + return async function matchFunc( + response: Response, + options?: { resultKey?: string; extraFields?: Record }, + ): Promise< + [result: Result, raw: unknown] + > { + let raw: unknown; + let matcher: Matcher | undefined; + for (const match of matchers) { + const { codes } = match; + const ctpattern = "ctype" in match + ? match.ctype + : DEFAULT_CONTENT_TYPES[match.enc]; + if (ctpattern && matchResponse(response, codes, ctpattern)) { + matcher = match; + break; + } else if (!ctpattern && matchStatusCode(response, codes)) { + matcher = match; + break; + } + } + + if (!matcher) { + const responseBody = await response.text(); + return [{ + ok: false, + error: new SDKError( + "Unexpected API response status or content-type", + response, + responseBody, + ), + }, responseBody]; + } + + const encoding = matcher.enc; + switch (encoding) { + case "json": + raw = await response.json(); + break; + case "bytes": + raw = new Uint8Array(await response.arrayBuffer()); + break; + case "stream": + raw = response.body; + break; + case "text": + raw = await response.text(); + break; + case "sse": + raw = response.body; + break; + case "nil": + raw = await discardResponseBody(response); + break; + case "fail": + raw = await response.text(); + break; + default: + encoding satisfies never; + throw new Error(`Unsupported response type: ${encoding}`); + } + + if (matcher.enc === "fail") { + return [{ + ok: false, + error: new SDKError( + "API error occurred", + response, + typeof raw === "string" ? raw : "", + ), + }, raw]; + } + + const resultKey = matcher.key || options?.resultKey; + let data: unknown; + + if ("err" in matcher) { + data = { + ...options?.extraFields, + ...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null), + ...(isPlainObject(raw) ? raw : null), + }; + } else if (resultKey) { + data = { + ...options?.extraFields, + ...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null), + [resultKey]: raw, + }; + } else if (matcher.hdrs) { + data = { + ...options?.extraFields, + ...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null), + ...(isPlainObject(raw) ? raw : null), + }; + } else { + data = raw; + } + + if ("err" in matcher) { + const result = safeParse( + data, + (v: unknown) => matcher.schema.parse(v), + "Response validation failed", + ); + return [result.ok ? { ok: false, error: result.value } : result, raw]; + } else { + return [ + safeParse( + data, + (v: unknown) => matcher.schema.parse(v), + "Response validation failed", + ), + raw, + ]; + } + }; +} + +const headerValRE = /, */; +/** + * Iterates over a Headers object and returns an object with all the header + * entries. Values are represented as an array to account for repeated headers. + */ +export function unpackHeaders(headers: Headers): Record { + const out: Record = {}; + + for (const [k, v] of headers.entries()) { + out[k] = v.split(headerValRE); + } + + return out; +} + +/** + * Discards the response body to free up resources. + * + * To learn why this is need, see the undici docs: + * https://undici.nodejs.org/#/?id=garbage-collection + */ +export async function discardResponseBody(res: Response) { + const reader = res.body?.getReader(); + if (reader == null) { + return; + } + + try { + let done = false; + while (!done) { + const res = await reader.read(); + done = res.done; + } + } finally { + reader.releaseLock(); + } +} diff --git a/sync-for-commerce/src/lib/primitives.ts b/sync-for-commerce/src/lib/primitives.ts index d3aae30be..48b28674d 100644 --- a/sync-for-commerce/src/lib/primitives.ts +++ b/sync-for-commerce/src/lib/primitives.ts @@ -1,7 +1,27 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +class InvariantError extends Error { + constructor(message: string) { + super(message); + this.name = "InvariantError"; + } +} + +export function invariant( + condition: unknown, + message: string, +): asserts condition { + if (!condition) { + throw new InvariantError(message); + } +} + +export type ExactPartial = { + [P in keyof T]?: T[P] | undefined; +}; + export type Remap = { [k in keyof Inp as Mapping[k] extends string /* if we have a string mapping for this key then use it */ ? Mapping[k] diff --git a/sync-for-commerce/src/lib/retries.ts b/sync-for-commerce/src/lib/retries.ts index ed9b49595..93ebc8def 100644 --- a/sync-for-commerce/src/lib/retries.ts +++ b/sync-for-commerce/src/lib/retries.ts @@ -1,7 +1,9 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import { isConnectionError, isTimeoutError } from "./http.js"; + export type BackoffStrategy = { initialInterval: number; maxInterval: number; @@ -24,23 +26,44 @@ export type RetryConfig = retryConnectionErrors?: boolean; }; -class PermanentError extends Error { - inner: unknown; +/** + * PermanentError is an error that is not recoverable. Throwing this error will + * cause a retry loop to terminate. + */ +export class PermanentError extends Error { + /** The underlying cause of the error. */ + override readonly cause: unknown; + + constructor(message: string, options?: { cause?: unknown }) { + let msg = message; + if (options?.cause) { + msg += `: ${options.cause}`; + } - constructor(inner: unknown) { - super("Permanent error"); - this.inner = inner; + super(msg, options); + this.name = "PermanentError"; + // In older runtimes, the cause field would not have been assigned through + // the super() call. + if (typeof this.cause === "undefined") { + this.cause = options?.cause; + } Object.setPrototypeOf(this, PermanentError.prototype); } } -class TemporaryError extends Error { - res: Response; +/** + * TemporaryError is an error is used to signal that an HTTP request can be + * retried as part of a retry loop. If retry attempts are exhausted and this + * error is thrown, the response will be returned to the caller. + */ +export class TemporaryError extends Error { + response: Response; - constructor(res: Response) { - super("Temporary error"); - this.res = res; + constructor(message: string, response: Response) { + super(message); + this.response = response; + this.name = "TemporaryError"; Object.setPrototypeOf(this, TemporaryError.prototype); } @@ -78,11 +101,14 @@ function wrapFetcher( try { const res = await fn(); if (isRetryableResponse(res, options.statusCodes)) { - throw new TemporaryError(res); + throw new TemporaryError( + "Response failed with retryable status code", + res, + ); } return res; - } catch (err) { + } catch (err: unknown) { if (err instanceof TemporaryError) { throw err; } @@ -94,52 +120,11 @@ function wrapFetcher( throw err; } - throw new PermanentError(err); + throw new PermanentError("Permanent error", { cause: err }); } }; } -function isConnectionError(err: unknown) { - if (typeof err !== "object" || err == null) { - return false; - } - - // Covers fetch in Deno as well - const isBrowserErr = - err instanceof TypeError && - err.message.toLowerCase().startsWith("failed to fetch"); - - const isNodeErr = - err instanceof TypeError && - err.message.toLowerCase().startsWith("fetch failed"); - - const isBunErr = "name" in err && err.name === "ConnectionError"; - - const isGenericErr = - "code" in err && - typeof err.code === "string" && - err.code.toLowerCase() === "econnreset"; - - return isBrowserErr || isNodeErr || isGenericErr || isBunErr; -} - -function isTimeoutError(err: unknown) { - if (typeof err !== "object" || err == null) { - return false; - } - - // Fetch in browser, Node.js, Bun, Deno - const isNative = "name" in err && err.name === "TimeoutError"; - - // Node.js HTTP client and Axios - const isGenericErr = - "code" in err && - typeof err.code === "string" && - err.code.toLowerCase() === "econnaborted"; - - return isNative || isGenericErr; -} - const codeRangeRE = new RegExp("^[0-9]xx$", "i"); function isRetryableResponse(res: Response, statusCodes: string[]): boolean { @@ -178,37 +163,25 @@ async function retryBackoff( try { const res = await fn(); return res; - } catch (err) { + } catch (err: unknown) { if (err instanceof PermanentError) { - throw err.inner; + throw err.cause; } const elapsed = Date.now() - start; if (elapsed > maxElapsedTime) { if (err instanceof TemporaryError) { - return err.res; + return err.response; } throw err; } let retryInterval = 0; - if (err instanceof TemporaryError && err.res && err.res.headers) { - const retryVal = err.res.headers.get("retry-after") || ""; - if (retryVal != "") { - const parsedNumber = Number(retryVal); - if (!isNaN(parsedNumber) && Number.isInteger(parsedNumber)) { - retryInterval = parsedNumber * 1000; - } else { - const parsedDate = Date.parse(retryVal); - if (!isNaN(parsedDate)) { - const deltaMS = parsedDate - Date.now(); - retryInterval = deltaMS > 0 ? Math.ceil(deltaMS) : 0; - } - } - } + if (err instanceof TemporaryError) { + retryInterval = retryIntervalFromResponse(err.response); } - if (retryInterval == 0) { + if (retryInterval <= 0) { retryInterval = initialInterval * Math.pow(x, exponent) + Math.random() * 1000; } @@ -221,6 +194,26 @@ async function retryBackoff( } } +function retryIntervalFromResponse(res: Response): number { + const retryVal = res.headers.get("retry-after") || ""; + if (!retryVal) { + return 0; + } + + const parsedNumber = Number(retryVal); + if (Number.isInteger(parsedNumber)) { + return parsedNumber * 1000; + } + + const parsedDate = Date.parse(retryVal); + if (Number.isInteger(parsedDate)) { + const deltaMS = parsedDate - Date.now(); + return deltaMS > 0 ? Math.ceil(deltaMS) : 0; + } + + return 0; +} + async function delay(delay: number): Promise { return new Promise((resolve) => setTimeout(resolve, delay)); } diff --git a/sync-for-commerce/src/lib/schemas.ts b/sync-for-commerce/src/lib/schemas.ts index 390a82d21..a2ad30da3 100644 --- a/sync-for-commerce/src/lib/schemas.ts +++ b/sync-for-commerce/src/lib/schemas.ts @@ -1,56 +1,86 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { output, ZodEffects, ZodError, ZodObject, ZodRawShape, ZodTypeAny } from "zod"; +import { + output, + ZodEffects, + ZodError, + ZodObject, + ZodRawShape, + ZodTypeAny, +} from "zod"; import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js"; +import { ERR, OK, Result } from "../sdk/types/fp.js"; /** * Utility function that executes some code which may throw a ZodError. It * intercepts this error and converts it to an SDKValidationError so as to not * leak Zod implementation details to user code. */ -export function parse(rawValue: Inp, fn: (value: Inp) => Out, errorMessage: string): Out { - try { - return fn(rawValue); - } catch (err) { - if (err instanceof ZodError) { - throw new SDKValidationError(errorMessage, err, rawValue); - } - throw err; +export function parse( + rawValue: Inp, + fn: (value: Inp) => Out, + errorMessage: string, +): Out { + try { + return fn(rawValue); + } catch (err) { + if (err instanceof ZodError) { + throw new SDKValidationError(errorMessage, err, rawValue); } + throw err; + } +} + +/** + * Utility function that executes some code which may result in a ZodError. It + * intercepts this error and converts it to an SDKValidationError so as to not + * leak Zod implementation details to user code. + */ +export function safeParse( + rawValue: Inp, + fn: (value: Inp) => Out, + errorMessage: string, +): Result { + try { + return OK(fn(rawValue)); + } catch (err) { + return ERR(new SDKValidationError(errorMessage, err, rawValue)); + } } export function collectExtraKeys< - Shape extends ZodRawShape, - Catchall extends ZodTypeAny, - K extends string + Shape extends ZodRawShape, + Catchall extends ZodTypeAny, + K extends string, >( - obj: ZodObject, - extrasKey: K + obj: ZodObject, + extrasKey: K, ): ZodEffects< - typeof obj, - output> & { - [k in K]: Record>; - } + typeof obj, + & output> + & { + [k in K]: Record>; + } > { - return obj.transform((val) => { - const extras: Record> = {}; - const { shape } = obj; - for (const [key] of Object.entries(val)) { - if (key in shape) { - continue; - } + return obj.transform((val) => { + const extras: Record> = {}; + const { shape } = obj; + for (const [key] of Object.entries(val)) { + if (key in shape) { + continue; + } - const v = val[key]; - if (typeof v === "undefined") { - continue; - } + const v = val[key]; + if (typeof v === "undefined") { + continue; + } - extras[key] = v; - delete val[key]; - } + extras[key] = v; + delete val[key]; + } - return { ...val, [extrasKey]: extras }; - }); + return { ...val, [extrasKey]: extras }; + }); } diff --git a/sync-for-commerce/src/lib/sdks.ts b/sync-for-commerce/src/lib/sdks.ts index 6e43e8eb6..14e2d9371 100644 --- a/sync-for-commerce/src/lib/sdks.ts +++ b/sync-for-commerce/src/lib/sdks.ts @@ -1,210 +1,388 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ResponseMatcher, HTTPClient, matchStatusCode } from "./http.js"; -import { SecurityState, resolveSecurity, resolveGlobalSecurity } from "./security.js"; -import { retry, RetryConfig } from "./retries.js"; -import { pathToFunc } from "./url.js"; -import { encodeForm } from "./encodings.js"; -import { stringToBase64 } from "./base64.js"; -import { SDK_METADATA } from "./config.js"; import { SDKHooks } from "../hooks/hooks.js"; import { HookContext } from "../hooks/types.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../sdk/models/errors/httpclienterrors.js"; +import { ERR, OK, Result } from "../sdk/types/fp.js"; +import { stringToBase64 } from "./base64.js"; +import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "./config.js"; +import { encodeForm } from "./encodings.js"; +import { + HTTPClient, + isAbortError, + isConnectionError, + isTimeoutError, + matchContentType, + matchStatusCode, +} from "./http.js"; +import { Logger } from "./logger.js"; +import { retry, RetryConfig } from "./retries.js"; +import { SecurityState } from "./security.js"; export type RequestOptions = { - /** - * Sets a timeout, in milliseconds, on HTTP requests made by an SDK method. If - * `fetchOptions.signal` is set then it will take precedence over this option. - */ - timeoutMs?: number; - /** - * Set or override a retry policy on HTTP calls. - */ - retries?: RetryConfig; - /** - * Specifies the status codes which should be retried using the given retry policy. - */ - retryCodes?: string[]; - /** - * Sets various request options on the `fetch` call made by an SDK method. - * - * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options|Request} - */ - fetchOptions?: Omit; + /** + * Sets a timeout, in milliseconds, on HTTP requests made by an SDK method. If + * `fetchOptions.signal` is set then it will take precedence over this option. + */ + timeoutMs?: number; + /** + * Set or override a retry policy on HTTP calls. + */ + retries?: RetryConfig; + /** + * Specifies the status codes which should be retried using the given retry policy. + */ + retryCodes?: string[]; + /** + * Sets various request options on the `fetch` call made by an SDK method. + * + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options|Request} + */ + fetchOptions?: Omit; }; type RequestConfig = { - method: string; - path: string; - baseURL?: string | URL; - query?: string; - body?: RequestInit["body"]; - headers?: HeadersInit; - security?: SecurityState | null; - uaHeader?: string; - timeoutMs?: number; + method: string; + path: string; + baseURL?: string | URL; + query?: string; + body?: RequestInit["body"]; + headers?: HeadersInit; + security?: SecurityState | null; + uaHeader?: string; + timeoutMs?: number; }; const gt: unknown = typeof globalThis === "undefined" ? null : globalThis; -const webWorkerLike = - typeof gt === "object" && - gt != null && - "importScripts" in gt && - typeof gt["importScripts"] === "function"; -const isBrowserLike = - webWorkerLike || - (typeof navigator !== "undefined" && "serviceWorker" in navigator) || - (typeof window === "object" && typeof window.document !== "undefined"); +const webWorkerLike = typeof gt === "object" + && gt != null + && "importScripts" in gt + && typeof gt["importScripts"] === "function"; +const isBrowserLike = webWorkerLike + || (typeof navigator !== "undefined" && "serviceWorker" in navigator) + || (typeof window === "object" && typeof window.document !== "undefined"); export class ClientSDK { - private readonly client: HTTPClient; - protected readonly baseURL: URL | null; - protected readonly hooks$: SDKHooks; - - constructor(init: { client: HTTPClient; baseURL: URL | null; hooks: SDKHooks }) { - const url = init.baseURL; - if (url) { - url.pathname = url.pathname.replace(/\/+$/, "") + "/"; - } + readonly #httpClient: HTTPClient; + readonly #hooks: SDKHooks; + readonly #logger?: Logger | undefined; + protected readonly _baseURL: URL | null; + public readonly _options: SDKOptions & { hooks?: SDKHooks }; - this.hooks$ = init.hooks; - const { baseURL, client } = this.hooks$.sdkInit({ baseURL: url, client: init.client }); - this.baseURL = baseURL; - this.client = client; + constructor(options: SDKOptions = {}) { + const opt = options as unknown; + if ( + typeof opt === "object" + && opt != null + && "hooks" in opt + && opt.hooks instanceof SDKHooks + ) { + this.#hooks = opt.hooks; + } else { + this.#hooks = new SDKHooks(); } + this._options = { ...options, hooks: this.#hooks }; - protected createRequest$( - context: HookContext, - conf: RequestConfig, - options?: RequestOptions - ): Request { - const { method, path, query, headers: opHeaders, security } = conf; + const url = serverURLFromOptions(options); + if (url) { + url.pathname = url.pathname.replace(/\/+$/, "") + "/"; + } + const { baseURL, client } = this.#hooks.sdkInit({ + baseURL: url, + client: options.httpClient || new HTTPClient(), + }); + this._baseURL = baseURL; + this.#httpClient = client; + this.#logger = options.debugLogger; + } - const base = conf.baseURL ?? this.baseURL; - if (!base) { - throw new TypeError("No base URL provided for operation"); - } - const reqURL = new URL(base); - const inputURL = new URL(path, reqURL); + public _createRequest( + context: HookContext, + conf: RequestConfig, + options?: RequestOptions, + ): Result { + const { method, path, query, headers: opHeaders, security } = conf; - if (path) { - reqURL.pathname += inputURL.pathname.replace(/^\/+/, ""); - } + const base = conf.baseURL ?? this._baseURL; + if (!base) { + return ERR(new InvalidRequestError("No base URL provided for operation")); + } + const reqURL = new URL(base); + const inputURL = new URL(path, reqURL); - let finalQuery = query || ""; + if (path) { + reqURL.pathname += inputURL.pathname.replace(/^\/+/, ""); + } - const secQuery: string[] = []; - for (const [k, v] of Object.entries(security?.queryParams || {})) { - secQuery.push(encodeForm(k, v, { charEncoding: "percent" })); - } - if (secQuery.length) { - finalQuery += `&${secQuery.join("&")}`; - } + let finalQuery = query || ""; - if (finalQuery) { - const q = finalQuery.startsWith("&") ? finalQuery.slice(1) : finalQuery; - reqURL.search = `?${q}`; - } + const secQuery: string[] = []; + for (const [k, v] of Object.entries(security?.queryParams || {})) { + secQuery.push(encodeForm(k, v, { charEncoding: "percent" })); + } + if (secQuery.length) { + finalQuery += `&${secQuery.join("&")}`; + } - const headers = new Headers(opHeaders); + if (finalQuery) { + const q = finalQuery.startsWith("&") ? finalQuery.slice(1) : finalQuery; + reqURL.search = `?${q}`; + } - const username = security?.basic.username; - const password = security?.basic.password; - if (username != null || password != null) { - const encoded = stringToBase64([username || "", password || ""].join(":")); - headers.set("Authorization", `Basic ${encoded}`); - } + const headers = new Headers(opHeaders); - const securityHeaders = new Headers(security?.headers || {}); - for (const [k, v] of securityHeaders) { - headers.set(k, v); - } + const username = security?.basic.username; + const password = security?.basic.password; + if (username != null || password != null) { + const encoded = stringToBase64( + [username || "", password || ""].join(":"), + ); + headers.set("Authorization", `Basic ${encoded}`); + } - let cookie = headers.get("cookie") || ""; - for (const [k, v] of Object.entries(security?.cookies || {})) { - cookie += `; ${k}=${v}`; - } - cookie = cookie.startsWith("; ") ? cookie.slice(2) : cookie; - headers.set("cookie", cookie); + const securityHeaders = new Headers(security?.headers || {}); + for (const [k, v] of securityHeaders) { + headers.set(k, v); + } - const userHeaders = new Headers(options?.fetchOptions?.headers); - for (const [k, v] of userHeaders) { - headers.set(k, v); - } + let cookie = headers.get("cookie") || ""; + for (const [k, v] of Object.entries(security?.cookies || {})) { + cookie += `; ${k}=${v}`; + } + cookie = cookie.startsWith("; ") ? cookie.slice(2) : cookie; + headers.set("cookie", cookie); - // Only set user agent header in non-browser-like environments since CORS - // policy disallows setting it in browsers e.g. Chrome throws an error. - if (!isBrowserLike) { - headers.set(conf.uaHeader ?? "user-agent", SDK_METADATA.userAgent); - } + const userHeaders = new Headers(options?.fetchOptions?.headers); + for (const [k, v] of userHeaders) { + headers.set(k, v); + } - let fetchOptions = options?.fetchOptions; - if (!fetchOptions?.signal && conf.timeoutMs && conf.timeoutMs > 0) { - const timeoutSignal = AbortSignal.timeout(conf.timeoutMs); - if (!fetchOptions) { - fetchOptions = { signal: timeoutSignal }; - } else { - fetchOptions.signal = timeoutSignal; - } - } + // Only set user agent header in non-browser-like environments since CORS + // policy disallows setting it in browsers e.g. Chrome throws an error. + if (!isBrowserLike) { + headers.set(conf.uaHeader ?? "user-agent", SDK_METADATA.userAgent); + } - const input = this.hooks$.beforeCreateRequest(context, { - url: reqURL, - options: { - ...fetchOptions, - body: conf.body ?? null, - headers, - method, - }, - }); + let fetchOptions = options?.fetchOptions; + if (!fetchOptions?.signal && conf.timeoutMs && conf.timeoutMs > 0) { + const timeoutSignal = AbortSignal.timeout(conf.timeoutMs); + if (!fetchOptions) { + fetchOptions = { signal: timeoutSignal }; + } else { + fetchOptions.signal = timeoutSignal; + } + } - return new Request(input.url, input.options); + if (conf.body instanceof ReadableStream) { + if (!fetchOptions) { + fetchOptions = { + // @ts-expect-error see https://github.com/node-fetch/node-fetch/issues/1769 + duplex: "half", + }; + } else { + // @ts-expect-error see https://github.com/node-fetch/node-fetch/issues/1769 + fetchOptions.duplex = "half"; + } } - protected async do$( - request: Request, + let input; + try { + input = this.#hooks.beforeCreateRequest(context, { + url: reqURL, options: { - context: HookContext; - errorCodes: number | string | (number | string)[]; - retryConfig?: RetryConfig | undefined; - retryCodes?: string[] | undefined; - } - ): Promise { - const { context, errorCodes } = options; - const retryConfig = options.retryConfig || { strategy: "none" }; - const retryCodes = options.retryCodes || []; - - return retry( - async () => { - const req = request.clone(); - - let response = await this.client.request( - await this.hooks$.beforeRequest(context, req) - ); - - if (matchStatusCode(response, errorCodes)) { - const result = await this.hooks$.afterError(context, response, null); - if (result.error) { - throw result.error; - } - response = result.response || response; - } else { - response = await this.hooks$.afterSuccess(context, response); - } - - return response; - }, - { config: retryConfig, statusCodes: retryCodes } - ); + ...fetchOptions, + body: conf.body ?? null, + headers, + method, + }, + }); + } catch (err: unknown) { + return ERR( + new UnexpectedClientError("Create request hook failed to execute", { + cause: err, + }), + ); } - protected matcher(): ResponseMatcher { - return new ResponseMatcher(); + return OK(new Request(input.url, input.options)); + } + + public async _do( + request: Request, + options: { + context: HookContext; + errorCodes: number | string | (number | string)[]; + retryConfig: RetryConfig; + retryCodes: string[]; + }, + ): Promise< + Result< + Response, + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + | UnexpectedClientError + > + > { + const { context, errorCodes } = options; + + return retry( + async () => { + const req = await this.#hooks.beforeRequest(context, request.clone()); + await logRequest(this.#logger, req).catch((e) => + this.#logger?.log("Failed to log request:", e) + ); + + let response = await this.#httpClient.request(req); + + try { + if (matchStatusCode(response, errorCodes)) { + const result = await this.#hooks.afterError( + context, + response, + null, + ); + if (result.error) { + throw result.error; + } + response = result.response || response; + } else { + response = await this.#hooks.afterSuccess(context, response); + } + } finally { + await logResponse(this.#logger, response, req) + .catch(e => this.#logger?.log("Failed to log response:", e)); + } + + return response; + }, + { config: options.retryConfig, statusCodes: options.retryCodes }, + ).then( + (r) => OK(r), + (err) => { + switch (true) { + case isAbortError(err): + return ERR( + new RequestAbortedError("Request aborted by client", { + cause: err, + }), + ); + case isTimeoutError(err): + return ERR( + new RequestTimeoutError("Request timed out", { cause: err }), + ); + case isConnectionError(err): + return ERR( + new ConnectionError("Unable to make request", { cause: err }), + ); + default: + return ERR( + new UnexpectedClientError("Unexpected HTTP client error", { + cause: err, + }), + ); + } + }, + ); + } +} + +const jsonLikeContentTypeRE = /^application\/(?:.{0,100}\+)?json/; +async function logRequest(logger: Logger | undefined, req: Request) { + if (!logger) { + return; + } + + const contentType = req.headers.get("content-type"); + const ct = contentType?.split(";")[0] || ""; + + logger.group(`> Request: ${req.method} ${req.url}`); + + logger.group("Headers:"); + for (const [k, v] of req.headers.entries()) { + logger.log(`${k}: ${v}`); + } + logger.groupEnd(); + + logger.group("Body:"); + switch (true) { + case jsonLikeContentTypeRE.test(ct): + logger.log(await req.clone().json()); + break; + case ct.startsWith("text/"): + logger.log(await req.clone().text()); + break; + case ct === "multipart/form-data": { + const body = await req.clone().formData(); + for (const [k, v] of body) { + const vlabel = v instanceof Blob ? "" : v; + logger.log(`${k}: ${vlabel}`); + } + break; } + default: + logger.log(`<${contentType}>`); + break; + } + logger.groupEnd(); - protected templateURLComponent = pathToFunc; + logger.groupEnd(); +} + +async function logResponse( + logger: Logger | undefined, + res: Response, + req: Request, +) { + if (!logger) { + return; + } + + const contentType = res.headers.get("content-type"); + const ct = contentType?.split(";")[0] || ""; + + logger.group(`< Response: ${req.method} ${req.url}`); + logger.log("Status Code:", res.status, res.statusText); + + logger.group("Headers:"); + for (const [k, v] of res.headers.entries()) { + logger.log(`${k}: ${v}`); + } + logger.groupEnd(); + + logger.group("Body:"); + switch (true) { + case matchContentType(res, "application/json") + || jsonLikeContentTypeRE.test(ct): + logger.log(await res.clone().json()); + break; + case matchContentType(res, "text/event-stream"): + logger.log(`<${contentType}>`); + break; + case matchContentType(res, "text/*"): + logger.log(await res.clone().text()); + break; + case matchContentType(res, "multipart/form-data"): { + const body = await res.clone().formData(); + for (const [k, v] of body) { + const vlabel = v instanceof Blob ? "" : v; + logger.log(`${k}: ${vlabel}`); + } + break; + } + default: + logger.log(`<${contentType}>`); + break; + } + logger.groupEnd(); - protected resolveSecurity = resolveSecurity; - protected resolveGlobalSecurity = resolveGlobalSecurity; + logger.groupEnd(); } diff --git a/sync-for-commerce/src/lib/security.ts b/sync-for-commerce/src/lib/security.ts index 28dcb6c66..5d9f81476 100644 --- a/sync-for-commerce/src/lib/security.ts +++ b/sync-for-commerce/src/lib/security.ts @@ -1,182 +1,253 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as shared from "../sdk/models/shared/index.js"; +type OAuth2PasswordFlow = { + username: string; + password?: string | undefined; + clientID: string; + clientSecret?: string | undefined; + tokenURL: string; +}; + export enum SecurityErrorCode { - Incomplete = "incomplete", - UnrecognisedSecurityType = "unrecognized_security_type", + Incomplete = "incomplete", + UnrecognisedSecurityType = "unrecognized_security_type", } export class SecurityError extends Error { - constructor(public code: SecurityErrorCode, message: string) { - super(message); - this.name = "SecurityError"; - } - - static incomplete(): SecurityError { - return new SecurityError( - SecurityErrorCode.Incomplete, - "Security requirements not met in order to perform the operation" - ); - } - static unrecognizedType(type: string): SecurityError { - return new SecurityError( - SecurityErrorCode.UnrecognisedSecurityType, - `Unrecognised security type: ${type}` - ); - } + constructor( + public code: SecurityErrorCode, + message: string, + ) { + super(message); + this.name = "SecurityError"; + } + + static incomplete(): SecurityError { + return new SecurityError( + SecurityErrorCode.Incomplete, + "Security requirements not met in order to perform the operation", + ); + } + static unrecognizedType(type: string): SecurityError { + return new SecurityError( + SecurityErrorCode.UnrecognisedSecurityType, + `Unrecognised security type: ${type}`, + ); + } } export type SecurityState = { - basic: { username?: string | undefined; password?: string | undefined }; - headers: Record; - queryParams: Record; - cookies: Record; + basic: { username?: string | undefined; password?: string | undefined }; + headers: Record; + queryParams: Record; + cookies: Record; + oauth2: ({ type: "password" } & OAuth2PasswordFlow) | { type: "none" }; }; type SecurityInputBasic = { - type: "http:basic"; - value: { username?: string | undefined; password?: string | undefined } | null | undefined; + type: "http:basic"; + value: + | { username?: string | undefined; password?: string | undefined } + | null + | undefined; }; type SecurityInputBearer = { - type: "http:bearer"; - value: string | null | undefined; - fieldName: string; + type: "http:bearer"; + value: string | null | undefined; + fieldName: string; }; type SecurityInputAPIKey = { - type: "apiKey:header" | "apiKey:query" | "apiKey:cookie"; - value: string | null | undefined; - fieldName: string; + type: "apiKey:header" | "apiKey:query" | "apiKey:cookie"; + value: string | null | undefined; + fieldName: string; }; type SecurityInputOIDC = { - type: "openIdConnect"; - value: string | null | undefined; - fieldName: string; + type: "openIdConnect"; + value: string | null | undefined; + fieldName: string; }; type SecurityInputOAuth2 = { - type: "oauth2"; - value: string | null | undefined; - fieldName: string; + type: "oauth2"; + value: string | null | undefined; + fieldName: string; }; type SecurityInputOAuth2ClientCredentials = { - type: "oauth2:client_credentials"; - value: string | null | undefined; - fieldName: string; + type: "oauth2:client_credentials"; + value: + | { clientID?: string | undefined; clientSecret?: string | undefined } + | null + | undefined; +}; + +type SecurityInputOAuth2PasswordCredentials = { + type: "oauth2:password"; + value: + | string + | null + | undefined; + fieldName: string; +}; + +type SecurityInputCustom = { + type: "http:custom"; + value: any | null | undefined; + fieldName: string; }; export type SecurityInput = - | SecurityInputBasic - | SecurityInputBearer - | SecurityInputAPIKey - | SecurityInputOAuth2 - | SecurityInputOAuth2ClientCredentials - | SecurityInputOIDC; - -export function resolveSecurity(...options: SecurityInput[][]): SecurityState | null { - const state: SecurityState = { - basic: { username: "", password: "" }, - headers: {}, - queryParams: {}, - cookies: {}, - }; - - const option = options.find((opts) => { - return opts.every((o) => { - if (o.value == null) { - return false; - } else if (o.type === "http:basic") { - return o.value.username != null || o.value.password != null; - } else if (typeof o.value === "string") { - return !!o.value; - } else { - throw new Error( - `Unrecognized security type: ${o.type} (value type: ${typeof o.value})` - ); - } - }); - }); - if (option == null) { + | SecurityInputBasic + | SecurityInputBearer + | SecurityInputAPIKey + | SecurityInputOAuth2 + | SecurityInputOAuth2ClientCredentials + | SecurityInputOAuth2PasswordCredentials + | SecurityInputOIDC + | SecurityInputCustom; + +export function resolveSecurity( + ...options: SecurityInput[][] +): SecurityState | null { + const state: SecurityState = { + basic: { username: "", password: "" }, + headers: {}, + queryParams: {}, + cookies: {}, + oauth2: { type: "none" }, + }; + + const option = options.find((opts) => { + return opts.every((o) => { + if (o.value == null) { + return false; + } else if (o.type === "http:basic") { + return o.value.username != null || o.value.password != null; + } else if (o.type === "http:custom") { return null; + } else if (o.type === "oauth2:password") { + return ( + typeof o.value === "string" && !!o.value + ); + } else if (o.type === "oauth2:client_credentials") { + return o.value.clientID != null || o.value.clientSecret != null; + } else if (typeof o.value === "string") { + return !!o.value; + } else { + throw new Error( + `Unrecognized security type: ${o.type} (value type: ${typeof o + .value})`, + ); + } + }); + }); + if (option == null) { + return null; + } + + option.forEach((spec) => { + if (spec.value == null) { + return; } - option.forEach((spec) => { - if (spec.value == null) { - return; - } - - const { type } = spec; - - switch (type) { - case "apiKey:header": - state.headers[spec.fieldName] = spec.value; - break; - case "apiKey:query": - state.queryParams[spec.fieldName] = spec.value; - break; - case "apiKey:cookie": - state.cookies[spec.fieldName] = spec.value; - break; - case "http:basic": - applyBasic(state, spec); - break; - case "http:bearer": - applyBearer(state, spec); - break; - case "oauth2": - applyBearer(state, spec); - break; - case "oauth2:client_credentials": - break; - case "openIdConnect": - applyBearer(state, spec); - break; - default: - spec satisfies never; - throw SecurityError.unrecognizedType(type); - } - }); + const { type } = spec; + + switch (type) { + case "apiKey:header": + state.headers[spec.fieldName] = spec.value; + break; + case "apiKey:query": + state.queryParams[spec.fieldName] = spec.value; + break; + case "apiKey:cookie": + state.cookies[spec.fieldName] = spec.value; + break; + case "http:basic": + applyBasic(state, spec); + break; + case "http:custom": + break; + case "http:bearer": + applyBearer(state, spec); + break; + case "oauth2": + applyBearer(state, spec); + break; + case "oauth2:password": + applyBearer(state, spec); + break; + case "oauth2:client_credentials": + break; + case "openIdConnect": + applyBearer(state, spec); + break; + default: + spec satisfies never; + throw SecurityError.unrecognizedType(type); + } + }); - return state; + return state; } -function applyBasic(state: SecurityState, spec: SecurityInputBasic) { - if (spec.value == null) { - return; - } +function applyBasic( + state: SecurityState, + spec: SecurityInputBasic, +) { + if (spec.value == null) { + return; + } - state.basic = spec.value; + state.basic = spec.value; } function applyBearer( - state: SecurityState, - spec: SecurityInputBearer | SecurityInputOAuth2 | SecurityInputOIDC + state: SecurityState, + spec: + | SecurityInputBearer + | SecurityInputOAuth2 + | SecurityInputOIDC + | SecurityInputOAuth2PasswordCredentials, ) { - if (spec.value == null) { - return; - } + if (typeof spec.value !== "string" || !spec.value) { + return; + } - let value = spec.value; - if (value.slice(0, 7).toLowerCase() !== "bearer ") { - value = `Bearer ${value}`; - } + let value = spec.value; + if (value.slice(0, 7).toLowerCase() !== "bearer ") { + value = `Bearer ${value}`; + } - state.headers[spec.fieldName] = value; + state.headers[spec.fieldName] = value; } + export function resolveGlobalSecurity( - security: Partial | null | undefined + security: Partial | null | undefined, ): SecurityState | null { - return resolveSecurity([ - { - fieldName: "Authorization", - type: "apiKey:header", - value: security?.authHeader, - }, - ]); + return resolveSecurity( + [ + { + fieldName: "Authorization", + type: "apiKey:header", + value: security?.authHeader, + }, + ], + ); +} + +export async function extractSecurity< + T extends string | Record, +>(sec: T | (() => Promise) | undefined): Promise { + if (sec == null) { + return; + } + + return typeof sec === "function" ? sec() : sec; } diff --git a/sync-for-commerce/src/lib/url.ts b/sync-for-commerce/src/lib/url.ts index df58acbba..6bc6356e2 100644 --- a/sync-for-commerce/src/lib/url.ts +++ b/sync-for-commerce/src/lib/url.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ const hasOwn = Object.prototype.hasOwnProperty; diff --git a/sync-for-commerce/src/sdk/advancedcontrols.ts b/sync-for-commerce/src/sdk/advancedcontrols.ts index e66d4324d..798e196c2 100644 --- a/sync-for-commerce/src/sdk/advancedcontrols.ts +++ b/sync-for-commerce/src/sdk/advancedcontrols.ts @@ -1,434 +1,82 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks/hooks.js"; -import { SDKOptions, serverURLFromOptions } from "../lib/config.js"; -import { - encodeFormQuery as encodeFormQuery$, - encodeJSON as encodeJSON$, - encodeSimple as encodeSimple$, -} from "../lib/encodings.js"; -import { HTTPClient } from "../lib/http.js"; -import * as schemas$ from "../lib/schemas.js"; +import { advancedControlsCreateCompany } from "../funcs/advancedControlsCreateCompany.js"; +import { advancedControlsGetConfiguration } from "../funcs/advancedControlsGetConfiguration.js"; +import { advancedControlsListCompanies } from "../funcs/advancedControlsListCompanies.js"; +import { advancedControlsSetConfiguration } from "../funcs/advancedControlsSetConfiguration.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; -import * as errors from "./models/errors/index.js"; import * as operations from "./models/operations/index.js"; import * as shared from "./models/shared/index.js"; +import { unwrapAsync } from "./types/fp.js"; export class AdvancedControls extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - - /** - * List companies - * - * @remarks - * Returns a list of companies. - */ - async listCompanies( - request?: operations.ListCompaniesRequest | undefined, - options?: RequestOptions - ): Promise { - const input$ = typeof request === "undefined" ? {} : request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.ListCompaniesRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const path$ = this.templateURLComponent("/companies")(); - - const query$ = encodeFormQuery$({ - orderBy: payload$.orderBy, - page: payload$.page, - pageSize: payload$.pageSize, - query: payload$.query, - }); - - const headers$ = new Headers({ - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "list-companies", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["400", "401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.Companies$inboundSchema) - .json([400, 401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Create company - * - * @remarks - * Creates a Codat company - */ - async createCompany( - request?: shared.CreateCompany | undefined, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => shared.CreateCompany$outboundSchema.optional().parse(value$), - "Input validation failed" - ); - const body$ = - payload$ === undefined ? null : encodeJSON$("body", payload$, { explode: true }); - - const path$ = this.templateURLComponent("/companies")(); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "create-company", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["400", "401", "402", "403", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.Company$inboundSchema) - .json([400, 401, 402, 403, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Get company configuration - * - * @remarks - * Returns a company's commerce sync configuration'. - */ - async getConfiguration( - request: operations.GetConfigurationRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.GetConfigurationRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - companyId: encodeSimple$("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent("/config/companies/{companyId}/sync/commerce")( - pathParams$ - ); - - const query$ = ""; - - const headers$ = new Headers({ - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "get-configuration", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.Configuration$inboundSchema) - .json([401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Set configuration - * - * @remarks - * Sets a company's commerce sync configuration. - */ - async setConfiguration( - request: operations.SetConfigurationRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.SetConfigurationRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - companyId: encodeSimple$("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent("/config/companies/{companyId}/sync/commerce")( - pathParams$ - ); - - const query$ = ""; - - const headers$ = new Headers({ - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "set-configuration", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: [ - "400", - "401", - "402", - "403", - "404", - "409", - "429", - "4XX", - "500", - "503", - "5XX", - ], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.Configuration$inboundSchema) - .json( - [400, 401, 402, 403, 404, 409, 429, 500, 503], - errors.ErrorMessage$inboundSchema, - { err: true } - ) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } + /** + * List companies + * + * @remarks + * Returns a list of companies. + */ + async listCompanies( + request?: operations.ListCompaniesRequest | undefined, + options?: RequestOptions, + ): Promise { + return unwrapAsync(advancedControlsListCompanies( + this, + request, + options, + )); + } + + /** + * Create company + * + * @remarks + * Creates a Codat company + */ + async createCompany( + request?: shared.CreateCompany | undefined, + options?: RequestOptions, + ): Promise { + return unwrapAsync(advancedControlsCreateCompany( + this, + request, + options, + )); + } + + /** + * Get company configuration + * + * @remarks + * Returns a company's commerce sync configuration'. + */ + async getConfiguration( + request: operations.GetConfigurationRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(advancedControlsGetConfiguration( + this, + request, + options, + )); + } + + /** + * Set configuration + * + * @remarks + * Sets a company's commerce sync configuration. + */ + async setConfiguration( + request: operations.SetConfigurationRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(advancedControlsSetConfiguration( + this, + request, + options, + )); + } } diff --git a/sync-for-commerce/src/sdk/connections.ts b/sync-for-commerce/src/sdk/connections.ts index 86ea11154..ccb24faad 100644 --- a/sync-for-commerce/src/sdk/connections.ts +++ b/sync-for-commerce/src/sdk/connections.ts @@ -1,546 +1,102 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks/hooks.js"; -import { SDKOptions, serverURLFromOptions } from "../lib/config.js"; -import { - encodeFormQuery as encodeFormQuery$, - encodeJSON as encodeJSON$, - encodeSimple as encodeSimple$, -} from "../lib/encodings.js"; -import { HTTPClient } from "../lib/http.js"; -import * as schemas$ from "../lib/schemas.js"; +import { connectionsCreate } from "../funcs/connectionsCreate.js"; +import { connectionsGetSyncFlowUrl } from "../funcs/connectionsGetSyncFlowUrl.js"; +import { connectionsList } from "../funcs/connectionsList.js"; +import { connectionsUpdateAuthorization } from "../funcs/connectionsUpdateAuthorization.js"; +import { connectionsUpdateConnection } from "../funcs/connectionsUpdateConnection.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; -import * as errors from "./models/errors/index.js"; import * as operations from "./models/operations/index.js"; import * as shared from "./models/shared/index.js"; +import { unwrapAsync } from "./types/fp.js"; export class Connections extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - - /** - * Start new sync flow - * - * @remarks - * Create a new company and connections. Get a URL for Sync Flow, including a one time passcode. - */ - async getSyncFlowUrl( - request: operations.GetSyncFlowUrlRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.GetSyncFlowUrlRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - accountingKey: encodeSimple$("accountingKey", payload$.accountingKey, { - explode: false, - charEncoding: "percent", - }), - commerceKey: encodeSimple$("commerceKey", payload$.commerceKey, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent( - "/config/sync/commerce/{commerceKey}/{accountingKey}/start" - )(pathParams$); - - const query$ = encodeFormQuery$({ - merchantIdentifier: payload$.merchantIdentifier, - }); - - const headers$ = new Headers({ - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "get-sync-flow-url", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["400", "401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.SyncFlowUrl$inboundSchema) - .json([400, 401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * List connections - * - * @remarks - * List the connections for a company. - */ - async list( - request: operations.ListConnectionsRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.ListConnectionsRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - companyId: encodeSimple$("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent("/companies/{companyId}/connections")(pathParams$); - - const query$ = encodeFormQuery$({ - orderBy: payload$.orderBy, - page: payload$.page, - pageSize: payload$.pageSize, - query: payload$.query, - }); - - const headers$ = new Headers({ - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "list-connections", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["400", "401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.Connections$inboundSchema) - .json([400, 401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Create connection - * - * @remarks - * Creates a connection for the company by providing a valid `platformKey`. - * - * Use the [List Integrations](https://docs.codat.io/sync-for-sync-for-commerce-api#/operations/list-integrations) endpoint to access valid platform keys. - */ - async create( - request: operations.CreateConnectionRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.CreateConnectionRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = encodeJSON$("body", payload$.RequestBody, { explode: true }); - - const pathParams$ = { - companyId: encodeSimple$("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent("/companies/{companyId}/connections")(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "create-connection", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.Connection$inboundSchema) - .json([401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Update connection - * - * @remarks - * Update a data connection - */ - async updateConnection( - request: operations.UpdateConnectionRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.UpdateConnectionRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = encodeJSON$("body", payload$.UpdateConnection, { explode: true }); - - const pathParams$ = { - companyId: encodeSimple$("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - connectionId: encodeSimple$("connectionId", payload$.connectionId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent( - "/companies/{companyId}/connections/{connectionId}" - )(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "update-connection", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "PATCH", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.Connection$inboundSchema) - .json([401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Update authorization - * - * @remarks - * Update data connection's authorization. - */ - async updateAuthorization( - request: operations.UpdateConnectionAuthorizationRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => - operations.UpdateConnectionAuthorizationRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = encodeJSON$("body", payload$.RequestBody, { explode: true }); - - const pathParams$ = { - companyId: encodeSimple$("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - connectionId: encodeSimple$("connectionId", payload$.connectionId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent( - "/companies/{companyId}/connections/{connectionId}/authorization" - )(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "update-connection-authorization", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "PUT", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.Connection$inboundSchema) - .json([401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } + /** + * Start new sync flow + * + * @remarks + * Create a new company and connections. Get a URL for Sync Flow, including a one time passcode. + */ + async getSyncFlowUrl( + request: operations.GetSyncFlowUrlRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(connectionsGetSyncFlowUrl( + this, + request, + options, + )); + } + + /** + * List connections + * + * @remarks + * List the connections for a company. + */ + async list( + request: operations.ListConnectionsRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(connectionsList( + this, + request, + options, + )); + } + + /** + * Create connection + * + * @remarks + * Creates a connection for the company by providing a valid `platformKey`. + * + * Use the [List Integrations](https://docs.codat.io/platform-api#/operations/list-integrations) endpoint to access valid platform keys. + */ + async create( + request: operations.CreateConnectionRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(connectionsCreate( + this, + request, + options, + )); + } + + /** + * Update connection + * + * @remarks + * Update a data connection + */ + async updateConnection( + request: operations.UpdateConnectionRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(connectionsUpdateConnection( + this, + request, + options, + )); + } + + /** + * Update authorization + * + * @remarks + * Update data connection's authorization. + */ + async updateAuthorization( + request: operations.UpdateConnectionAuthorizationRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(connectionsUpdateAuthorization( + this, + request, + options, + )); + } } diff --git a/sync-for-commerce/src/sdk/index.ts b/sync-for-commerce/src/sdk/index.ts index 34a84fc27..ecac22648 100644 --- a/sync-for-commerce/src/sdk/index.ts +++ b/sync-for-commerce/src/sdk/index.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export * from "./sdk.js"; diff --git a/sync-for-commerce/src/sdk/integrations.ts b/sync-for-commerce/src/sdk/integrations.ts index c2569472f..2de5daf64 100644 --- a/sync-for-commerce/src/sdk/integrations.ts +++ b/sync-for-commerce/src/sdk/integrations.ts @@ -1,233 +1,46 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks/hooks.js"; -import { SDKOptions, serverURLFromOptions } from "../lib/config.js"; -import { - encodeFormQuery as encodeFormQuery$, - encodeSimple as encodeSimple$, -} from "../lib/encodings.js"; -import { HTTPClient } from "../lib/http.js"; -import * as schemas$ from "../lib/schemas.js"; +import { integrationsGetBranding } from "../funcs/integrationsGetBranding.js"; +import { integrationsList } from "../funcs/integrationsList.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; -import * as errors from "./models/errors/index.js"; import * as operations from "./models/operations/index.js"; import * as shared from "./models/shared/index.js"; +import { unwrapAsync } from "./types/fp.js"; export class Integrations extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - - /** - * List integrations - * - * @remarks - * Retrieve a list of available integrations support by data type and state of release. - */ - async list( - request?: operations.ListIntegrationsRequest | undefined, - options?: RequestOptions - ): Promise { - const input$ = typeof request === "undefined" ? {} : request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.ListIntegrationsRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const path$ = this.templateURLComponent("/config/integrations")(); - - const query$ = encodeFormQuery$({ - orderBy: payload$.orderBy, - page: payload$.page, - pageSize: payload$.pageSize, - query: payload$.query, - }); - - const headers$ = new Headers({ - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "list-integrations", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["400", "401", "402", "403", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.Integrations$inboundSchema) - .json([400, 401, 402, 403, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Get branding for an integration - * - * @remarks - * Retrieve Integration branding assets. - */ - async getBranding( - request: operations.GetIntegrationBrandingRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.GetIntegrationBrandingRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - platformKey: encodeSimple$("platformKey", payload$.platformKey, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent("/config/integrations/{platformKey}/branding")( - pathParams$ - ); - - const query$ = ""; - - const headers$ = new Headers({ - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "get-integration-branding", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.Branding$inboundSchema) - .json([401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } + /** + * List integrations + * + * @remarks + * Retrieve a list of available integrations support by data type and state of release. + */ + async list( + request?: operations.ListIntegrationsRequest | undefined, + options?: RequestOptions, + ): Promise { + return unwrapAsync(integrationsList( + this, + request, + options, + )); + } + + /** + * Get branding for an integration + * + * @remarks + * Retrieve Integration branding assets. + */ + async getBranding( + request: operations.GetIntegrationBrandingRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(integrationsGetBranding( + this, + request, + options, + )); + } } diff --git a/sync-for-commerce/src/sdk/models/errors/errormessage.ts b/sync-for-commerce/src/sdk/models/errors/errormessage.ts index 55220d375..5d7f59312 100644 --- a/sync-for-commerce/src/sdk/models/errors/errormessage.ts +++ b/sync-for-commerce/src/sdk/models/errors/errormessage.ts @@ -1,169 +1,156 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as shared from "../shared/index.js"; import * as z from "zod"; +import * as shared from "../shared/index.js"; /** - * Your `query` parameter was not correctly formed + * The request made is not valid. */ export type ErrorMessageData = { - /** - * The HTTP status code returned by the error. - */ - statusCode?: number | undefined; - /** - * Codat's service the returned the error. - */ - service?: string | undefined; - /** - * A brief description of the error. - */ - error?: string | undefined; - /** - * Unique identifier used to propagate to all downstream services and determine the source of the error. - */ - correlationId?: string | undefined; - /** - * A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. - */ - validation?: shared.ErrorValidation | null | undefined; - /** - * `True` if the error occurred transiently and can be retried. - */ - canBeRetried?: string | undefined; - /** - * Machine readable error code used to automate processes based on the code returned. - */ - detailedErrorCode?: number | undefined; + /** + * The HTTP status code returned by the error. + */ + statusCode?: number | undefined; + /** + * Codat's service the returned the error. + */ + service?: string | undefined; + /** + * A brief description of the error. + */ + error?: string | undefined; + /** + * Unique identifier used to propagate to all downstream services and determine the source of the error. + */ + correlationId?: string | undefined; + /** + * A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. + */ + validation?: shared.ErrorValidation | null | undefined; + /** + * `True` if the error occurred transiently and can be retried. + */ + canBeRetried?: string | undefined; + /** + * Machine readable error code used to automate processes based on the code returned. + */ + detailedErrorCode?: number | undefined; }; /** - * Your `query` parameter was not correctly formed + * The request made is not valid. */ export class ErrorMessage extends Error { - /** - * The HTTP status code returned by the error. - */ - statusCode?: number | undefined; - /** - * Codat's service the returned the error. - */ - service?: string | undefined; - /** - * A brief description of the error. - */ - error?: string | undefined; - /** - * Unique identifier used to propagate to all downstream services and determine the source of the error. - */ - correlationId?: string | undefined; - /** - * A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. - */ - validation?: shared.ErrorValidation | null | undefined; - /** - * `True` if the error occurred transiently and can be retried. - */ - canBeRetried?: string | undefined; - /** - * Machine readable error code used to automate processes based on the code returned. - */ - detailedErrorCode?: number | undefined; + /** + * The HTTP status code returned by the error. + */ + statusCode?: number | undefined; + /** + * Codat's service the returned the error. + */ + service?: string | undefined; + /** + * A brief description of the error. + */ + error?: string | undefined; + /** + * Unique identifier used to propagate to all downstream services and determine the source of the error. + */ + correlationId?: string | undefined; + /** + * A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. + */ + validation?: shared.ErrorValidation | null | undefined; + /** + * `True` if the error occurred transiently and can be retried. + */ + canBeRetried?: string | undefined; + /** + * Machine readable error code used to automate processes based on the code returned. + */ + detailedErrorCode?: number | undefined; - /** The original data that was passed to this error instance. */ - data$: ErrorMessageData; + /** The original data that was passed to this error instance. */ + data$: ErrorMessageData; - constructor(err: ErrorMessageData) { - const message = - "message" in err && typeof err.message === "string" - ? err.message - : `API error occurred: ${JSON.stringify(err)}`; - super(message); - this.data$ = err; + constructor(err: ErrorMessageData) { + const message = "message" in err && typeof err.message === "string" + ? err.message + : `API error occurred: ${JSON.stringify(err)}`; + super(message); + this.data$ = err; - if (err.statusCode != null) { - this.statusCode = err.statusCode; - } - if (err.service != null) { - this.service = err.service; - } - if (err.error != null) { - this.error = err.error; - } - if (err.correlationId != null) { - this.correlationId = err.correlationId; - } - if (err.validation != null) { - this.validation = err.validation; - } - if (err.canBeRetried != null) { - this.canBeRetried = err.canBeRetried; - } - if (err.detailedErrorCode != null) { - this.detailedErrorCode = err.detailedErrorCode; - } - - this.name = "ErrorMessage"; + if (err.statusCode != null) this.statusCode = err.statusCode; + if (err.service != null) this.service = err.service; + if (err.error != null) this.error = err.error; + if (err.correlationId != null) this.correlationId = err.correlationId; + if (err.validation != null) this.validation = err.validation; + if (err.canBeRetried != null) this.canBeRetried = err.canBeRetried; + if (err.detailedErrorCode != null) { + this.detailedErrorCode = err.detailedErrorCode; } + + this.name = "ErrorMessage"; + } } /** @internal */ -export const ErrorMessage$inboundSchema: z.ZodType = z - .object({ - statusCode: z.number().int().optional(), - service: z.string().optional(), - error: z.string().optional(), - correlationId: z.string().optional(), - validation: z.nullable(shared.ErrorValidation$inboundSchema).optional(), - canBeRetried: z.string().optional(), - detailedErrorCode: z.number().int().optional(), - }) - .transform((v) => { - return new ErrorMessage(v); - }); +export const ErrorMessage$inboundSchema: z.ZodType< + ErrorMessage, + z.ZodTypeDef, + unknown +> = z.object({ + statusCode: z.number().int().optional(), + service: z.string().optional(), + error: z.string().optional(), + correlationId: z.string().optional(), + validation: z.nullable(shared.ErrorValidation$inboundSchema).optional(), + canBeRetried: z.string().optional(), + detailedErrorCode: z.number().int().optional(), +}) + .transform((v) => { + return new ErrorMessage(v); + }); /** @internal */ export type ErrorMessage$Outbound = { - statusCode?: number | undefined; - service?: string | undefined; - error?: string | undefined; - correlationId?: string | undefined; - validation?: shared.ErrorValidation$Outbound | null | undefined; - canBeRetried?: string | undefined; - detailedErrorCode?: number | undefined; + statusCode?: number | undefined; + service?: string | undefined; + error?: string | undefined; + correlationId?: string | undefined; + validation?: shared.ErrorValidation$Outbound | null | undefined; + canBeRetried?: string | undefined; + detailedErrorCode?: number | undefined; }; /** @internal */ export const ErrorMessage$outboundSchema: z.ZodType< - ErrorMessage$Outbound, - z.ZodTypeDef, - ErrorMessage -> = z - .instanceof(ErrorMessage) - .transform((v) => v.data$) - .pipe( - z.object({ - statusCode: z.number().int().optional(), - service: z.string().optional(), - error: z.string().optional(), - correlationId: z.string().optional(), - validation: z.nullable(shared.ErrorValidation$outboundSchema).optional(), - canBeRetried: z.string().optional(), - detailedErrorCode: z.number().int().optional(), - }) - ); + ErrorMessage$Outbound, + z.ZodTypeDef, + ErrorMessage +> = z.instanceof(ErrorMessage) + .transform(v => v.data$) + .pipe(z.object({ + statusCode: z.number().int().optional(), + service: z.string().optional(), + error: z.string().optional(), + correlationId: z.string().optional(), + validation: z.nullable(shared.ErrorValidation$outboundSchema).optional(), + canBeRetried: z.string().optional(), + detailedErrorCode: z.number().int().optional(), + })); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ErrorMessage$ { - /** @deprecated use `ErrorMessage$inboundSchema` instead. */ - export const inboundSchema = ErrorMessage$inboundSchema; - /** @deprecated use `ErrorMessage$outboundSchema` instead. */ - export const outboundSchema = ErrorMessage$outboundSchema; - /** @deprecated use `ErrorMessage$Outbound` instead. */ - export type Outbound = ErrorMessage$Outbound; + /** @deprecated use `ErrorMessage$inboundSchema` instead. */ + export const inboundSchema = ErrorMessage$inboundSchema; + /** @deprecated use `ErrorMessage$outboundSchema` instead. */ + export const outboundSchema = ErrorMessage$outboundSchema; + /** @deprecated use `ErrorMessage$Outbound` instead. */ + export type Outbound = ErrorMessage$Outbound; } diff --git a/sync-for-commerce/src/sdk/models/errors/httpclienterrors.ts b/sync-for-commerce/src/sdk/models/errors/httpclienterrors.ts new file mode 100644 index 000000000..b34f61212 --- /dev/null +++ b/sync-for-commerce/src/sdk/models/errors/httpclienterrors.ts @@ -0,0 +1,62 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/** + * Base class for all HTTP errors. + */ +export class HTTPClientError extends Error { + /** The underlying cause of the error. */ + override readonly cause: unknown; + override name = "HTTPClientError"; + constructor(message: string, opts?: { cause?: unknown }) { + let msg = message; + if (opts?.cause) { + msg += `: ${opts.cause}`; + } + + super(msg, opts); + // In older runtimes, the cause field would not have been assigned through + // the super() call. + if (typeof this.cause === "undefined") { + this.cause = opts?.cause; + } + } +} + +/** + * An error to capture unrecognised or unexpected errors when making HTTP calls. + */ +export class UnexpectedClientError extends HTTPClientError { + override name = "UnexpectedClientError"; +} + +/** + * An error that is raised when any inputs used to create a request are invalid. + */ +export class InvalidRequestError extends HTTPClientError { + override name = "InvalidRequestError"; +} + +/** + * An error that is raised when a HTTP request was aborted by the client error. + */ +export class RequestAbortedError extends HTTPClientError { + override readonly name = "RequestAbortedError"; +} + +/** + * An error that is raised when a HTTP request timed out due to an AbortSignal + * signal timeout. + */ +export class RequestTimeoutError extends HTTPClientError { + override readonly name = "RequestTimeoutError"; +} + +/** + * An error that is raised when a HTTP client is unable to make a request to + * a server. + */ +export class ConnectionError extends HTTPClientError { + override readonly name = "ConnectionError"; +} diff --git a/sync-for-commerce/src/sdk/models/errors/index.ts b/sync-for-commerce/src/sdk/models/errors/index.ts index 7de3befd3..615a51570 100644 --- a/sync-for-commerce/src/sdk/models/errors/index.ts +++ b/sync-for-commerce/src/sdk/models/errors/index.ts @@ -1,7 +1,8 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export * from "./errormessage.js"; +export * from "./httpclienterrors.js"; export * from "./sdkerror.js"; export * from "./sdkvalidationerror.js"; diff --git a/sync-for-commerce/src/sdk/models/errors/sdkerror.ts b/sync-for-commerce/src/sdk/models/errors/sdkerror.ts index 5a94e842a..001f46592 100644 --- a/sync-for-commerce/src/sdk/models/errors/sdkerror.ts +++ b/sync-for-commerce/src/sdk/models/errors/sdkerror.ts @@ -1,25 +1,27 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export class SDKError extends Error { - public readonly statusCode: number; - public readonly contentType: string; + public readonly statusCode: number; + public readonly contentType: string; - constructor( - message: string, - public readonly rawResponse: Response, - public readonly body: string = "" - ) { - const statusCode = rawResponse.status; - const contentType = rawResponse.headers.get("content-type") || ""; - const bodyString = body.length > 0 ? `\n${body}` : ""; + constructor( + message: string, + public readonly rawResponse: Response, + public readonly body: string = "", + ) { + const statusCode = rawResponse.status; + const contentType = rawResponse.headers.get("content-type") || ""; + const bodyString = body.length > 0 ? `\n${body}` : ""; - super(`${message}: Status ${statusCode} Content-Type ${contentType} Body ${bodyString}`); + super( + `${message}: Status ${statusCode} Content-Type ${contentType} Body ${bodyString}`, + ); - this.statusCode = statusCode; - this.contentType = contentType; + this.statusCode = statusCode; + this.contentType = contentType; - this.name = "SDKError"; - } + this.name = "SDKError"; + } } diff --git a/sync-for-commerce/src/sdk/models/errors/sdkvalidationerror.ts b/sync-for-commerce/src/sdk/models/errors/sdkvalidationerror.ts index 5eb921820..16929b9e5 100644 --- a/sync-for-commerce/src/sdk/models/errors/sdkvalidationerror.ts +++ b/sync-for-commerce/src/sdk/models/errors/sdkvalidationerror.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; @@ -10,15 +10,17 @@ export class SDKValidationError extends Error { */ public readonly rawValue: unknown; + /** + * The raw message that failed validation. + */ + public readonly rawMessage: unknown; + constructor(message: string, cause: unknown, rawValue: unknown) { - super(message); + super(`${message}: ${cause}`); this.name = "SDKValidationError"; this.cause = cause; this.rawValue = rawValue; - } - - public override toString(): string { - return `${this.message}: ${this.cause}`; + this.rawMessage = message; } /** @@ -28,7 +30,7 @@ export class SDKValidationError extends Error { */ public pretty(): string { if (this.cause instanceof z.ZodError) { - return `${this.message}\n${formatZodError(this.cause)}`; + return `${this.rawMessage}\n${formatZodError(this.cause)}`; } else { return this.toString(); } diff --git a/sync-for-commerce/src/sdk/models/operations/createconnection.ts b/sync-for-commerce/src/sdk/models/operations/createconnection.ts index 5f4ed4d4b..84f50733d 100644 --- a/sync-for-commerce/src/sdk/models/operations/createconnection.ts +++ b/sync-for-commerce/src/sdk/models/operations/createconnection.ts @@ -1,46 +1,49 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { remap as remap$ } from "../../../lib/primitives.js"; import * as z from "zod"; +import { remap as remap$ } from "../../../lib/primitives.js"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreateConnectionRequestBody = { - /** - * A unique 4-letter key to represent a platform in each integration. View [accounting](https://docs.codat.io/integrations/accounting/overview#platform-keys), [banking](https://docs.codat.io/integrations/banking/overview#platform-keys), and [commerce](https://docs.codat.io/integrations/commerce/overview#platform-keys) platform keys. - */ - platformKey?: string | undefined; + /** + * A unique 4-letter key to represent a platform in each integration. View [accounting](https://docs.codat.io/integrations/accounting/overview#platform-keys), [banking](https://docs.codat.io/integrations/banking/overview#platform-keys), and [commerce](https://docs.codat.io/integrations/commerce/overview#platform-keys) platform keys. + */ + platformKey?: string | undefined; }; export type CreateConnectionRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; - requestBody?: CreateConnectionRequestBody | undefined; + /** + * Unique identifier for a company. + */ + companyId: string; + requestBody?: CreateConnectionRequestBody | undefined; }; /** @internal */ export const CreateConnectionRequestBody$inboundSchema: z.ZodType< - CreateConnectionRequestBody, - z.ZodTypeDef, - unknown + CreateConnectionRequestBody, + z.ZodTypeDef, + unknown > = z.object({ - platformKey: z.string().optional(), + platformKey: z.string().optional(), }); /** @internal */ export type CreateConnectionRequestBody$Outbound = { - platformKey?: string | undefined; + platformKey?: string | undefined; }; /** @internal */ export const CreateConnectionRequestBody$outboundSchema: z.ZodType< - CreateConnectionRequestBody$Outbound, - z.ZodTypeDef, - CreateConnectionRequestBody + CreateConnectionRequestBody$Outbound, + z.ZodTypeDef, + CreateConnectionRequestBody > = z.object({ - platformKey: z.string().optional(), + platformKey: z.string().optional(), }); /** @@ -48,61 +51,97 @@ export const CreateConnectionRequestBody$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CreateConnectionRequestBody$ { - /** @deprecated use `CreateConnectionRequestBody$inboundSchema` instead. */ - export const inboundSchema = CreateConnectionRequestBody$inboundSchema; - /** @deprecated use `CreateConnectionRequestBody$outboundSchema` instead. */ - export const outboundSchema = CreateConnectionRequestBody$outboundSchema; - /** @deprecated use `CreateConnectionRequestBody$Outbound` instead. */ - export type Outbound = CreateConnectionRequestBody$Outbound; + /** @deprecated use `CreateConnectionRequestBody$inboundSchema` instead. */ + export const inboundSchema = CreateConnectionRequestBody$inboundSchema; + /** @deprecated use `CreateConnectionRequestBody$outboundSchema` instead. */ + export const outboundSchema = CreateConnectionRequestBody$outboundSchema; + /** @deprecated use `CreateConnectionRequestBody$Outbound` instead. */ + export type Outbound = CreateConnectionRequestBody$Outbound; +} + +export function createConnectionRequestBodyToJSON( + createConnectionRequestBody: CreateConnectionRequestBody, +): string { + return JSON.stringify( + CreateConnectionRequestBody$outboundSchema.parse( + createConnectionRequestBody, + ), + ); +} + +export function createConnectionRequestBodyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateConnectionRequestBody$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateConnectionRequestBody' from JSON`, + ); } /** @internal */ export const CreateConnectionRequest$inboundSchema: z.ZodType< - CreateConnectionRequest, - z.ZodTypeDef, - unknown -> = z - .object({ - companyId: z.string(), - RequestBody: z.lazy(() => CreateConnectionRequestBody$inboundSchema).optional(), - }) - .transform((v) => { - return remap$(v, { - RequestBody: "requestBody", - }); - }); + CreateConnectionRequest, + z.ZodTypeDef, + unknown +> = z.object({ + companyId: z.string(), + RequestBody: z.lazy(() => CreateConnectionRequestBody$inboundSchema) + .optional(), +}).transform((v) => { + return remap$(v, { + "RequestBody": "requestBody", + }); +}); /** @internal */ export type CreateConnectionRequest$Outbound = { - companyId: string; - RequestBody?: CreateConnectionRequestBody$Outbound | undefined; + companyId: string; + RequestBody?: CreateConnectionRequestBody$Outbound | undefined; }; /** @internal */ export const CreateConnectionRequest$outboundSchema: z.ZodType< - CreateConnectionRequest$Outbound, - z.ZodTypeDef, - CreateConnectionRequest -> = z - .object({ - companyId: z.string(), - requestBody: z.lazy(() => CreateConnectionRequestBody$outboundSchema).optional(), - }) - .transform((v) => { - return remap$(v, { - requestBody: "RequestBody", - }); - }); + CreateConnectionRequest$Outbound, + z.ZodTypeDef, + CreateConnectionRequest +> = z.object({ + companyId: z.string(), + requestBody: z.lazy(() => CreateConnectionRequestBody$outboundSchema) + .optional(), +}).transform((v) => { + return remap$(v, { + requestBody: "RequestBody", + }); +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CreateConnectionRequest$ { - /** @deprecated use `CreateConnectionRequest$inboundSchema` instead. */ - export const inboundSchema = CreateConnectionRequest$inboundSchema; - /** @deprecated use `CreateConnectionRequest$outboundSchema` instead. */ - export const outboundSchema = CreateConnectionRequest$outboundSchema; - /** @deprecated use `CreateConnectionRequest$Outbound` instead. */ - export type Outbound = CreateConnectionRequest$Outbound; + /** @deprecated use `CreateConnectionRequest$inboundSchema` instead. */ + export const inboundSchema = CreateConnectionRequest$inboundSchema; + /** @deprecated use `CreateConnectionRequest$outboundSchema` instead. */ + export const outboundSchema = CreateConnectionRequest$outboundSchema; + /** @deprecated use `CreateConnectionRequest$Outbound` instead. */ + export type Outbound = CreateConnectionRequest$Outbound; +} + +export function createConnectionRequestToJSON( + createConnectionRequest: CreateConnectionRequest, +): string { + return JSON.stringify( + CreateConnectionRequest$outboundSchema.parse(createConnectionRequest), + ); +} + +export function createConnectionRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateConnectionRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateConnectionRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/getconfigtextsyncflow.ts b/sync-for-commerce/src/sdk/models/operations/getconfigtextsyncflow.ts index 13f826190..3ee23dd62 100644 --- a/sync-for-commerce/src/sdk/models/operations/getconfigtextsyncflow.ts +++ b/sync-for-commerce/src/sdk/models/operations/getconfigtextsyncflow.ts @@ -1,38 +1,41 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import * as shared from "../shared/index.js"; import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; +import * as shared from "../shared/index.js"; export type GetConfigTextSyncFlowRequest = { - /** - * Localization identifier for English (US) or French. - */ - locale: shared.Locale; + /** + * Localization identifier for English (US) or French. + */ + locale: shared.Locale; }; /** @internal */ export const GetConfigTextSyncFlowRequest$inboundSchema: z.ZodType< - GetConfigTextSyncFlowRequest, - z.ZodTypeDef, - unknown + GetConfigTextSyncFlowRequest, + z.ZodTypeDef, + unknown > = z.object({ - locale: shared.Locale$inboundSchema, + locale: shared.Locale$inboundSchema, }); /** @internal */ export type GetConfigTextSyncFlowRequest$Outbound = { - locale: string; + locale: string; }; /** @internal */ export const GetConfigTextSyncFlowRequest$outboundSchema: z.ZodType< - GetConfigTextSyncFlowRequest$Outbound, - z.ZodTypeDef, - GetConfigTextSyncFlowRequest + GetConfigTextSyncFlowRequest$Outbound, + z.ZodTypeDef, + GetConfigTextSyncFlowRequest > = z.object({ - locale: shared.Locale$outboundSchema, + locale: shared.Locale$outboundSchema, }); /** @@ -40,10 +43,30 @@ export const GetConfigTextSyncFlowRequest$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetConfigTextSyncFlowRequest$ { - /** @deprecated use `GetConfigTextSyncFlowRequest$inboundSchema` instead. */ - export const inboundSchema = GetConfigTextSyncFlowRequest$inboundSchema; - /** @deprecated use `GetConfigTextSyncFlowRequest$outboundSchema` instead. */ - export const outboundSchema = GetConfigTextSyncFlowRequest$outboundSchema; - /** @deprecated use `GetConfigTextSyncFlowRequest$Outbound` instead. */ - export type Outbound = GetConfigTextSyncFlowRequest$Outbound; + /** @deprecated use `GetConfigTextSyncFlowRequest$inboundSchema` instead. */ + export const inboundSchema = GetConfigTextSyncFlowRequest$inboundSchema; + /** @deprecated use `GetConfigTextSyncFlowRequest$outboundSchema` instead. */ + export const outboundSchema = GetConfigTextSyncFlowRequest$outboundSchema; + /** @deprecated use `GetConfigTextSyncFlowRequest$Outbound` instead. */ + export type Outbound = GetConfigTextSyncFlowRequest$Outbound; +} + +export function getConfigTextSyncFlowRequestToJSON( + getConfigTextSyncFlowRequest: GetConfigTextSyncFlowRequest, +): string { + return JSON.stringify( + GetConfigTextSyncFlowRequest$outboundSchema.parse( + getConfigTextSyncFlowRequest, + ), + ); +} + +export function getConfigTextSyncFlowRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetConfigTextSyncFlowRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetConfigTextSyncFlowRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/getconfiguration.ts b/sync-for-commerce/src/sdk/models/operations/getconfiguration.ts index e38c89bc5..a86bb2e5f 100644 --- a/sync-for-commerce/src/sdk/models/operations/getconfiguration.ts +++ b/sync-for-commerce/src/sdk/models/operations/getconfiguration.ts @@ -1,37 +1,40 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetConfigurationRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; + /** + * Unique identifier for a company. + */ + companyId: string; }; /** @internal */ export const GetConfigurationRequest$inboundSchema: z.ZodType< - GetConfigurationRequest, - z.ZodTypeDef, - unknown + GetConfigurationRequest, + z.ZodTypeDef, + unknown > = z.object({ - companyId: z.string(), + companyId: z.string(), }); /** @internal */ export type GetConfigurationRequest$Outbound = { - companyId: string; + companyId: string; }; /** @internal */ export const GetConfigurationRequest$outboundSchema: z.ZodType< - GetConfigurationRequest$Outbound, - z.ZodTypeDef, - GetConfigurationRequest + GetConfigurationRequest$Outbound, + z.ZodTypeDef, + GetConfigurationRequest > = z.object({ - companyId: z.string(), + companyId: z.string(), }); /** @@ -39,10 +42,28 @@ export const GetConfigurationRequest$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetConfigurationRequest$ { - /** @deprecated use `GetConfigurationRequest$inboundSchema` instead. */ - export const inboundSchema = GetConfigurationRequest$inboundSchema; - /** @deprecated use `GetConfigurationRequest$outboundSchema` instead. */ - export const outboundSchema = GetConfigurationRequest$outboundSchema; - /** @deprecated use `GetConfigurationRequest$Outbound` instead. */ - export type Outbound = GetConfigurationRequest$Outbound; + /** @deprecated use `GetConfigurationRequest$inboundSchema` instead. */ + export const inboundSchema = GetConfigurationRequest$inboundSchema; + /** @deprecated use `GetConfigurationRequest$outboundSchema` instead. */ + export const outboundSchema = GetConfigurationRequest$outboundSchema; + /** @deprecated use `GetConfigurationRequest$Outbound` instead. */ + export type Outbound = GetConfigurationRequest$Outbound; +} + +export function getConfigurationRequestToJSON( + getConfigurationRequest: GetConfigurationRequest, +): string { + return JSON.stringify( + GetConfigurationRequest$outboundSchema.parse(getConfigurationRequest), + ); +} + +export function getConfigurationRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetConfigurationRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetConfigurationRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/getintegrationbranding.ts b/sync-for-commerce/src/sdk/models/operations/getintegrationbranding.ts index 7ecc719d3..e2cc3a45c 100644 --- a/sync-for-commerce/src/sdk/models/operations/getintegrationbranding.ts +++ b/sync-for-commerce/src/sdk/models/operations/getintegrationbranding.ts @@ -1,37 +1,40 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetIntegrationBrandingRequest = { - /** - * A unique 4-letter key to represent a platform in each integration. - */ - platformKey: string; + /** + * A unique 4-letter key to represent a platform in each integration. + */ + platformKey: string; }; /** @internal */ export const GetIntegrationBrandingRequest$inboundSchema: z.ZodType< - GetIntegrationBrandingRequest, - z.ZodTypeDef, - unknown + GetIntegrationBrandingRequest, + z.ZodTypeDef, + unknown > = z.object({ - platformKey: z.string(), + platformKey: z.string(), }); /** @internal */ export type GetIntegrationBrandingRequest$Outbound = { - platformKey: string; + platformKey: string; }; /** @internal */ export const GetIntegrationBrandingRequest$outboundSchema: z.ZodType< - GetIntegrationBrandingRequest$Outbound, - z.ZodTypeDef, - GetIntegrationBrandingRequest + GetIntegrationBrandingRequest$Outbound, + z.ZodTypeDef, + GetIntegrationBrandingRequest > = z.object({ - platformKey: z.string(), + platformKey: z.string(), }); /** @@ -39,10 +42,30 @@ export const GetIntegrationBrandingRequest$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetIntegrationBrandingRequest$ { - /** @deprecated use `GetIntegrationBrandingRequest$inboundSchema` instead. */ - export const inboundSchema = GetIntegrationBrandingRequest$inboundSchema; - /** @deprecated use `GetIntegrationBrandingRequest$outboundSchema` instead. */ - export const outboundSchema = GetIntegrationBrandingRequest$outboundSchema; - /** @deprecated use `GetIntegrationBrandingRequest$Outbound` instead. */ - export type Outbound = GetIntegrationBrandingRequest$Outbound; + /** @deprecated use `GetIntegrationBrandingRequest$inboundSchema` instead. */ + export const inboundSchema = GetIntegrationBrandingRequest$inboundSchema; + /** @deprecated use `GetIntegrationBrandingRequest$outboundSchema` instead. */ + export const outboundSchema = GetIntegrationBrandingRequest$outboundSchema; + /** @deprecated use `GetIntegrationBrandingRequest$Outbound` instead. */ + export type Outbound = GetIntegrationBrandingRequest$Outbound; +} + +export function getIntegrationBrandingRequestToJSON( + getIntegrationBrandingRequest: GetIntegrationBrandingRequest, +): string { + return JSON.stringify( + GetIntegrationBrandingRequest$outboundSchema.parse( + getIntegrationBrandingRequest, + ), + ); +} + +export function getIntegrationBrandingRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetIntegrationBrandingRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetIntegrationBrandingRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/getlastsuccessfulsync.ts b/sync-for-commerce/src/sdk/models/operations/getlastsuccessfulsync.ts index fcfa41c0c..66bb1a5fc 100644 --- a/sync-for-commerce/src/sdk/models/operations/getlastsuccessfulsync.ts +++ b/sync-for-commerce/src/sdk/models/operations/getlastsuccessfulsync.ts @@ -1,37 +1,40 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetLastSuccessfulSyncRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; + /** + * Unique identifier for a company. + */ + companyId: string; }; /** @internal */ export const GetLastSuccessfulSyncRequest$inboundSchema: z.ZodType< - GetLastSuccessfulSyncRequest, - z.ZodTypeDef, - unknown + GetLastSuccessfulSyncRequest, + z.ZodTypeDef, + unknown > = z.object({ - companyId: z.string(), + companyId: z.string(), }); /** @internal */ export type GetLastSuccessfulSyncRequest$Outbound = { - companyId: string; + companyId: string; }; /** @internal */ export const GetLastSuccessfulSyncRequest$outboundSchema: z.ZodType< - GetLastSuccessfulSyncRequest$Outbound, - z.ZodTypeDef, - GetLastSuccessfulSyncRequest + GetLastSuccessfulSyncRequest$Outbound, + z.ZodTypeDef, + GetLastSuccessfulSyncRequest > = z.object({ - companyId: z.string(), + companyId: z.string(), }); /** @@ -39,10 +42,30 @@ export const GetLastSuccessfulSyncRequest$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetLastSuccessfulSyncRequest$ { - /** @deprecated use `GetLastSuccessfulSyncRequest$inboundSchema` instead. */ - export const inboundSchema = GetLastSuccessfulSyncRequest$inboundSchema; - /** @deprecated use `GetLastSuccessfulSyncRequest$outboundSchema` instead. */ - export const outboundSchema = GetLastSuccessfulSyncRequest$outboundSchema; - /** @deprecated use `GetLastSuccessfulSyncRequest$Outbound` instead. */ - export type Outbound = GetLastSuccessfulSyncRequest$Outbound; + /** @deprecated use `GetLastSuccessfulSyncRequest$inboundSchema` instead. */ + export const inboundSchema = GetLastSuccessfulSyncRequest$inboundSchema; + /** @deprecated use `GetLastSuccessfulSyncRequest$outboundSchema` instead. */ + export const outboundSchema = GetLastSuccessfulSyncRequest$outboundSchema; + /** @deprecated use `GetLastSuccessfulSyncRequest$Outbound` instead. */ + export type Outbound = GetLastSuccessfulSyncRequest$Outbound; +} + +export function getLastSuccessfulSyncRequestToJSON( + getLastSuccessfulSyncRequest: GetLastSuccessfulSyncRequest, +): string { + return JSON.stringify( + GetLastSuccessfulSyncRequest$outboundSchema.parse( + getLastSuccessfulSyncRequest, + ), + ); +} + +export function getLastSuccessfulSyncRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetLastSuccessfulSyncRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetLastSuccessfulSyncRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/getlatestsync.ts b/sync-for-commerce/src/sdk/models/operations/getlatestsync.ts index 49e6eb89f..55388d946 100644 --- a/sync-for-commerce/src/sdk/models/operations/getlatestsync.ts +++ b/sync-for-commerce/src/sdk/models/operations/getlatestsync.ts @@ -1,37 +1,40 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetLatestSyncRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; + /** + * Unique identifier for a company. + */ + companyId: string; }; /** @internal */ export const GetLatestSyncRequest$inboundSchema: z.ZodType< - GetLatestSyncRequest, - z.ZodTypeDef, - unknown + GetLatestSyncRequest, + z.ZodTypeDef, + unknown > = z.object({ - companyId: z.string(), + companyId: z.string(), }); /** @internal */ export type GetLatestSyncRequest$Outbound = { - companyId: string; + companyId: string; }; /** @internal */ export const GetLatestSyncRequest$outboundSchema: z.ZodType< - GetLatestSyncRequest$Outbound, - z.ZodTypeDef, - GetLatestSyncRequest + GetLatestSyncRequest$Outbound, + z.ZodTypeDef, + GetLatestSyncRequest > = z.object({ - companyId: z.string(), + companyId: z.string(), }); /** @@ -39,10 +42,28 @@ export const GetLatestSyncRequest$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetLatestSyncRequest$ { - /** @deprecated use `GetLatestSyncRequest$inboundSchema` instead. */ - export const inboundSchema = GetLatestSyncRequest$inboundSchema; - /** @deprecated use `GetLatestSyncRequest$outboundSchema` instead. */ - export const outboundSchema = GetLatestSyncRequest$outboundSchema; - /** @deprecated use `GetLatestSyncRequest$Outbound` instead. */ - export type Outbound = GetLatestSyncRequest$Outbound; + /** @deprecated use `GetLatestSyncRequest$inboundSchema` instead. */ + export const inboundSchema = GetLatestSyncRequest$inboundSchema; + /** @deprecated use `GetLatestSyncRequest$outboundSchema` instead. */ + export const outboundSchema = GetLatestSyncRequest$outboundSchema; + /** @deprecated use `GetLatestSyncRequest$Outbound` instead. */ + export type Outbound = GetLatestSyncRequest$Outbound; +} + +export function getLatestSyncRequestToJSON( + getLatestSyncRequest: GetLatestSyncRequest, +): string { + return JSON.stringify( + GetLatestSyncRequest$outboundSchema.parse(getLatestSyncRequest), + ); +} + +export function getLatestSyncRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetLatestSyncRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetLatestSyncRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/getsyncbyid.ts b/sync-for-commerce/src/sdk/models/operations/getsyncbyid.ts index 429ea9fb6..2c7373fe2 100644 --- a/sync-for-commerce/src/sdk/models/operations/getsyncbyid.ts +++ b/sync-for-commerce/src/sdk/models/operations/getsyncbyid.ts @@ -1,44 +1,47 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetSyncByIdRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; - /** - * Unique identifier for a sync. - */ - syncId: string; + /** + * Unique identifier for a company. + */ + companyId: string; + /** + * Unique identifier for a sync. + */ + syncId: string; }; /** @internal */ export const GetSyncByIdRequest$inboundSchema: z.ZodType< - GetSyncByIdRequest, - z.ZodTypeDef, - unknown + GetSyncByIdRequest, + z.ZodTypeDef, + unknown > = z.object({ - companyId: z.string(), - syncId: z.string(), + companyId: z.string(), + syncId: z.string(), }); /** @internal */ export type GetSyncByIdRequest$Outbound = { - companyId: string; - syncId: string; + companyId: string; + syncId: string; }; /** @internal */ export const GetSyncByIdRequest$outboundSchema: z.ZodType< - GetSyncByIdRequest$Outbound, - z.ZodTypeDef, - GetSyncByIdRequest + GetSyncByIdRequest$Outbound, + z.ZodTypeDef, + GetSyncByIdRequest > = z.object({ - companyId: z.string(), - syncId: z.string(), + companyId: z.string(), + syncId: z.string(), }); /** @@ -46,10 +49,28 @@ export const GetSyncByIdRequest$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetSyncByIdRequest$ { - /** @deprecated use `GetSyncByIdRequest$inboundSchema` instead. */ - export const inboundSchema = GetSyncByIdRequest$inboundSchema; - /** @deprecated use `GetSyncByIdRequest$outboundSchema` instead. */ - export const outboundSchema = GetSyncByIdRequest$outboundSchema; - /** @deprecated use `GetSyncByIdRequest$Outbound` instead. */ - export type Outbound = GetSyncByIdRequest$Outbound; + /** @deprecated use `GetSyncByIdRequest$inboundSchema` instead. */ + export const inboundSchema = GetSyncByIdRequest$inboundSchema; + /** @deprecated use `GetSyncByIdRequest$outboundSchema` instead. */ + export const outboundSchema = GetSyncByIdRequest$outboundSchema; + /** @deprecated use `GetSyncByIdRequest$Outbound` instead. */ + export type Outbound = GetSyncByIdRequest$Outbound; +} + +export function getSyncByIdRequestToJSON( + getSyncByIdRequest: GetSyncByIdRequest, +): string { + return JSON.stringify( + GetSyncByIdRequest$outboundSchema.parse(getSyncByIdRequest), + ); +} + +export function getSyncByIdRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetSyncByIdRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetSyncByIdRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/getsyncflowurl.ts b/sync-for-commerce/src/sdk/models/operations/getsyncflowurl.ts index 4057603e4..0dc80a97a 100644 --- a/sync-for-commerce/src/sdk/models/operations/getsyncflowurl.ts +++ b/sync-for-commerce/src/sdk/models/operations/getsyncflowurl.ts @@ -1,51 +1,54 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetSyncFlowUrlRequest = { - /** - * Commerce platform key - */ - commerceKey: string; - /** - * Accounting platform key - */ - accountingKey: string; - /** - * Identifier for your merchant, can be the merchant name or Codat company id. - */ - merchantIdentifier?: string | undefined; + /** + * Commerce platform key + */ + commerceKey: string; + /** + * Accounting platform key + */ + accountingKey: string; + /** + * Identifier for your merchant, can be the merchant name or Codat company id. + */ + merchantIdentifier?: string | undefined; }; /** @internal */ export const GetSyncFlowUrlRequest$inboundSchema: z.ZodType< - GetSyncFlowUrlRequest, - z.ZodTypeDef, - unknown + GetSyncFlowUrlRequest, + z.ZodTypeDef, + unknown > = z.object({ - commerceKey: z.string(), - accountingKey: z.string(), - merchantIdentifier: z.string().optional(), + commerceKey: z.string(), + accountingKey: z.string(), + merchantIdentifier: z.string().optional(), }); /** @internal */ export type GetSyncFlowUrlRequest$Outbound = { - commerceKey: string; - accountingKey: string; - merchantIdentifier?: string | undefined; + commerceKey: string; + accountingKey: string; + merchantIdentifier?: string | undefined; }; /** @internal */ export const GetSyncFlowUrlRequest$outboundSchema: z.ZodType< - GetSyncFlowUrlRequest$Outbound, - z.ZodTypeDef, - GetSyncFlowUrlRequest + GetSyncFlowUrlRequest$Outbound, + z.ZodTypeDef, + GetSyncFlowUrlRequest > = z.object({ - commerceKey: z.string(), - accountingKey: z.string(), - merchantIdentifier: z.string().optional(), + commerceKey: z.string(), + accountingKey: z.string(), + merchantIdentifier: z.string().optional(), }); /** @@ -53,10 +56,28 @@ export const GetSyncFlowUrlRequest$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetSyncFlowUrlRequest$ { - /** @deprecated use `GetSyncFlowUrlRequest$inboundSchema` instead. */ - export const inboundSchema = GetSyncFlowUrlRequest$inboundSchema; - /** @deprecated use `GetSyncFlowUrlRequest$outboundSchema` instead. */ - export const outboundSchema = GetSyncFlowUrlRequest$outboundSchema; - /** @deprecated use `GetSyncFlowUrlRequest$Outbound` instead. */ - export type Outbound = GetSyncFlowUrlRequest$Outbound; + /** @deprecated use `GetSyncFlowUrlRequest$inboundSchema` instead. */ + export const inboundSchema = GetSyncFlowUrlRequest$inboundSchema; + /** @deprecated use `GetSyncFlowUrlRequest$outboundSchema` instead. */ + export const outboundSchema = GetSyncFlowUrlRequest$outboundSchema; + /** @deprecated use `GetSyncFlowUrlRequest$Outbound` instead. */ + export type Outbound = GetSyncFlowUrlRequest$Outbound; +} + +export function getSyncFlowUrlRequestToJSON( + getSyncFlowUrlRequest: GetSyncFlowUrlRequest, +): string { + return JSON.stringify( + GetSyncFlowUrlRequest$outboundSchema.parse(getSyncFlowUrlRequest), + ); +} + +export function getSyncFlowUrlRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetSyncFlowUrlRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetSyncFlowUrlRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/getsyncstatus.ts b/sync-for-commerce/src/sdk/models/operations/getsyncstatus.ts index 1607e955d..4ef2aa679 100644 --- a/sync-for-commerce/src/sdk/models/operations/getsyncstatus.ts +++ b/sync-for-commerce/src/sdk/models/operations/getsyncstatus.ts @@ -1,37 +1,40 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetSyncStatusRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; + /** + * Unique identifier for a company. + */ + companyId: string; }; /** @internal */ export const GetSyncStatusRequest$inboundSchema: z.ZodType< - GetSyncStatusRequest, - z.ZodTypeDef, - unknown + GetSyncStatusRequest, + z.ZodTypeDef, + unknown > = z.object({ - companyId: z.string(), + companyId: z.string(), }); /** @internal */ export type GetSyncStatusRequest$Outbound = { - companyId: string; + companyId: string; }; /** @internal */ export const GetSyncStatusRequest$outboundSchema: z.ZodType< - GetSyncStatusRequest$Outbound, - z.ZodTypeDef, - GetSyncStatusRequest + GetSyncStatusRequest$Outbound, + z.ZodTypeDef, + GetSyncStatusRequest > = z.object({ - companyId: z.string(), + companyId: z.string(), }); /** @@ -39,10 +42,28 @@ export const GetSyncStatusRequest$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetSyncStatusRequest$ { - /** @deprecated use `GetSyncStatusRequest$inboundSchema` instead. */ - export const inboundSchema = GetSyncStatusRequest$inboundSchema; - /** @deprecated use `GetSyncStatusRequest$outboundSchema` instead. */ - export const outboundSchema = GetSyncStatusRequest$outboundSchema; - /** @deprecated use `GetSyncStatusRequest$Outbound` instead. */ - export type Outbound = GetSyncStatusRequest$Outbound; + /** @deprecated use `GetSyncStatusRequest$inboundSchema` instead. */ + export const inboundSchema = GetSyncStatusRequest$inboundSchema; + /** @deprecated use `GetSyncStatusRequest$outboundSchema` instead. */ + export const outboundSchema = GetSyncStatusRequest$outboundSchema; + /** @deprecated use `GetSyncStatusRequest$Outbound` instead. */ + export type Outbound = GetSyncStatusRequest$Outbound; +} + +export function getSyncStatusRequestToJSON( + getSyncStatusRequest: GetSyncStatusRequest, +): string { + return JSON.stringify( + GetSyncStatusRequest$outboundSchema.parse(getSyncStatusRequest), + ); +} + +export function getSyncStatusRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetSyncStatusRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetSyncStatusRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/getvisibleaccounts.ts b/sync-for-commerce/src/sdk/models/operations/getvisibleaccounts.ts index 128390149..76fd532d4 100644 --- a/sync-for-commerce/src/sdk/models/operations/getvisibleaccounts.ts +++ b/sync-for-commerce/src/sdk/models/operations/getvisibleaccounts.ts @@ -1,44 +1,47 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetVisibleAccountsRequest = { - /** - * Unique identifier for your client in Codat. - */ - clientId: string; - /** - * A unique 4-letter key to represent a platform in each integration. - */ - platformKey: string; + /** + * Unique identifier for your client in Codat. + */ + clientId: string; + /** + * A unique 4-letter key to represent a platform in each integration. + */ + platformKey: string; }; /** @internal */ export const GetVisibleAccountsRequest$inboundSchema: z.ZodType< - GetVisibleAccountsRequest, - z.ZodTypeDef, - unknown + GetVisibleAccountsRequest, + z.ZodTypeDef, + unknown > = z.object({ - clientId: z.string(), - platformKey: z.string(), + clientId: z.string(), + platformKey: z.string(), }); /** @internal */ export type GetVisibleAccountsRequest$Outbound = { - clientId: string; - platformKey: string; + clientId: string; + platformKey: string; }; /** @internal */ export const GetVisibleAccountsRequest$outboundSchema: z.ZodType< - GetVisibleAccountsRequest$Outbound, - z.ZodTypeDef, - GetVisibleAccountsRequest + GetVisibleAccountsRequest$Outbound, + z.ZodTypeDef, + GetVisibleAccountsRequest > = z.object({ - clientId: z.string(), - platformKey: z.string(), + clientId: z.string(), + platformKey: z.string(), }); /** @@ -46,10 +49,28 @@ export const GetVisibleAccountsRequest$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetVisibleAccountsRequest$ { - /** @deprecated use `GetVisibleAccountsRequest$inboundSchema` instead. */ - export const inboundSchema = GetVisibleAccountsRequest$inboundSchema; - /** @deprecated use `GetVisibleAccountsRequest$outboundSchema` instead. */ - export const outboundSchema = GetVisibleAccountsRequest$outboundSchema; - /** @deprecated use `GetVisibleAccountsRequest$Outbound` instead. */ - export type Outbound = GetVisibleAccountsRequest$Outbound; + /** @deprecated use `GetVisibleAccountsRequest$inboundSchema` instead. */ + export const inboundSchema = GetVisibleAccountsRequest$inboundSchema; + /** @deprecated use `GetVisibleAccountsRequest$outboundSchema` instead. */ + export const outboundSchema = GetVisibleAccountsRequest$outboundSchema; + /** @deprecated use `GetVisibleAccountsRequest$Outbound` instead. */ + export type Outbound = GetVisibleAccountsRequest$Outbound; +} + +export function getVisibleAccountsRequestToJSON( + getVisibleAccountsRequest: GetVisibleAccountsRequest, +): string { + return JSON.stringify( + GetVisibleAccountsRequest$outboundSchema.parse(getVisibleAccountsRequest), + ); +} + +export function getVisibleAccountsRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetVisibleAccountsRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetVisibleAccountsRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/index.ts b/sync-for-commerce/src/sdk/models/operations/index.ts index a3932e02d..50d604d2e 100644 --- a/sync-for-commerce/src/sdk/models/operations/index.ts +++ b/sync-for-commerce/src/sdk/models/operations/index.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export * from "./createconnection.js"; diff --git a/sync-for-commerce/src/sdk/models/operations/listcompanies.ts b/sync-for-commerce/src/sdk/models/operations/listcompanies.ts index c8efeba02..95bf0265c 100644 --- a/sync-for-commerce/src/sdk/models/operations/listcompanies.ts +++ b/sync-for-commerce/src/sdk/models/operations/listcompanies.ts @@ -1,58 +1,61 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListCompaniesRequest = { - /** - * Page number. [Read more](https://docs.codat.io/using-the-api/paging). - */ - page?: number | undefined; - /** - * Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). - */ - pageSize?: number | undefined; - /** - * Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). - */ - query?: string | undefined; - /** - * Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). - */ - orderBy?: string | undefined; + /** + * Page number. [Read more](https://docs.codat.io/using-the-api/paging). + */ + page?: number | undefined; + /** + * Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). + */ + pageSize?: number | undefined; + /** + * Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). + */ + query?: string | undefined; + /** + * Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). + */ + orderBy?: string | undefined; }; /** @internal */ export const ListCompaniesRequest$inboundSchema: z.ZodType< - ListCompaniesRequest, - z.ZodTypeDef, - unknown + ListCompaniesRequest, + z.ZodTypeDef, + unknown > = z.object({ - page: z.number().int().default(1), - pageSize: z.number().int().default(100), - query: z.string().optional(), - orderBy: z.string().optional(), + page: z.number().int().default(1), + pageSize: z.number().int().default(100), + query: z.string().optional(), + orderBy: z.string().optional(), }); /** @internal */ export type ListCompaniesRequest$Outbound = { - page: number; - pageSize: number; - query?: string | undefined; - orderBy?: string | undefined; + page: number; + pageSize: number; + query?: string | undefined; + orderBy?: string | undefined; }; /** @internal */ export const ListCompaniesRequest$outboundSchema: z.ZodType< - ListCompaniesRequest$Outbound, - z.ZodTypeDef, - ListCompaniesRequest + ListCompaniesRequest$Outbound, + z.ZodTypeDef, + ListCompaniesRequest > = z.object({ - page: z.number().int().default(1), - pageSize: z.number().int().default(100), - query: z.string().optional(), - orderBy: z.string().optional(), + page: z.number().int().default(1), + pageSize: z.number().int().default(100), + query: z.string().optional(), + orderBy: z.string().optional(), }); /** @@ -60,10 +63,28 @@ export const ListCompaniesRequest$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ListCompaniesRequest$ { - /** @deprecated use `ListCompaniesRequest$inboundSchema` instead. */ - export const inboundSchema = ListCompaniesRequest$inboundSchema; - /** @deprecated use `ListCompaniesRequest$outboundSchema` instead. */ - export const outboundSchema = ListCompaniesRequest$outboundSchema; - /** @deprecated use `ListCompaniesRequest$Outbound` instead. */ - export type Outbound = ListCompaniesRequest$Outbound; + /** @deprecated use `ListCompaniesRequest$inboundSchema` instead. */ + export const inboundSchema = ListCompaniesRequest$inboundSchema; + /** @deprecated use `ListCompaniesRequest$outboundSchema` instead. */ + export const outboundSchema = ListCompaniesRequest$outboundSchema; + /** @deprecated use `ListCompaniesRequest$Outbound` instead. */ + export type Outbound = ListCompaniesRequest$Outbound; +} + +export function listCompaniesRequestToJSON( + listCompaniesRequest: ListCompaniesRequest, +): string { + return JSON.stringify( + ListCompaniesRequest$outboundSchema.parse(listCompaniesRequest), + ); +} + +export function listCompaniesRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListCompaniesRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListCompaniesRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/listconnections.ts b/sync-for-commerce/src/sdk/models/operations/listconnections.ts index fda56c1a5..7fe54afef 100644 --- a/sync-for-commerce/src/sdk/models/operations/listconnections.ts +++ b/sync-for-commerce/src/sdk/models/operations/listconnections.ts @@ -1,65 +1,68 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListConnectionsRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; - /** - * Page number. [Read more](https://docs.codat.io/using-the-api/paging). - */ - page?: number | undefined; - /** - * Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). - */ - pageSize?: number | undefined; - /** - * Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). - */ - query?: string | undefined; - /** - * Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). - */ - orderBy?: string | undefined; + /** + * Unique identifier for a company. + */ + companyId: string; + /** + * Page number. [Read more](https://docs.codat.io/using-the-api/paging). + */ + page?: number | undefined; + /** + * Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). + */ + pageSize?: number | undefined; + /** + * Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). + */ + query?: string | undefined; + /** + * Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). + */ + orderBy?: string | undefined; }; /** @internal */ export const ListConnectionsRequest$inboundSchema: z.ZodType< - ListConnectionsRequest, - z.ZodTypeDef, - unknown + ListConnectionsRequest, + z.ZodTypeDef, + unknown > = z.object({ - companyId: z.string(), - page: z.number().int().default(1), - pageSize: z.number().int().default(100), - query: z.string().optional(), - orderBy: z.string().optional(), + companyId: z.string(), + page: z.number().int().default(1), + pageSize: z.number().int().default(100), + query: z.string().optional(), + orderBy: z.string().optional(), }); /** @internal */ export type ListConnectionsRequest$Outbound = { - companyId: string; - page: number; - pageSize: number; - query?: string | undefined; - orderBy?: string | undefined; + companyId: string; + page: number; + pageSize: number; + query?: string | undefined; + orderBy?: string | undefined; }; /** @internal */ export const ListConnectionsRequest$outboundSchema: z.ZodType< - ListConnectionsRequest$Outbound, - z.ZodTypeDef, - ListConnectionsRequest + ListConnectionsRequest$Outbound, + z.ZodTypeDef, + ListConnectionsRequest > = z.object({ - companyId: z.string(), - page: z.number().int().default(1), - pageSize: z.number().int().default(100), - query: z.string().optional(), - orderBy: z.string().optional(), + companyId: z.string(), + page: z.number().int().default(1), + pageSize: z.number().int().default(100), + query: z.string().optional(), + orderBy: z.string().optional(), }); /** @@ -67,10 +70,28 @@ export const ListConnectionsRequest$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ListConnectionsRequest$ { - /** @deprecated use `ListConnectionsRequest$inboundSchema` instead. */ - export const inboundSchema = ListConnectionsRequest$inboundSchema; - /** @deprecated use `ListConnectionsRequest$outboundSchema` instead. */ - export const outboundSchema = ListConnectionsRequest$outboundSchema; - /** @deprecated use `ListConnectionsRequest$Outbound` instead. */ - export type Outbound = ListConnectionsRequest$Outbound; + /** @deprecated use `ListConnectionsRequest$inboundSchema` instead. */ + export const inboundSchema = ListConnectionsRequest$inboundSchema; + /** @deprecated use `ListConnectionsRequest$outboundSchema` instead. */ + export const outboundSchema = ListConnectionsRequest$outboundSchema; + /** @deprecated use `ListConnectionsRequest$Outbound` instead. */ + export type Outbound = ListConnectionsRequest$Outbound; +} + +export function listConnectionsRequestToJSON( + listConnectionsRequest: ListConnectionsRequest, +): string { + return JSON.stringify( + ListConnectionsRequest$outboundSchema.parse(listConnectionsRequest), + ); +} + +export function listConnectionsRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListConnectionsRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListConnectionsRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/listintegrations.ts b/sync-for-commerce/src/sdk/models/operations/listintegrations.ts index d9733c1f2..9637445d7 100644 --- a/sync-for-commerce/src/sdk/models/operations/listintegrations.ts +++ b/sync-for-commerce/src/sdk/models/operations/listintegrations.ts @@ -1,58 +1,61 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListIntegrationsRequest = { - /** - * Page number. [Read more](https://docs.codat.io/using-the-api/paging). - */ - page?: number | undefined; - /** - * Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). - */ - pageSize?: number | undefined; - /** - * Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). - */ - query?: string | undefined; - /** - * Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). - */ - orderBy?: string | undefined; + /** + * Page number. [Read more](https://docs.codat.io/using-the-api/paging). + */ + page?: number | undefined; + /** + * Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging). + */ + pageSize?: number | undefined; + /** + * Codat query string. [Read more](https://docs.codat.io/using-the-api/querying). + */ + query?: string | undefined; + /** + * Field to order results by. [Read more](https://docs.codat.io/using-the-api/ordering-results). + */ + orderBy?: string | undefined; }; /** @internal */ export const ListIntegrationsRequest$inboundSchema: z.ZodType< - ListIntegrationsRequest, - z.ZodTypeDef, - unknown + ListIntegrationsRequest, + z.ZodTypeDef, + unknown > = z.object({ - page: z.number().int().default(1), - pageSize: z.number().int().default(100), - query: z.string().optional(), - orderBy: z.string().optional(), + page: z.number().int().default(1), + pageSize: z.number().int().default(100), + query: z.string().optional(), + orderBy: z.string().optional(), }); /** @internal */ export type ListIntegrationsRequest$Outbound = { - page: number; - pageSize: number; - query?: string | undefined; - orderBy?: string | undefined; + page: number; + pageSize: number; + query?: string | undefined; + orderBy?: string | undefined; }; /** @internal */ export const ListIntegrationsRequest$outboundSchema: z.ZodType< - ListIntegrationsRequest$Outbound, - z.ZodTypeDef, - ListIntegrationsRequest + ListIntegrationsRequest$Outbound, + z.ZodTypeDef, + ListIntegrationsRequest > = z.object({ - page: z.number().int().default(1), - pageSize: z.number().int().default(100), - query: z.string().optional(), - orderBy: z.string().optional(), + page: z.number().int().default(1), + pageSize: z.number().int().default(100), + query: z.string().optional(), + orderBy: z.string().optional(), }); /** @@ -60,10 +63,28 @@ export const ListIntegrationsRequest$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ListIntegrationsRequest$ { - /** @deprecated use `ListIntegrationsRequest$inboundSchema` instead. */ - export const inboundSchema = ListIntegrationsRequest$inboundSchema; - /** @deprecated use `ListIntegrationsRequest$outboundSchema` instead. */ - export const outboundSchema = ListIntegrationsRequest$outboundSchema; - /** @deprecated use `ListIntegrationsRequest$Outbound` instead. */ - export type Outbound = ListIntegrationsRequest$Outbound; + /** @deprecated use `ListIntegrationsRequest$inboundSchema` instead. */ + export const inboundSchema = ListIntegrationsRequest$inboundSchema; + /** @deprecated use `ListIntegrationsRequest$outboundSchema` instead. */ + export const outboundSchema = ListIntegrationsRequest$outboundSchema; + /** @deprecated use `ListIntegrationsRequest$Outbound` instead. */ + export type Outbound = ListIntegrationsRequest$Outbound; +} + +export function listIntegrationsRequestToJSON( + listIntegrationsRequest: ListIntegrationsRequest, +): string { + return JSON.stringify( + ListIntegrationsRequest$outboundSchema.parse(listIntegrationsRequest), + ); +} + +export function listIntegrationsRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListIntegrationsRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListIntegrationsRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/listsyncs.ts b/sync-for-commerce/src/sdk/models/operations/listsyncs.ts index 9bbd856e4..1ab884290 100644 --- a/sync-for-commerce/src/sdk/models/operations/listsyncs.ts +++ b/sync-for-commerce/src/sdk/models/operations/listsyncs.ts @@ -1,34 +1,40 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListSyncsRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; + /** + * Unique identifier for a company. + */ + companyId: string; }; /** @internal */ -export const ListSyncsRequest$inboundSchema: z.ZodType = - z.object({ - companyId: z.string(), - }); +export const ListSyncsRequest$inboundSchema: z.ZodType< + ListSyncsRequest, + z.ZodTypeDef, + unknown +> = z.object({ + companyId: z.string(), +}); /** @internal */ export type ListSyncsRequest$Outbound = { - companyId: string; + companyId: string; }; /** @internal */ export const ListSyncsRequest$outboundSchema: z.ZodType< - ListSyncsRequest$Outbound, - z.ZodTypeDef, - ListSyncsRequest + ListSyncsRequest$Outbound, + z.ZodTypeDef, + ListSyncsRequest > = z.object({ - companyId: z.string(), + companyId: z.string(), }); /** @@ -36,10 +42,28 @@ export const ListSyncsRequest$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ListSyncsRequest$ { - /** @deprecated use `ListSyncsRequest$inboundSchema` instead. */ - export const inboundSchema = ListSyncsRequest$inboundSchema; - /** @deprecated use `ListSyncsRequest$outboundSchema` instead. */ - export const outboundSchema = ListSyncsRequest$outboundSchema; - /** @deprecated use `ListSyncsRequest$Outbound` instead. */ - export type Outbound = ListSyncsRequest$Outbound; + /** @deprecated use `ListSyncsRequest$inboundSchema` instead. */ + export const inboundSchema = ListSyncsRequest$inboundSchema; + /** @deprecated use `ListSyncsRequest$outboundSchema` instead. */ + export const outboundSchema = ListSyncsRequest$outboundSchema; + /** @deprecated use `ListSyncsRequest$Outbound` instead. */ + export type Outbound = ListSyncsRequest$Outbound; +} + +export function listSyncsRequestToJSON( + listSyncsRequest: ListSyncsRequest, +): string { + return JSON.stringify( + ListSyncsRequest$outboundSchema.parse(listSyncsRequest), + ); +} + +export function listSyncsRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListSyncsRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListSyncsRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/requestsync.ts b/sync-for-commerce/src/sdk/models/operations/requestsync.ts index aad446a31..ace951c1a 100644 --- a/sync-for-commerce/src/sdk/models/operations/requestsync.ts +++ b/sync-for-commerce/src/sdk/models/operations/requestsync.ts @@ -1,66 +1,83 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; import { remap as remap$ } from "../../../lib/primitives.js"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import * as shared from "../shared/index.js"; -import * as z from "zod"; export type RequestSyncRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; - syncToLatestArgs?: shared.SyncToLatestArgs | undefined; + /** + * Unique identifier for a company. + */ + companyId: string; + syncToLatestArgs?: shared.SyncToLatestArgs | undefined; }; /** @internal */ export const RequestSyncRequest$inboundSchema: z.ZodType< - RequestSyncRequest, - z.ZodTypeDef, - unknown -> = z - .object({ - companyId: z.string(), - SyncToLatestArgs: shared.SyncToLatestArgs$inboundSchema.optional(), - }) - .transform((v) => { - return remap$(v, { - SyncToLatestArgs: "syncToLatestArgs", - }); - }); + RequestSyncRequest, + z.ZodTypeDef, + unknown +> = z.object({ + companyId: z.string(), + SyncToLatestArgs: shared.SyncToLatestArgs$inboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + "SyncToLatestArgs": "syncToLatestArgs", + }); +}); /** @internal */ export type RequestSyncRequest$Outbound = { - companyId: string; - SyncToLatestArgs?: shared.SyncToLatestArgs$Outbound | undefined; + companyId: string; + SyncToLatestArgs?: shared.SyncToLatestArgs$Outbound | undefined; }; /** @internal */ export const RequestSyncRequest$outboundSchema: z.ZodType< - RequestSyncRequest$Outbound, - z.ZodTypeDef, - RequestSyncRequest -> = z - .object({ - companyId: z.string(), - syncToLatestArgs: shared.SyncToLatestArgs$outboundSchema.optional(), - }) - .transform((v) => { - return remap$(v, { - syncToLatestArgs: "SyncToLatestArgs", - }); - }); + RequestSyncRequest$Outbound, + z.ZodTypeDef, + RequestSyncRequest +> = z.object({ + companyId: z.string(), + syncToLatestArgs: shared.SyncToLatestArgs$outboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + syncToLatestArgs: "SyncToLatestArgs", + }); +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace RequestSyncRequest$ { - /** @deprecated use `RequestSyncRequest$inboundSchema` instead. */ - export const inboundSchema = RequestSyncRequest$inboundSchema; - /** @deprecated use `RequestSyncRequest$outboundSchema` instead. */ - export const outboundSchema = RequestSyncRequest$outboundSchema; - /** @deprecated use `RequestSyncRequest$Outbound` instead. */ - export type Outbound = RequestSyncRequest$Outbound; + /** @deprecated use `RequestSyncRequest$inboundSchema` instead. */ + export const inboundSchema = RequestSyncRequest$inboundSchema; + /** @deprecated use `RequestSyncRequest$outboundSchema` instead. */ + export const outboundSchema = RequestSyncRequest$outboundSchema; + /** @deprecated use `RequestSyncRequest$Outbound` instead. */ + export type Outbound = RequestSyncRequest$Outbound; +} + +export function requestSyncRequestToJSON( + requestSyncRequest: RequestSyncRequest, +): string { + return JSON.stringify( + RequestSyncRequest$outboundSchema.parse(requestSyncRequest), + ); +} + +export function requestSyncRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RequestSyncRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RequestSyncRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/requestsyncfordaterange.ts b/sync-for-commerce/src/sdk/models/operations/requestsyncfordaterange.ts index 7494297db..9c1ea83d3 100644 --- a/sync-for-commerce/src/sdk/models/operations/requestsyncfordaterange.ts +++ b/sync-for-commerce/src/sdk/models/operations/requestsyncfordaterange.ts @@ -1,66 +1,85 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; import { remap as remap$ } from "../../../lib/primitives.js"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import * as shared from "../shared/index.js"; -import * as z from "zod"; export type RequestSyncForDateRangeRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; - syncRange?: shared.SyncRange | undefined; + /** + * Unique identifier for a company. + */ + companyId: string; + syncRange?: shared.SyncRange | undefined; }; /** @internal */ export const RequestSyncForDateRangeRequest$inboundSchema: z.ZodType< - RequestSyncForDateRangeRequest, - z.ZodTypeDef, - unknown -> = z - .object({ - companyId: z.string(), - SyncRange: shared.SyncRange$inboundSchema.optional(), - }) - .transform((v) => { - return remap$(v, { - SyncRange: "syncRange", - }); - }); + RequestSyncForDateRangeRequest, + z.ZodTypeDef, + unknown +> = z.object({ + companyId: z.string(), + SyncRange: shared.SyncRange$inboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + "SyncRange": "syncRange", + }); +}); /** @internal */ export type RequestSyncForDateRangeRequest$Outbound = { - companyId: string; - SyncRange?: shared.SyncRange$Outbound | undefined; + companyId: string; + SyncRange?: shared.SyncRange$Outbound | undefined; }; /** @internal */ export const RequestSyncForDateRangeRequest$outboundSchema: z.ZodType< - RequestSyncForDateRangeRequest$Outbound, - z.ZodTypeDef, - RequestSyncForDateRangeRequest -> = z - .object({ - companyId: z.string(), - syncRange: shared.SyncRange$outboundSchema.optional(), - }) - .transform((v) => { - return remap$(v, { - syncRange: "SyncRange", - }); - }); + RequestSyncForDateRangeRequest$Outbound, + z.ZodTypeDef, + RequestSyncForDateRangeRequest +> = z.object({ + companyId: z.string(), + syncRange: shared.SyncRange$outboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + syncRange: "SyncRange", + }); +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace RequestSyncForDateRangeRequest$ { - /** @deprecated use `RequestSyncForDateRangeRequest$inboundSchema` instead. */ - export const inboundSchema = RequestSyncForDateRangeRequest$inboundSchema; - /** @deprecated use `RequestSyncForDateRangeRequest$outboundSchema` instead. */ - export const outboundSchema = RequestSyncForDateRangeRequest$outboundSchema; - /** @deprecated use `RequestSyncForDateRangeRequest$Outbound` instead. */ - export type Outbound = RequestSyncForDateRangeRequest$Outbound; + /** @deprecated use `RequestSyncForDateRangeRequest$inboundSchema` instead. */ + export const inboundSchema = RequestSyncForDateRangeRequest$inboundSchema; + /** @deprecated use `RequestSyncForDateRangeRequest$outboundSchema` instead. */ + export const outboundSchema = RequestSyncForDateRangeRequest$outboundSchema; + /** @deprecated use `RequestSyncForDateRangeRequest$Outbound` instead. */ + export type Outbound = RequestSyncForDateRangeRequest$Outbound; +} + +export function requestSyncForDateRangeRequestToJSON( + requestSyncForDateRangeRequest: RequestSyncForDateRangeRequest, +): string { + return JSON.stringify( + RequestSyncForDateRangeRequest$outboundSchema.parse( + requestSyncForDateRangeRequest, + ), + ); +} + +export function requestSyncForDateRangeRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RequestSyncForDateRangeRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RequestSyncForDateRangeRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/setconfiguration.ts b/sync-for-commerce/src/sdk/models/operations/setconfiguration.ts index 612175568..4e911f304 100644 --- a/sync-for-commerce/src/sdk/models/operations/setconfiguration.ts +++ b/sync-for-commerce/src/sdk/models/operations/setconfiguration.ts @@ -1,37 +1,40 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type SetConfigurationRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; + /** + * Unique identifier for a company. + */ + companyId: string; }; /** @internal */ export const SetConfigurationRequest$inboundSchema: z.ZodType< - SetConfigurationRequest, - z.ZodTypeDef, - unknown + SetConfigurationRequest, + z.ZodTypeDef, + unknown > = z.object({ - companyId: z.string(), + companyId: z.string(), }); /** @internal */ export type SetConfigurationRequest$Outbound = { - companyId: string; + companyId: string; }; /** @internal */ export const SetConfigurationRequest$outboundSchema: z.ZodType< - SetConfigurationRequest$Outbound, - z.ZodTypeDef, - SetConfigurationRequest + SetConfigurationRequest$Outbound, + z.ZodTypeDef, + SetConfigurationRequest > = z.object({ - companyId: z.string(), + companyId: z.string(), }); /** @@ -39,10 +42,28 @@ export const SetConfigurationRequest$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SetConfigurationRequest$ { - /** @deprecated use `SetConfigurationRequest$inboundSchema` instead. */ - export const inboundSchema = SetConfigurationRequest$inboundSchema; - /** @deprecated use `SetConfigurationRequest$outboundSchema` instead. */ - export const outboundSchema = SetConfigurationRequest$outboundSchema; - /** @deprecated use `SetConfigurationRequest$Outbound` instead. */ - export type Outbound = SetConfigurationRequest$Outbound; + /** @deprecated use `SetConfigurationRequest$inboundSchema` instead. */ + export const inboundSchema = SetConfigurationRequest$inboundSchema; + /** @deprecated use `SetConfigurationRequest$outboundSchema` instead. */ + export const outboundSchema = SetConfigurationRequest$outboundSchema; + /** @deprecated use `SetConfigurationRequest$Outbound` instead. */ + export type Outbound = SetConfigurationRequest$Outbound; +} + +export function setConfigurationRequestToJSON( + setConfigurationRequest: SetConfigurationRequest, +): string { + return JSON.stringify( + SetConfigurationRequest$outboundSchema.parse(setConfigurationRequest), + ); +} + +export function setConfigurationRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SetConfigurationRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SetConfigurationRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/updateconfigtextsyncflow.ts b/sync-for-commerce/src/sdk/models/operations/updateconfigtextsyncflow.ts index 06e834e61..f5f5859eb 100644 --- a/sync-for-commerce/src/sdk/models/operations/updateconfigtextsyncflow.ts +++ b/sync-for-commerce/src/sdk/models/operations/updateconfigtextsyncflow.ts @@ -1,66 +1,85 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; import { remap as remap$ } from "../../../lib/primitives.js"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import * as shared from "../shared/index.js"; -import * as z from "zod"; export type UpdateConfigTextSyncFlowRequest = { - /** - * Localization identifier for English (US) or French. - */ - locale: shared.Locale; - requestBody?: { [k: string]: shared.Localization } | undefined; + /** + * Localization identifier for English (US) or French. + */ + locale: shared.Locale; + requestBody?: { [k: string]: shared.Localization } | undefined; }; /** @internal */ export const UpdateConfigTextSyncFlowRequest$inboundSchema: z.ZodType< - UpdateConfigTextSyncFlowRequest, - z.ZodTypeDef, - unknown -> = z - .object({ - locale: shared.Locale$inboundSchema, - RequestBody: z.record(shared.Localization$inboundSchema).optional(), - }) - .transform((v) => { - return remap$(v, { - RequestBody: "requestBody", - }); - }); + UpdateConfigTextSyncFlowRequest, + z.ZodTypeDef, + unknown +> = z.object({ + locale: shared.Locale$inboundSchema, + RequestBody: z.record(shared.Localization$inboundSchema).optional(), +}).transform((v) => { + return remap$(v, { + "RequestBody": "requestBody", + }); +}); /** @internal */ export type UpdateConfigTextSyncFlowRequest$Outbound = { - locale: string; - RequestBody?: { [k: string]: shared.Localization$Outbound } | undefined; + locale: string; + RequestBody?: { [k: string]: shared.Localization$Outbound } | undefined; }; /** @internal */ export const UpdateConfigTextSyncFlowRequest$outboundSchema: z.ZodType< - UpdateConfigTextSyncFlowRequest$Outbound, - z.ZodTypeDef, - UpdateConfigTextSyncFlowRequest -> = z - .object({ - locale: shared.Locale$outboundSchema, - requestBody: z.record(shared.Localization$outboundSchema).optional(), - }) - .transform((v) => { - return remap$(v, { - requestBody: "RequestBody", - }); - }); + UpdateConfigTextSyncFlowRequest$Outbound, + z.ZodTypeDef, + UpdateConfigTextSyncFlowRequest +> = z.object({ + locale: shared.Locale$outboundSchema, + requestBody: z.record(shared.Localization$outboundSchema).optional(), +}).transform((v) => { + return remap$(v, { + requestBody: "RequestBody", + }); +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace UpdateConfigTextSyncFlowRequest$ { - /** @deprecated use `UpdateConfigTextSyncFlowRequest$inboundSchema` instead. */ - export const inboundSchema = UpdateConfigTextSyncFlowRequest$inboundSchema; - /** @deprecated use `UpdateConfigTextSyncFlowRequest$outboundSchema` instead. */ - export const outboundSchema = UpdateConfigTextSyncFlowRequest$outboundSchema; - /** @deprecated use `UpdateConfigTextSyncFlowRequest$Outbound` instead. */ - export type Outbound = UpdateConfigTextSyncFlowRequest$Outbound; + /** @deprecated use `UpdateConfigTextSyncFlowRequest$inboundSchema` instead. */ + export const inboundSchema = UpdateConfigTextSyncFlowRequest$inboundSchema; + /** @deprecated use `UpdateConfigTextSyncFlowRequest$outboundSchema` instead. */ + export const outboundSchema = UpdateConfigTextSyncFlowRequest$outboundSchema; + /** @deprecated use `UpdateConfigTextSyncFlowRequest$Outbound` instead. */ + export type Outbound = UpdateConfigTextSyncFlowRequest$Outbound; +} + +export function updateConfigTextSyncFlowRequestToJSON( + updateConfigTextSyncFlowRequest: UpdateConfigTextSyncFlowRequest, +): string { + return JSON.stringify( + UpdateConfigTextSyncFlowRequest$outboundSchema.parse( + updateConfigTextSyncFlowRequest, + ), + ); +} + +export function updateConfigTextSyncFlowRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => UpdateConfigTextSyncFlowRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'UpdateConfigTextSyncFlowRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/updateconnection.ts b/sync-for-commerce/src/sdk/models/operations/updateconnection.ts index 7dbce1258..87a0fd790 100644 --- a/sync-for-commerce/src/sdk/models/operations/updateconnection.ts +++ b/sync-for-commerce/src/sdk/models/operations/updateconnection.ts @@ -1,73 +1,90 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; import { remap as remap$ } from "../../../lib/primitives.js"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import * as shared from "../shared/index.js"; -import * as z from "zod"; export type UpdateConnectionRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; - /** - * Unique identifier for a connection. - */ - connectionId: string; - updateConnection?: shared.UpdateConnection | undefined; + /** + * Unique identifier for a company. + */ + companyId: string; + /** + * Unique identifier for a connection. + */ + connectionId: string; + updateConnection?: shared.UpdateConnection | undefined; }; /** @internal */ export const UpdateConnectionRequest$inboundSchema: z.ZodType< - UpdateConnectionRequest, - z.ZodTypeDef, - unknown -> = z - .object({ - companyId: z.string(), - connectionId: z.string(), - UpdateConnection: shared.UpdateConnection$inboundSchema.optional(), - }) - .transform((v) => { - return remap$(v, { - UpdateConnection: "updateConnection", - }); - }); + UpdateConnectionRequest, + z.ZodTypeDef, + unknown +> = z.object({ + companyId: z.string(), + connectionId: z.string(), + UpdateConnection: shared.UpdateConnection$inboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + "UpdateConnection": "updateConnection", + }); +}); /** @internal */ export type UpdateConnectionRequest$Outbound = { - companyId: string; - connectionId: string; - UpdateConnection?: shared.UpdateConnection$Outbound | undefined; + companyId: string; + connectionId: string; + UpdateConnection?: shared.UpdateConnection$Outbound | undefined; }; /** @internal */ export const UpdateConnectionRequest$outboundSchema: z.ZodType< - UpdateConnectionRequest$Outbound, - z.ZodTypeDef, - UpdateConnectionRequest -> = z - .object({ - companyId: z.string(), - connectionId: z.string(), - updateConnection: shared.UpdateConnection$outboundSchema.optional(), - }) - .transform((v) => { - return remap$(v, { - updateConnection: "UpdateConnection", - }); - }); + UpdateConnectionRequest$Outbound, + z.ZodTypeDef, + UpdateConnectionRequest +> = z.object({ + companyId: z.string(), + connectionId: z.string(), + updateConnection: shared.UpdateConnection$outboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + updateConnection: "UpdateConnection", + }); +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace UpdateConnectionRequest$ { - /** @deprecated use `UpdateConnectionRequest$inboundSchema` instead. */ - export const inboundSchema = UpdateConnectionRequest$inboundSchema; - /** @deprecated use `UpdateConnectionRequest$outboundSchema` instead. */ - export const outboundSchema = UpdateConnectionRequest$outboundSchema; - /** @deprecated use `UpdateConnectionRequest$Outbound` instead. */ - export type Outbound = UpdateConnectionRequest$Outbound; + /** @deprecated use `UpdateConnectionRequest$inboundSchema` instead. */ + export const inboundSchema = UpdateConnectionRequest$inboundSchema; + /** @deprecated use `UpdateConnectionRequest$outboundSchema` instead. */ + export const outboundSchema = UpdateConnectionRequest$outboundSchema; + /** @deprecated use `UpdateConnectionRequest$Outbound` instead. */ + export type Outbound = UpdateConnectionRequest$Outbound; +} + +export function updateConnectionRequestToJSON( + updateConnectionRequest: UpdateConnectionRequest, +): string { + return JSON.stringify( + UpdateConnectionRequest$outboundSchema.parse(updateConnectionRequest), + ); +} + +export function updateConnectionRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => UpdateConnectionRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'UpdateConnectionRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/updateconnectionauthorization.ts b/sync-for-commerce/src/sdk/models/operations/updateconnectionauthorization.ts index b1864ad6e..b6fa04c65 100644 --- a/sync-for-commerce/src/sdk/models/operations/updateconnectionauthorization.ts +++ b/sync-for-commerce/src/sdk/models/operations/updateconnectionauthorization.ts @@ -1,72 +1,94 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { remap as remap$ } from "../../../lib/primitives.js"; import * as z from "zod"; +import { remap as remap$ } from "../../../lib/primitives.js"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type UpdateConnectionAuthorizationRequest = { - /** - * Unique identifier for a company. - */ - companyId: string; - /** - * Unique identifier for a connection. - */ - connectionId: string; - requestBody?: { [k: string]: string } | undefined; + /** + * Unique identifier for a company. + */ + companyId: string; + /** + * Unique identifier for a connection. + */ + connectionId: string; + requestBody?: { [k: string]: string } | undefined; }; /** @internal */ export const UpdateConnectionAuthorizationRequest$inboundSchema: z.ZodType< - UpdateConnectionAuthorizationRequest, - z.ZodTypeDef, - unknown -> = z - .object({ - companyId: z.string(), - connectionId: z.string(), - RequestBody: z.record(z.string()).optional(), - }) - .transform((v) => { - return remap$(v, { - RequestBody: "requestBody", - }); - }); + UpdateConnectionAuthorizationRequest, + z.ZodTypeDef, + unknown +> = z.object({ + companyId: z.string(), + connectionId: z.string(), + RequestBody: z.record(z.string()).optional(), +}).transform((v) => { + return remap$(v, { + "RequestBody": "requestBody", + }); +}); /** @internal */ export type UpdateConnectionAuthorizationRequest$Outbound = { - companyId: string; - connectionId: string; - RequestBody?: { [k: string]: string } | undefined; + companyId: string; + connectionId: string; + RequestBody?: { [k: string]: string } | undefined; }; /** @internal */ export const UpdateConnectionAuthorizationRequest$outboundSchema: z.ZodType< - UpdateConnectionAuthorizationRequest$Outbound, - z.ZodTypeDef, - UpdateConnectionAuthorizationRequest -> = z - .object({ - companyId: z.string(), - connectionId: z.string(), - requestBody: z.record(z.string()).optional(), - }) - .transform((v) => { - return remap$(v, { - requestBody: "RequestBody", - }); - }); + UpdateConnectionAuthorizationRequest$Outbound, + z.ZodTypeDef, + UpdateConnectionAuthorizationRequest +> = z.object({ + companyId: z.string(), + connectionId: z.string(), + requestBody: z.record(z.string()).optional(), +}).transform((v) => { + return remap$(v, { + requestBody: "RequestBody", + }); +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace UpdateConnectionAuthorizationRequest$ { - /** @deprecated use `UpdateConnectionAuthorizationRequest$inboundSchema` instead. */ - export const inboundSchema = UpdateConnectionAuthorizationRequest$inboundSchema; - /** @deprecated use `UpdateConnectionAuthorizationRequest$outboundSchema` instead. */ - export const outboundSchema = UpdateConnectionAuthorizationRequest$outboundSchema; - /** @deprecated use `UpdateConnectionAuthorizationRequest$Outbound` instead. */ - export type Outbound = UpdateConnectionAuthorizationRequest$Outbound; + /** @deprecated use `UpdateConnectionAuthorizationRequest$inboundSchema` instead. */ + export const inboundSchema = + UpdateConnectionAuthorizationRequest$inboundSchema; + /** @deprecated use `UpdateConnectionAuthorizationRequest$outboundSchema` instead. */ + export const outboundSchema = + UpdateConnectionAuthorizationRequest$outboundSchema; + /** @deprecated use `UpdateConnectionAuthorizationRequest$Outbound` instead. */ + export type Outbound = UpdateConnectionAuthorizationRequest$Outbound; +} + +export function updateConnectionAuthorizationRequestToJSON( + updateConnectionAuthorizationRequest: UpdateConnectionAuthorizationRequest, +): string { + return JSON.stringify( + UpdateConnectionAuthorizationRequest$outboundSchema.parse( + updateConnectionAuthorizationRequest, + ), + ); +} + +export function updateConnectionAuthorizationRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + UpdateConnectionAuthorizationRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'UpdateConnectionAuthorizationRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/operations/updatevisibleaccountssyncflow.ts b/sync-for-commerce/src/sdk/models/operations/updatevisibleaccountssyncflow.ts index 0f4a589cf..a3e334d4d 100644 --- a/sync-for-commerce/src/sdk/models/operations/updatevisibleaccountssyncflow.ts +++ b/sync-for-commerce/src/sdk/models/operations/updatevisibleaccountssyncflow.ts @@ -1,66 +1,88 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; import { remap as remap$ } from "../../../lib/primitives.js"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import * as shared from "../shared/index.js"; -import * as z from "zod"; export type UpdateVisibleAccountsSyncFlowRequest = { - /** - * A unique 4-letter key to represent a platform in each integration. - */ - platformKey: string; - visibleAccounts?: shared.VisibleAccounts | undefined; + /** + * A unique 4-letter key to represent a platform in each integration. + */ + platformKey: string; + visibleAccounts?: shared.VisibleAccounts | undefined; }; /** @internal */ export const UpdateVisibleAccountsSyncFlowRequest$inboundSchema: z.ZodType< - UpdateVisibleAccountsSyncFlowRequest, - z.ZodTypeDef, - unknown -> = z - .object({ - platformKey: z.string(), - VisibleAccounts: shared.VisibleAccounts$inboundSchema.optional(), - }) - .transform((v) => { - return remap$(v, { - VisibleAccounts: "visibleAccounts", - }); - }); + UpdateVisibleAccountsSyncFlowRequest, + z.ZodTypeDef, + unknown +> = z.object({ + platformKey: z.string(), + VisibleAccounts: shared.VisibleAccounts$inboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + "VisibleAccounts": "visibleAccounts", + }); +}); /** @internal */ export type UpdateVisibleAccountsSyncFlowRequest$Outbound = { - platformKey: string; - VisibleAccounts?: shared.VisibleAccounts$Outbound | undefined; + platformKey: string; + VisibleAccounts?: shared.VisibleAccounts$Outbound | undefined; }; /** @internal */ export const UpdateVisibleAccountsSyncFlowRequest$outboundSchema: z.ZodType< - UpdateVisibleAccountsSyncFlowRequest$Outbound, - z.ZodTypeDef, - UpdateVisibleAccountsSyncFlowRequest -> = z - .object({ - platformKey: z.string(), - visibleAccounts: shared.VisibleAccounts$outboundSchema.optional(), - }) - .transform((v) => { - return remap$(v, { - visibleAccounts: "VisibleAccounts", - }); - }); + UpdateVisibleAccountsSyncFlowRequest$Outbound, + z.ZodTypeDef, + UpdateVisibleAccountsSyncFlowRequest +> = z.object({ + platformKey: z.string(), + visibleAccounts: shared.VisibleAccounts$outboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + visibleAccounts: "VisibleAccounts", + }); +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace UpdateVisibleAccountsSyncFlowRequest$ { - /** @deprecated use `UpdateVisibleAccountsSyncFlowRequest$inboundSchema` instead. */ - export const inboundSchema = UpdateVisibleAccountsSyncFlowRequest$inboundSchema; - /** @deprecated use `UpdateVisibleAccountsSyncFlowRequest$outboundSchema` instead. */ - export const outboundSchema = UpdateVisibleAccountsSyncFlowRequest$outboundSchema; - /** @deprecated use `UpdateVisibleAccountsSyncFlowRequest$Outbound` instead. */ - export type Outbound = UpdateVisibleAccountsSyncFlowRequest$Outbound; + /** @deprecated use `UpdateVisibleAccountsSyncFlowRequest$inboundSchema` instead. */ + export const inboundSchema = + UpdateVisibleAccountsSyncFlowRequest$inboundSchema; + /** @deprecated use `UpdateVisibleAccountsSyncFlowRequest$outboundSchema` instead. */ + export const outboundSchema = + UpdateVisibleAccountsSyncFlowRequest$outboundSchema; + /** @deprecated use `UpdateVisibleAccountsSyncFlowRequest$Outbound` instead. */ + export type Outbound = UpdateVisibleAccountsSyncFlowRequest$Outbound; +} + +export function updateVisibleAccountsSyncFlowRequestToJSON( + updateVisibleAccountsSyncFlowRequest: UpdateVisibleAccountsSyncFlowRequest, +): string { + return JSON.stringify( + UpdateVisibleAccountsSyncFlowRequest$outboundSchema.parse( + updateVisibleAccountsSyncFlowRequest, + ), + ); +} + +export function updateVisibleAccountsSyncFlowRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + UpdateVisibleAccountsSyncFlowRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'UpdateVisibleAccountsSyncFlowRequest' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/accountconfiguration.ts b/sync-for-commerce/src/sdk/models/shared/accountconfiguration.ts index f1e2e803e..41f21f8af 100644 --- a/sync-for-commerce/src/sdk/models/shared/accountconfiguration.ts +++ b/sync-for-commerce/src/sdk/models/shared/accountconfiguration.ts @@ -1,74 +1,82 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - AccountConfigurationOption, - AccountConfigurationOption$inboundSchema, - AccountConfigurationOption$Outbound, - AccountConfigurationOption$outboundSchema, + AccountConfigurationOption, + AccountConfigurationOption$inboundSchema, + AccountConfigurationOption$Outbound, + AccountConfigurationOption$outboundSchema, } from "./accountconfigurationoption.js"; -import * as z from "zod"; /** * G/L account object for configuration. */ export type AccountConfiguration = { - /** - * Label text for sales configuration section. - */ - labelText?: string | null | undefined; - /** - * Descriptive text for sales configuration section. - */ - descriptionText?: string | null | undefined; - /** - * Selected account id from the list of available accounts. - */ - selectedAccountId?: string | null | undefined; - /** - * Required section to be configured for sync. - */ - required?: boolean | undefined; - /** - * Object containing account options. - */ - accountOptions?: Array | null | undefined; + /** + * Label text for sales configuration section. + */ + labelText?: string | null | undefined; + /** + * Descriptive text for sales configuration section. + */ + descriptionText?: string | null | undefined; + /** + * Selected account id from the list of available accounts. + */ + selectedAccountId?: string | null | undefined; + /** + * Required section to be configured for sync. + */ + required?: boolean | undefined; + /** + * Object containing account options. + */ + accountOptions?: Array | null | undefined; }; /** @internal */ export const AccountConfiguration$inboundSchema: z.ZodType< - AccountConfiguration, - z.ZodTypeDef, - unknown + AccountConfiguration, + z.ZodTypeDef, + unknown > = z.object({ - labelText: z.nullable(z.string()).optional(), - descriptionText: z.nullable(z.string()).optional(), - selectedAccountId: z.nullable(z.string()).optional(), - required: z.boolean().optional(), - accountOptions: z.nullable(z.array(AccountConfigurationOption$inboundSchema)).optional(), + labelText: z.nullable(z.string()).optional(), + descriptionText: z.nullable(z.string()).optional(), + selectedAccountId: z.nullable(z.string()).optional(), + required: z.boolean().optional(), + accountOptions: z.nullable(z.array(AccountConfigurationOption$inboundSchema)) + .optional(), }); /** @internal */ export type AccountConfiguration$Outbound = { - labelText?: string | null | undefined; - descriptionText?: string | null | undefined; - selectedAccountId?: string | null | undefined; - required?: boolean | undefined; - accountOptions?: Array | null | undefined; + labelText?: string | null | undefined; + descriptionText?: string | null | undefined; + selectedAccountId?: string | null | undefined; + required?: boolean | undefined; + accountOptions?: + | Array + | null + | undefined; }; /** @internal */ export const AccountConfiguration$outboundSchema: z.ZodType< - AccountConfiguration$Outbound, - z.ZodTypeDef, - AccountConfiguration + AccountConfiguration$Outbound, + z.ZodTypeDef, + AccountConfiguration > = z.object({ - labelText: z.nullable(z.string()).optional(), - descriptionText: z.nullable(z.string()).optional(), - selectedAccountId: z.nullable(z.string()).optional(), - required: z.boolean().optional(), - accountOptions: z.nullable(z.array(AccountConfigurationOption$outboundSchema)).optional(), + labelText: z.nullable(z.string()).optional(), + descriptionText: z.nullable(z.string()).optional(), + selectedAccountId: z.nullable(z.string()).optional(), + required: z.boolean().optional(), + accountOptions: z.nullable(z.array(AccountConfigurationOption$outboundSchema)) + .optional(), }); /** @@ -76,10 +84,28 @@ export const AccountConfiguration$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AccountConfiguration$ { - /** @deprecated use `AccountConfiguration$inboundSchema` instead. */ - export const inboundSchema = AccountConfiguration$inboundSchema; - /** @deprecated use `AccountConfiguration$outboundSchema` instead. */ - export const outboundSchema = AccountConfiguration$outboundSchema; - /** @deprecated use `AccountConfiguration$Outbound` instead. */ - export type Outbound = AccountConfiguration$Outbound; + /** @deprecated use `AccountConfiguration$inboundSchema` instead. */ + export const inboundSchema = AccountConfiguration$inboundSchema; + /** @deprecated use `AccountConfiguration$outboundSchema` instead. */ + export const outboundSchema = AccountConfiguration$outboundSchema; + /** @deprecated use `AccountConfiguration$Outbound` instead. */ + export type Outbound = AccountConfiguration$Outbound; +} + +export function accountConfigurationToJSON( + accountConfiguration: AccountConfiguration, +): string { + return JSON.stringify( + AccountConfiguration$outboundSchema.parse(accountConfiguration), + ); +} + +export function accountConfigurationFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AccountConfiguration$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AccountConfiguration' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/accountconfigurationoption.ts b/sync-for-commerce/src/sdk/models/shared/accountconfigurationoption.ts index 0d5768951..92e83446d 100644 --- a/sync-for-commerce/src/sdk/models/shared/accountconfigurationoption.ts +++ b/sync-for-commerce/src/sdk/models/shared/accountconfigurationoption.ts @@ -1,58 +1,61 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type AccountConfigurationOption = { - /** - * Identifier for the account, unique for the company. - */ - id?: string | undefined; - /** - * Name of the account. - */ - name?: string | null | undefined; - /** - * Reference given to each nominal account for a business. It ensures money is allocated to the correct account. This code isn't a unique identifier in the Codat system. - */ - nominalCode?: string | null | undefined; - /** - * Classification of the type of G/L account. - */ - classification?: string | null | undefined; + /** + * Identifier for the account, unique for the company. + */ + id?: string | undefined; + /** + * Name of the account. + */ + name?: string | null | undefined; + /** + * Reference given to each nominal account for a business. It ensures money is allocated to the correct account. This code isn't a unique identifier in the Codat system. + */ + nominalCode?: string | null | undefined; + /** + * Classification of the type of G/L account. + */ + classification?: string | null | undefined; }; /** @internal */ export const AccountConfigurationOption$inboundSchema: z.ZodType< - AccountConfigurationOption, - z.ZodTypeDef, - unknown + AccountConfigurationOption, + z.ZodTypeDef, + unknown > = z.object({ - id: z.string().optional(), - name: z.nullable(z.string()).optional(), - nominalCode: z.nullable(z.string()).optional(), - classification: z.nullable(z.string()).optional(), + id: z.string().optional(), + name: z.nullable(z.string()).optional(), + nominalCode: z.nullable(z.string()).optional(), + classification: z.nullable(z.string()).optional(), }); /** @internal */ export type AccountConfigurationOption$Outbound = { - id?: string | undefined; - name?: string | null | undefined; - nominalCode?: string | null | undefined; - classification?: string | null | undefined; + id?: string | undefined; + name?: string | null | undefined; + nominalCode?: string | null | undefined; + classification?: string | null | undefined; }; /** @internal */ export const AccountConfigurationOption$outboundSchema: z.ZodType< - AccountConfigurationOption$Outbound, - z.ZodTypeDef, - AccountConfigurationOption + AccountConfigurationOption$Outbound, + z.ZodTypeDef, + AccountConfigurationOption > = z.object({ - id: z.string().optional(), - name: z.nullable(z.string()).optional(), - nominalCode: z.nullable(z.string()).optional(), - classification: z.nullable(z.string()).optional(), + id: z.string().optional(), + name: z.nullable(z.string()).optional(), + nominalCode: z.nullable(z.string()).optional(), + classification: z.nullable(z.string()).optional(), }); /** @@ -60,10 +63,28 @@ export const AccountConfigurationOption$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AccountConfigurationOption$ { - /** @deprecated use `AccountConfigurationOption$inboundSchema` instead. */ - export const inboundSchema = AccountConfigurationOption$inboundSchema; - /** @deprecated use `AccountConfigurationOption$outboundSchema` instead. */ - export const outboundSchema = AccountConfigurationOption$outboundSchema; - /** @deprecated use `AccountConfigurationOption$Outbound` instead. */ - export type Outbound = AccountConfigurationOption$Outbound; + /** @deprecated use `AccountConfigurationOption$inboundSchema` instead. */ + export const inboundSchema = AccountConfigurationOption$inboundSchema; + /** @deprecated use `AccountConfigurationOption$outboundSchema` instead. */ + export const outboundSchema = AccountConfigurationOption$outboundSchema; + /** @deprecated use `AccountConfigurationOption$Outbound` instead. */ + export type Outbound = AccountConfigurationOption$Outbound; +} + +export function accountConfigurationOptionToJSON( + accountConfigurationOption: AccountConfigurationOption, +): string { + return JSON.stringify( + AccountConfigurationOption$outboundSchema.parse(accountConfigurationOption), + ); +} + +export function accountConfigurationOptionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AccountConfigurationOption$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AccountConfigurationOption' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/branding.ts b/sync-for-commerce/src/sdk/models/shared/branding.ts index c2251e184..04e95943e 100644 --- a/sync-for-commerce/src/sdk/models/shared/branding.ts +++ b/sync-for-commerce/src/sdk/models/shared/branding.ts @@ -1,67 +1,91 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - BrandingButton, - BrandingButton$inboundSchema, - BrandingButton$Outbound, - BrandingButton$outboundSchema, + BrandingButton, + BrandingButton$inboundSchema, + BrandingButton$Outbound, + BrandingButton$outboundSchema, } from "./brandingbutton.js"; import { - BrandingLogo, - BrandingLogo$inboundSchema, - BrandingLogo$Outbound, - BrandingLogo$outboundSchema, + BrandingLogo, + BrandingLogo$inboundSchema, + BrandingLogo$Outbound, + BrandingLogo$outboundSchema, } from "./brandinglogo.js"; -import * as z from "zod"; export type Branding = { - /** - * Logo branding references. - */ - logo?: BrandingLogo | undefined; - /** - * Button branding references. - */ - button?: BrandingButton | undefined; - /** - * A source-specific ID used to distinguish between different sources originating from the same data connection. In general, a data connection is a single data source. However, for TrueLayer, `sourceId` is associated with a specific bank and has a many-to-one relationship with the `integrationId`. - */ - sourceId?: string | undefined; + /** + * Logo branding references. + */ + logo?: BrandingLogo | undefined; + /** + * Button branding references. + */ + button?: BrandingButton | undefined; + /** + * A source-specific ID used to distinguish between different sources originating from the same data connection. In general, a data connection is a single data source. However, for TrueLayer, `sourceId` is associated with a specific bank and has a many-to-one relationship with the `integrationId`. + */ + sourceId?: string | undefined; }; /** @internal */ -export const Branding$inboundSchema: z.ZodType = z.object({ - logo: BrandingLogo$inboundSchema.optional(), - button: BrandingButton$inboundSchema.optional(), - sourceId: z.string().optional(), +export const Branding$inboundSchema: z.ZodType< + Branding, + z.ZodTypeDef, + unknown +> = z.object({ + logo: BrandingLogo$inboundSchema.optional(), + button: BrandingButton$inboundSchema.optional(), + sourceId: z.string().optional(), }); /** @internal */ export type Branding$Outbound = { - logo?: BrandingLogo$Outbound | undefined; - button?: BrandingButton$Outbound | undefined; - sourceId?: string | undefined; + logo?: BrandingLogo$Outbound | undefined; + button?: BrandingButton$Outbound | undefined; + sourceId?: string | undefined; }; /** @internal */ -export const Branding$outboundSchema: z.ZodType = - z.object({ - logo: BrandingLogo$outboundSchema.optional(), - button: BrandingButton$outboundSchema.optional(), - sourceId: z.string().optional(), - }); +export const Branding$outboundSchema: z.ZodType< + Branding$Outbound, + z.ZodTypeDef, + Branding +> = z.object({ + logo: BrandingLogo$outboundSchema.optional(), + button: BrandingButton$outboundSchema.optional(), + sourceId: z.string().optional(), +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Branding$ { - /** @deprecated use `Branding$inboundSchema` instead. */ - export const inboundSchema = Branding$inboundSchema; - /** @deprecated use `Branding$outboundSchema` instead. */ - export const outboundSchema = Branding$outboundSchema; - /** @deprecated use `Branding$Outbound` instead. */ - export type Outbound = Branding$Outbound; + /** @deprecated use `Branding$inboundSchema` instead. */ + export const inboundSchema = Branding$inboundSchema; + /** @deprecated use `Branding$outboundSchema` instead. */ + export const outboundSchema = Branding$outboundSchema; + /** @deprecated use `Branding$Outbound` instead. */ + export type Outbound = Branding$Outbound; +} + +export function brandingToJSON(branding: Branding): string { + return JSON.stringify(Branding$outboundSchema.parse(branding)); +} + +export function brandingFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Branding$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Branding' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/brandingbutton.ts b/sync-for-commerce/src/sdk/models/shared/brandingbutton.ts index d0abaca99..9137a5b74 100644 --- a/sync-for-commerce/src/sdk/models/shared/brandingbutton.ts +++ b/sync-for-commerce/src/sdk/models/shared/brandingbutton.ts @@ -1,44 +1,50 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - BrandingImage, - BrandingImage$inboundSchema, - BrandingImage$Outbound, - BrandingImage$outboundSchema, + BrandingImage, + BrandingImage$inboundSchema, + BrandingImage$Outbound, + BrandingImage$outboundSchema, } from "./brandingimage.js"; -import * as z from "zod"; /** * Button branding references. */ export type BrandingButton = { - default?: BrandingImage | undefined; - hover?: BrandingImage | undefined; + default?: BrandingImage | undefined; + hover?: BrandingImage | undefined; }; /** @internal */ -export const BrandingButton$inboundSchema: z.ZodType = - z.object({ - default: BrandingImage$inboundSchema.optional(), - hover: BrandingImage$inboundSchema.optional(), - }); +export const BrandingButton$inboundSchema: z.ZodType< + BrandingButton, + z.ZodTypeDef, + unknown +> = z.object({ + default: BrandingImage$inboundSchema.optional(), + hover: BrandingImage$inboundSchema.optional(), +}); /** @internal */ export type BrandingButton$Outbound = { - default?: BrandingImage$Outbound | undefined; - hover?: BrandingImage$Outbound | undefined; + default?: BrandingImage$Outbound | undefined; + hover?: BrandingImage$Outbound | undefined; }; /** @internal */ export const BrandingButton$outboundSchema: z.ZodType< - BrandingButton$Outbound, - z.ZodTypeDef, - BrandingButton + BrandingButton$Outbound, + z.ZodTypeDef, + BrandingButton > = z.object({ - default: BrandingImage$outboundSchema.optional(), - hover: BrandingImage$outboundSchema.optional(), + default: BrandingImage$outboundSchema.optional(), + hover: BrandingImage$outboundSchema.optional(), }); /** @@ -46,10 +52,24 @@ export const BrandingButton$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BrandingButton$ { - /** @deprecated use `BrandingButton$inboundSchema` instead. */ - export const inboundSchema = BrandingButton$inboundSchema; - /** @deprecated use `BrandingButton$outboundSchema` instead. */ - export const outboundSchema = BrandingButton$outboundSchema; - /** @deprecated use `BrandingButton$Outbound` instead. */ - export type Outbound = BrandingButton$Outbound; + /** @deprecated use `BrandingButton$inboundSchema` instead. */ + export const inboundSchema = BrandingButton$inboundSchema; + /** @deprecated use `BrandingButton$outboundSchema` instead. */ + export const outboundSchema = BrandingButton$outboundSchema; + /** @deprecated use `BrandingButton$Outbound` instead. */ + export type Outbound = BrandingButton$Outbound; +} + +export function brandingButtonToJSON(brandingButton: BrandingButton): string { + return JSON.stringify(BrandingButton$outboundSchema.parse(brandingButton)); +} + +export function brandingButtonFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => BrandingButton$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'BrandingButton' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/brandingimage.ts b/sync-for-commerce/src/sdk/models/shared/brandingimage.ts index a58c0a4e4..1319b146e 100644 --- a/sync-for-commerce/src/sdk/models/shared/brandingimage.ts +++ b/sync-for-commerce/src/sdk/models/shared/brandingimage.ts @@ -1,40 +1,46 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - ImageReference, - ImageReference$inboundSchema, - ImageReference$Outbound, - ImageReference$outboundSchema, + ImageReference, + ImageReference$inboundSchema, + ImageReference$Outbound, + ImageReference$outboundSchema, } from "./imagereference.js"; -import * as z from "zod"; export type BrandingImage = { - /** - * Image reference. - */ - image?: ImageReference | undefined; + /** + * Image reference. + */ + image?: ImageReference | undefined; }; /** @internal */ -export const BrandingImage$inboundSchema: z.ZodType = - z.object({ - image: ImageReference$inboundSchema.optional(), - }); +export const BrandingImage$inboundSchema: z.ZodType< + BrandingImage, + z.ZodTypeDef, + unknown +> = z.object({ + image: ImageReference$inboundSchema.optional(), +}); /** @internal */ export type BrandingImage$Outbound = { - image?: ImageReference$Outbound | undefined; + image?: ImageReference$Outbound | undefined; }; /** @internal */ export const BrandingImage$outboundSchema: z.ZodType< - BrandingImage$Outbound, - z.ZodTypeDef, - BrandingImage + BrandingImage$Outbound, + z.ZodTypeDef, + BrandingImage > = z.object({ - image: ImageReference$outboundSchema.optional(), + image: ImageReference$outboundSchema.optional(), }); /** @@ -42,10 +48,24 @@ export const BrandingImage$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BrandingImage$ { - /** @deprecated use `BrandingImage$inboundSchema` instead. */ - export const inboundSchema = BrandingImage$inboundSchema; - /** @deprecated use `BrandingImage$outboundSchema` instead. */ - export const outboundSchema = BrandingImage$outboundSchema; - /** @deprecated use `BrandingImage$Outbound` instead. */ - export type Outbound = BrandingImage$Outbound; + /** @deprecated use `BrandingImage$inboundSchema` instead. */ + export const inboundSchema = BrandingImage$inboundSchema; + /** @deprecated use `BrandingImage$outboundSchema` instead. */ + export const outboundSchema = BrandingImage$outboundSchema; + /** @deprecated use `BrandingImage$Outbound` instead. */ + export type Outbound = BrandingImage$Outbound; +} + +export function brandingImageToJSON(brandingImage: BrandingImage): string { + return JSON.stringify(BrandingImage$outboundSchema.parse(brandingImage)); +} + +export function brandingImageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => BrandingImage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'BrandingImage' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/brandinglogo.ts b/sync-for-commerce/src/sdk/models/shared/brandinglogo.ts index e76fe562c..4092ec41e 100644 --- a/sync-for-commerce/src/sdk/models/shared/brandinglogo.ts +++ b/sync-for-commerce/src/sdk/models/shared/brandinglogo.ts @@ -1,43 +1,50 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - BrandingImage, - BrandingImage$inboundSchema, - BrandingImage$Outbound, - BrandingImage$outboundSchema, + BrandingImage, + BrandingImage$inboundSchema, + BrandingImage$Outbound, + BrandingImage$outboundSchema, } from "./brandingimage.js"; -import * as z from "zod"; /** * Logo branding references. */ export type BrandingLogo = { - full?: BrandingImage | undefined; - square?: BrandingImage | undefined; + full?: BrandingImage | undefined; + square?: BrandingImage | undefined; }; /** @internal */ -export const BrandingLogo$inboundSchema: z.ZodType = z.object({ - full: BrandingImage$inboundSchema.optional(), - square: BrandingImage$inboundSchema.optional(), +export const BrandingLogo$inboundSchema: z.ZodType< + BrandingLogo, + z.ZodTypeDef, + unknown +> = z.object({ + full: BrandingImage$inboundSchema.optional(), + square: BrandingImage$inboundSchema.optional(), }); /** @internal */ export type BrandingLogo$Outbound = { - full?: BrandingImage$Outbound | undefined; - square?: BrandingImage$Outbound | undefined; + full?: BrandingImage$Outbound | undefined; + square?: BrandingImage$Outbound | undefined; }; /** @internal */ export const BrandingLogo$outboundSchema: z.ZodType< - BrandingLogo$Outbound, - z.ZodTypeDef, - BrandingLogo + BrandingLogo$Outbound, + z.ZodTypeDef, + BrandingLogo > = z.object({ - full: BrandingImage$outboundSchema.optional(), - square: BrandingImage$outboundSchema.optional(), + full: BrandingImage$outboundSchema.optional(), + square: BrandingImage$outboundSchema.optional(), }); /** @@ -45,10 +52,24 @@ export const BrandingLogo$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BrandingLogo$ { - /** @deprecated use `BrandingLogo$inboundSchema` instead. */ - export const inboundSchema = BrandingLogo$inboundSchema; - /** @deprecated use `BrandingLogo$outboundSchema` instead. */ - export const outboundSchema = BrandingLogo$outboundSchema; - /** @deprecated use `BrandingLogo$Outbound` instead. */ - export type Outbound = BrandingLogo$Outbound; + /** @deprecated use `BrandingLogo$inboundSchema` instead. */ + export const inboundSchema = BrandingLogo$inboundSchema; + /** @deprecated use `BrandingLogo$outboundSchema` instead. */ + export const outboundSchema = BrandingLogo$outboundSchema; + /** @deprecated use `BrandingLogo$Outbound` instead. */ + export type Outbound = BrandingLogo$Outbound; +} + +export function brandingLogoToJSON(brandingLogo: BrandingLogo): string { + return JSON.stringify(BrandingLogo$outboundSchema.parse(brandingLogo)); +} + +export function brandingLogoFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => BrandingLogo$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'BrandingLogo' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/commerceconfiguration.ts b/sync-for-commerce/src/sdk/models/shared/commerceconfiguration.ts index 6e235053f..2d26d91de 100644 --- a/sync-for-commerce/src/sdk/models/shared/commerceconfiguration.ts +++ b/sync-for-commerce/src/sdk/models/shared/commerceconfiguration.ts @@ -1,87 +1,90 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - ConfigurationMapSettings, - ConfigurationMapSettings$inboundSchema, - ConfigurationMapSettings$Outbound, - ConfigurationMapSettings$outboundSchema, + ConfigurationMapSettings, + ConfigurationMapSettings$inboundSchema, + ConfigurationMapSettings$Outbound, + ConfigurationMapSettings$outboundSchema, } from "./configurationmapsettings.js"; import { - FeesConfiguration, - FeesConfiguration$inboundSchema, - FeesConfiguration$Outbound, - FeesConfiguration$outboundSchema, + FeesConfiguration, + FeesConfiguration$inboundSchema, + FeesConfiguration$Outbound, + FeesConfiguration$outboundSchema, } from "./feesconfiguration.js"; import { - NewPaymentsConfiguration, - NewPaymentsConfiguration$inboundSchema, - NewPaymentsConfiguration$Outbound, - NewPaymentsConfiguration$outboundSchema, + NewPaymentsConfiguration, + NewPaymentsConfiguration$inboundSchema, + NewPaymentsConfiguration$Outbound, + NewPaymentsConfiguration$outboundSchema, } from "./newpaymentsconfiguration.js"; import { - PaymentsConfiguration, - PaymentsConfiguration$inboundSchema, - PaymentsConfiguration$Outbound, - PaymentsConfiguration$outboundSchema, + PaymentsConfiguration, + PaymentsConfiguration$inboundSchema, + PaymentsConfiguration$Outbound, + PaymentsConfiguration$outboundSchema, } from "./paymentsconfiguration.js"; import { - SalesConfiguration, - SalesConfiguration$inboundSchema, - SalesConfiguration$Outbound, - SalesConfiguration$outboundSchema, + SalesConfiguration, + SalesConfiguration$inboundSchema, + SalesConfiguration$Outbound, + SalesConfiguration$outboundSchema, } from "./salesconfiguration.js"; -import * as z from "zod"; export type CommerceConfiguration = { - /** - * The country code outlining where the company is based. - */ - countryCode?: string | undefined; - mapSettings?: ConfigurationMapSettings | undefined; - sales?: SalesConfiguration | undefined; - payments?: PaymentsConfiguration | undefined; - newPayments?: NewPaymentsConfiguration | undefined; - fees?: FeesConfiguration | undefined; + /** + * The country code outlining where the company is based. + */ + countryCode?: string | undefined; + mapSettings?: ConfigurationMapSettings | undefined; + sales?: SalesConfiguration | undefined; + payments?: PaymentsConfiguration | undefined; + newPayments?: NewPaymentsConfiguration | undefined; + fees?: FeesConfiguration | undefined; }; /** @internal */ export const CommerceConfiguration$inboundSchema: z.ZodType< - CommerceConfiguration, - z.ZodTypeDef, - unknown + CommerceConfiguration, + z.ZodTypeDef, + unknown > = z.object({ - countryCode: z.string().optional(), - mapSettings: ConfigurationMapSettings$inboundSchema.optional(), - sales: SalesConfiguration$inboundSchema.optional(), - payments: PaymentsConfiguration$inboundSchema.optional(), - newPayments: NewPaymentsConfiguration$inboundSchema.optional(), - fees: FeesConfiguration$inboundSchema.optional(), + countryCode: z.string().optional(), + mapSettings: ConfigurationMapSettings$inboundSchema.optional(), + sales: SalesConfiguration$inboundSchema.optional(), + payments: PaymentsConfiguration$inboundSchema.optional(), + newPayments: NewPaymentsConfiguration$inboundSchema.optional(), + fees: FeesConfiguration$inboundSchema.optional(), }); /** @internal */ export type CommerceConfiguration$Outbound = { - countryCode?: string | undefined; - mapSettings?: ConfigurationMapSettings$Outbound | undefined; - sales?: SalesConfiguration$Outbound | undefined; - payments?: PaymentsConfiguration$Outbound | undefined; - newPayments?: NewPaymentsConfiguration$Outbound | undefined; - fees?: FeesConfiguration$Outbound | undefined; + countryCode?: string | undefined; + mapSettings?: ConfigurationMapSettings$Outbound | undefined; + sales?: SalesConfiguration$Outbound | undefined; + payments?: PaymentsConfiguration$Outbound | undefined; + newPayments?: NewPaymentsConfiguration$Outbound | undefined; + fees?: FeesConfiguration$Outbound | undefined; }; /** @internal */ export const CommerceConfiguration$outboundSchema: z.ZodType< - CommerceConfiguration$Outbound, - z.ZodTypeDef, - CommerceConfiguration + CommerceConfiguration$Outbound, + z.ZodTypeDef, + CommerceConfiguration > = z.object({ - countryCode: z.string().optional(), - mapSettings: ConfigurationMapSettings$outboundSchema.optional(), - sales: SalesConfiguration$outboundSchema.optional(), - payments: PaymentsConfiguration$outboundSchema.optional(), - newPayments: NewPaymentsConfiguration$outboundSchema.optional(), - fees: FeesConfiguration$outboundSchema.optional(), + countryCode: z.string().optional(), + mapSettings: ConfigurationMapSettings$outboundSchema.optional(), + sales: SalesConfiguration$outboundSchema.optional(), + payments: PaymentsConfiguration$outboundSchema.optional(), + newPayments: NewPaymentsConfiguration$outboundSchema.optional(), + fees: FeesConfiguration$outboundSchema.optional(), }); /** @@ -89,10 +92,28 @@ export const CommerceConfiguration$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CommerceConfiguration$ { - /** @deprecated use `CommerceConfiguration$inboundSchema` instead. */ - export const inboundSchema = CommerceConfiguration$inboundSchema; - /** @deprecated use `CommerceConfiguration$outboundSchema` instead. */ - export const outboundSchema = CommerceConfiguration$outboundSchema; - /** @deprecated use `CommerceConfiguration$Outbound` instead. */ - export type Outbound = CommerceConfiguration$Outbound; + /** @deprecated use `CommerceConfiguration$inboundSchema` instead. */ + export const inboundSchema = CommerceConfiguration$inboundSchema; + /** @deprecated use `CommerceConfiguration$outboundSchema` instead. */ + export const outboundSchema = CommerceConfiguration$outboundSchema; + /** @deprecated use `CommerceConfiguration$Outbound` instead. */ + export type Outbound = CommerceConfiguration$Outbound; +} + +export function commerceConfigurationToJSON( + commerceConfiguration: CommerceConfiguration, +): string { + return JSON.stringify( + CommerceConfiguration$outboundSchema.parse(commerceConfiguration), + ); +} + +export function commerceConfigurationFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CommerceConfiguration$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CommerceConfiguration' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/companies.ts b/sync-for-commerce/src/sdk/models/shared/companies.ts index 56aefb9be..deb1677dc 100644 --- a/sync-for-commerce/src/sdk/models/shared/companies.ts +++ b/sync-for-commerce/src/sdk/models/shared/companies.ts @@ -1,82 +1,108 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; import { remap as remap$ } from "../../../lib/primitives.js"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - Company, - Company$inboundSchema, - Company$Outbound, - Company$outboundSchema, + Company, + Company$inboundSchema, + Company$Outbound, + Company$outboundSchema, } from "./company.js"; -import { Links, Links$inboundSchema, Links$Outbound, Links$outboundSchema } from "./links.js"; -import * as z from "zod"; +import { + Links, + Links$inboundSchema, + Links$Outbound, + Links$outboundSchema, +} from "./links.js"; export type Companies = { - results?: Array | undefined; - /** - * Current page number. - */ - pageNumber: number; - /** - * Number of items to return in results array. - */ - pageSize: number; - /** - * Total number of items. - */ - totalResults: number; - links: Links; + results?: Array | undefined; + /** + * Current page number. + */ + pageNumber: number; + /** + * Number of items to return in results array. + */ + pageSize: number; + /** + * Total number of items. + */ + totalResults: number; + links: Links; }; /** @internal */ -export const Companies$inboundSchema: z.ZodType = z - .object({ - results: z.array(Company$inboundSchema).optional(), - pageNumber: z.number().int(), - pageSize: z.number().int(), - totalResults: z.number().int(), - _links: Links$inboundSchema, - }) - .transform((v) => { - return remap$(v, { - _links: "links", - }); - }); +export const Companies$inboundSchema: z.ZodType< + Companies, + z.ZodTypeDef, + unknown +> = z.object({ + results: z.array(Company$inboundSchema).optional(), + pageNumber: z.number().int(), + pageSize: z.number().int(), + totalResults: z.number().int(), + _links: Links$inboundSchema, +}).transform((v) => { + return remap$(v, { + "_links": "links", + }); +}); /** @internal */ export type Companies$Outbound = { - results?: Array | undefined; - pageNumber: number; - pageSize: number; - totalResults: number; - _links: Links$Outbound; + results?: Array | undefined; + pageNumber: number; + pageSize: number; + totalResults: number; + _links: Links$Outbound; }; /** @internal */ -export const Companies$outboundSchema: z.ZodType = z - .object({ - results: z.array(Company$outboundSchema).optional(), - pageNumber: z.number().int(), - pageSize: z.number().int(), - totalResults: z.number().int(), - links: Links$outboundSchema, - }) - .transform((v) => { - return remap$(v, { - links: "_links", - }); - }); +export const Companies$outboundSchema: z.ZodType< + Companies$Outbound, + z.ZodTypeDef, + Companies +> = z.object({ + results: z.array(Company$outboundSchema).optional(), + pageNumber: z.number().int(), + pageSize: z.number().int(), + totalResults: z.number().int(), + links: Links$outboundSchema, +}).transform((v) => { + return remap$(v, { + links: "_links", + }); +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Companies$ { - /** @deprecated use `Companies$inboundSchema` instead. */ - export const inboundSchema = Companies$inboundSchema; - /** @deprecated use `Companies$outboundSchema` instead. */ - export const outboundSchema = Companies$outboundSchema; - /** @deprecated use `Companies$Outbound` instead. */ - export type Outbound = Companies$Outbound; + /** @deprecated use `Companies$inboundSchema` instead. */ + export const inboundSchema = Companies$inboundSchema; + /** @deprecated use `Companies$outboundSchema` instead. */ + export const outboundSchema = Companies$outboundSchema; + /** @deprecated use `Companies$Outbound` instead. */ + export type Outbound = Companies$Outbound; +} + +export function companiesToJSON(companies: Companies): string { + return JSON.stringify(Companies$outboundSchema.parse(companies)); +} + +export function companiesFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Companies$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Companies' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/company.ts b/sync-for-commerce/src/sdk/models/shared/company.ts index a4f54f72a..5d39386bd 100644 --- a/sync-for-commerce/src/sdk/models/shared/company.ts +++ b/sync-for-commerce/src/sdk/models/shared/company.ts @@ -1,21 +1,23 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; +import { + CompanyReference, + CompanyReference$inboundSchema, + CompanyReference$Outbound, + CompanyReference$outboundSchema, +} from "./companyreference.js"; import { - Connection, - Connection$inboundSchema, - Connection$Outbound, - Connection$outboundSchema, + Connection, + Connection$inboundSchema, + Connection$Outbound, + Connection$outboundSchema, } from "./connection.js"; -import * as z from "zod"; - -export type GroupReference = { - /** - * Unique identifier for the group. - */ - id?: string | undefined; -}; /** * In Codat, a company represents a business sharing access to their data. Each company can have multiple [connections](https://docs.codat.io/sync-for-sync-for-commerce-api#/schemas/Connection) to different data sources such as one connection to [Xero](https://docs.codat.io/integrations/accounting/xero/accounting-xero) for accounting data, two connections to [Plaid](https://docs.codat.io/integrations/banking/plaid/banking-plaid) for two bank accounts and a connection to [Zettle](https://docs.codat.io/integrations/commerce/zettle/commerce-zettle) for POS data. @@ -27,160 +29,139 @@ export type GroupReference = { * When you create a company, you can specify a `name` and we will automatically generate a unique `id` for the company. You can also add a `description` to store any additional information about the company. */ export type Company = { - /** - * Unique identifier for your SMB in Codat. - */ - id: string; - /** - * The name of the company - */ - name: string; - /** - * Additional information about the company. This can be used to store foreign IDs, references, etc. - */ - description?: string | undefined; - /** - * `platformKeys` name used when creating the company. - * - * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. - */ - platform?: string | undefined; - /** - * The `redirect` [Link URL](https://docs.codat.io/auth-flow/authorize-hosted-link) enabling the customer to start their auth flow journey for the company. - */ - redirect: string; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - lastSync?: string | undefined; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - created?: string | undefined; - /** - * Name of user that created the company in Codat. - */ - createdByUserName?: string | undefined; - dataConnections?: Array | undefined; - /** - * An array of groups the company has been assigned to. - */ - groups?: Array | undefined; -}; - -/** @internal */ -export const GroupReference$inboundSchema: z.ZodType = - z.object({ - id: z.string().optional(), - }); - -/** @internal */ -export type GroupReference$Outbound = { - id?: string | undefined; + /** + * Unique identifier for your SMB in Codat. + */ + id: string; + /** + * The name of the company + */ + name: string; + /** + * Additional information about the company. This can be used to store foreign IDs, references, etc. + */ + description?: string | undefined; + /** + * The `redirect` [Link URL](https://docs.codat.io/auth-flow/authorize-hosted-link) enabling the customer to start their auth flow journey for the company. + */ + redirect: string; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + lastSync?: string | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + created?: string | undefined; + /** + * Name of user that created the company in Codat. + */ + createdByUserName?: string | null | undefined; + /** + * An array of products that are currently enabled for the company. + */ + products?: Array | undefined; + /** + * A collection of user-defined key-value pairs that store custom metadata against the company. + */ + tags?: { [k: string]: string } | undefined; + referenceParentCompany?: CompanyReference | undefined; + /** + * A list of subsidiary companies owned or controlled by this entity. Empty if the company has no children. + */ + referenceSubsidiaryCompanies?: Array | undefined; + dataConnections?: Array | undefined; }; /** @internal */ -export const GroupReference$outboundSchema: z.ZodType< - GroupReference$Outbound, - z.ZodTypeDef, - GroupReference -> = z.object({ - id: z.string().optional(), -}); - -/** - * @internal - * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. - */ -export namespace GroupReference$ { - /** @deprecated use `GroupReference$inboundSchema` instead. */ - export const inboundSchema = GroupReference$inboundSchema; - /** @deprecated use `GroupReference$outboundSchema` instead. */ - export const outboundSchema = GroupReference$outboundSchema; - /** @deprecated use `GroupReference$Outbound` instead. */ - export type Outbound = GroupReference$Outbound; -} - -/** @internal */ -export const Company$inboundSchema: z.ZodType = z.object({ +export const Company$inboundSchema: z.ZodType = + z.object({ id: z.string(), name: z.string(), description: z.string().optional(), - platform: z.string().optional(), redirect: z.string(), lastSync: z.string().optional(), created: z.string().optional(), - createdByUserName: z.string().optional(), + createdByUserName: z.nullable(z.string()).optional(), + products: z.array(z.string()).optional(), + tags: z.record(z.string()).optional(), + referenceParentCompany: CompanyReference$inboundSchema.optional(), + referenceSubsidiaryCompanies: z.array(CompanyReference$inboundSchema) + .optional(), dataConnections: z.array(Connection$inboundSchema).optional(), - groups: z.array(z.lazy(() => GroupReference$inboundSchema)).optional(), -}); + }); /** @internal */ export type Company$Outbound = { - id: string; - name: string; - description?: string | undefined; - platform?: string | undefined; - redirect: string; - lastSync?: string | undefined; - created?: string | undefined; - createdByUserName?: string | undefined; - dataConnections?: Array | undefined; - groups?: Array | undefined; + id: string; + name: string; + description?: string | undefined; + redirect: string; + lastSync?: string | undefined; + created?: string | undefined; + createdByUserName?: string | null | undefined; + products?: Array | undefined; + tags?: { [k: string]: string } | undefined; + referenceParentCompany?: CompanyReference$Outbound | undefined; + referenceSubsidiaryCompanies?: Array | undefined; + dataConnections?: Array | undefined; }; /** @internal */ -export const Company$outboundSchema: z.ZodType = z.object({ - id: z.string(), - name: z.string(), - description: z.string().optional(), - platform: z.string().optional(), - redirect: z.string(), - lastSync: z.string().optional(), - created: z.string().optional(), - createdByUserName: z.string().optional(), - dataConnections: z.array(Connection$outboundSchema).optional(), - groups: z.array(z.lazy(() => GroupReference$outboundSchema)).optional(), +export const Company$outboundSchema: z.ZodType< + Company$Outbound, + z.ZodTypeDef, + Company +> = z.object({ + id: z.string(), + name: z.string(), + description: z.string().optional(), + redirect: z.string(), + lastSync: z.string().optional(), + created: z.string().optional(), + createdByUserName: z.nullable(z.string()).optional(), + products: z.array(z.string()).optional(), + tags: z.record(z.string()).optional(), + referenceParentCompany: CompanyReference$outboundSchema.optional(), + referenceSubsidiaryCompanies: z.array(CompanyReference$outboundSchema) + .optional(), + dataConnections: z.array(Connection$outboundSchema).optional(), }); /** @@ -188,10 +169,24 @@ export const Company$outboundSchema: z.ZodType { + return safeParse( + jsonString, + (x) => Company$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Company' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/companyreference.ts b/sync-for-commerce/src/sdk/models/shared/companyreference.ts new file mode 100644 index 000000000..6409b598a --- /dev/null +++ b/sync-for-commerce/src/sdk/models/shared/companyreference.ts @@ -0,0 +1,161 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; + +/** + * A collection of links for the company. + */ +export type CompanyReferenceLinks = { + /** + * Link to the company page in the portal. + */ + portal?: string | undefined; +}; + +export type CompanyReference = { + /** + * Unique identifier for your SMB in Codat. + */ + id?: string | undefined; + /** + * The name of the company + */ + name?: string | undefined; + /** + * Additional information about the company. This can be used to store foreign IDs, references, etc. + */ + description?: string | undefined; + /** + * A collection of links for the company. + */ + links?: CompanyReferenceLinks | undefined; + /** + * A collection of user-defined key-value pairs that store custom metadata against the company. + */ + tags?: { [k: string]: string } | undefined; +}; + +/** @internal */ +export const CompanyReferenceLinks$inboundSchema: z.ZodType< + CompanyReferenceLinks, + z.ZodTypeDef, + unknown +> = z.object({ + portal: z.string().optional(), +}); + +/** @internal */ +export type CompanyReferenceLinks$Outbound = { + portal?: string | undefined; +}; + +/** @internal */ +export const CompanyReferenceLinks$outboundSchema: z.ZodType< + CompanyReferenceLinks$Outbound, + z.ZodTypeDef, + CompanyReferenceLinks +> = z.object({ + portal: z.string().optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace CompanyReferenceLinks$ { + /** @deprecated use `CompanyReferenceLinks$inboundSchema` instead. */ + export const inboundSchema = CompanyReferenceLinks$inboundSchema; + /** @deprecated use `CompanyReferenceLinks$outboundSchema` instead. */ + export const outboundSchema = CompanyReferenceLinks$outboundSchema; + /** @deprecated use `CompanyReferenceLinks$Outbound` instead. */ + export type Outbound = CompanyReferenceLinks$Outbound; +} + +export function companyReferenceLinksToJSON( + companyReferenceLinks: CompanyReferenceLinks, +): string { + return JSON.stringify( + CompanyReferenceLinks$outboundSchema.parse(companyReferenceLinks), + ); +} + +export function companyReferenceLinksFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CompanyReferenceLinks$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CompanyReferenceLinks' from JSON`, + ); +} + +/** @internal */ +export const CompanyReference$inboundSchema: z.ZodType< + CompanyReference, + z.ZodTypeDef, + unknown +> = z.object({ + id: z.string().optional(), + name: z.string().optional(), + description: z.string().optional(), + links: z.lazy(() => CompanyReferenceLinks$inboundSchema).optional(), + tags: z.record(z.string()).optional(), +}); + +/** @internal */ +export type CompanyReference$Outbound = { + id?: string | undefined; + name?: string | undefined; + description?: string | undefined; + links?: CompanyReferenceLinks$Outbound | undefined; + tags?: { [k: string]: string } | undefined; +}; + +/** @internal */ +export const CompanyReference$outboundSchema: z.ZodType< + CompanyReference$Outbound, + z.ZodTypeDef, + CompanyReference +> = z.object({ + id: z.string().optional(), + name: z.string().optional(), + description: z.string().optional(), + links: z.lazy(() => CompanyReferenceLinks$outboundSchema).optional(), + tags: z.record(z.string()).optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace CompanyReference$ { + /** @deprecated use `CompanyReference$inboundSchema` instead. */ + export const inboundSchema = CompanyReference$inboundSchema; + /** @deprecated use `CompanyReference$outboundSchema` instead. */ + export const outboundSchema = CompanyReference$outboundSchema; + /** @deprecated use `CompanyReference$Outbound` instead. */ + export type Outbound = CompanyReference$Outbound; +} + +export function companyReferenceToJSON( + companyReference: CompanyReference, +): string { + return JSON.stringify( + CompanyReference$outboundSchema.parse(companyReference), + ); +} + +export function companyReferenceFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CompanyReference$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CompanyReference' from JSON`, + ); +} diff --git a/sync-for-commerce/src/sdk/models/shared/companysyncstatus.ts b/sync-for-commerce/src/sdk/models/shared/companysyncstatus.ts index d83591fa3..22055b840 100644 --- a/sync-for-commerce/src/sdk/models/shared/companysyncstatus.ts +++ b/sync-for-commerce/src/sdk/models/shared/companysyncstatus.ts @@ -1,103 +1,107 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CompanySyncStatus = { - /** - * Unique identifier for your SMB in Codat. - */ - companyId?: string | null | undefined; - /** - * Unique identifier of the sync. - */ - syncId?: string | null | undefined; - /** - * Status code of the sync. - */ - syncStatusCode?: number | undefined; - /** - * Text status of the sync. - */ - syncStatus?: string | null | undefined; - /** - * Error message of the sync. - */ - errorMessage?: string | null | undefined; - /** - * Exception message of the sync. - */ - syncExceptionMessage?: string | null | undefined; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - syncUtc?: string | undefined; - /** - * Boolean of whether the sync resulted in data being pushed. - */ - dataPushed?: boolean | undefined; + /** + * Unique identifier for your SMB in Codat. + */ + companyId?: string | null | undefined; + /** + * Unique identifier of the sync. + */ + syncId?: string | null | undefined; + /** + * Status code of the sync. + */ + syncStatusCode?: number | undefined; + /** + * Text status of the sync. + */ + syncStatus?: string | null | undefined; + /** + * Error message of the sync. + */ + errorMessage?: string | null | undefined; + /** + * Exception message of the sync. + */ + syncExceptionMessage?: string | null | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + syncUtc?: string | undefined; + /** + * Boolean of whether the sync resulted in data being pushed. + */ + dataPushed?: boolean | undefined; }; /** @internal */ -export const CompanySyncStatus$inboundSchema: z.ZodType = - z.object({ - companyId: z.nullable(z.string()).optional(), - syncId: z.nullable(z.string()).optional(), - syncStatusCode: z.number().int().optional(), - syncStatus: z.nullable(z.string()).optional(), - errorMessage: z.nullable(z.string()).optional(), - syncExceptionMessage: z.nullable(z.string()).optional(), - syncUtc: z.string().optional(), - dataPushed: z.boolean().optional(), - }); +export const CompanySyncStatus$inboundSchema: z.ZodType< + CompanySyncStatus, + z.ZodTypeDef, + unknown +> = z.object({ + companyId: z.nullable(z.string()).optional(), + syncId: z.nullable(z.string()).optional(), + syncStatusCode: z.number().int().optional(), + syncStatus: z.nullable(z.string()).optional(), + errorMessage: z.nullable(z.string()).optional(), + syncExceptionMessage: z.nullable(z.string()).optional(), + syncUtc: z.string().optional(), + dataPushed: z.boolean().optional(), +}); /** @internal */ export type CompanySyncStatus$Outbound = { - companyId?: string | null | undefined; - syncId?: string | null | undefined; - syncStatusCode?: number | undefined; - syncStatus?: string | null | undefined; - errorMessage?: string | null | undefined; - syncExceptionMessage?: string | null | undefined; - syncUtc?: string | undefined; - dataPushed?: boolean | undefined; + companyId?: string | null | undefined; + syncId?: string | null | undefined; + syncStatusCode?: number | undefined; + syncStatus?: string | null | undefined; + errorMessage?: string | null | undefined; + syncExceptionMessage?: string | null | undefined; + syncUtc?: string | undefined; + dataPushed?: boolean | undefined; }; /** @internal */ export const CompanySyncStatus$outboundSchema: z.ZodType< - CompanySyncStatus$Outbound, - z.ZodTypeDef, - CompanySyncStatus + CompanySyncStatus$Outbound, + z.ZodTypeDef, + CompanySyncStatus > = z.object({ - companyId: z.nullable(z.string()).optional(), - syncId: z.nullable(z.string()).optional(), - syncStatusCode: z.number().int().optional(), - syncStatus: z.nullable(z.string()).optional(), - errorMessage: z.nullable(z.string()).optional(), - syncExceptionMessage: z.nullable(z.string()).optional(), - syncUtc: z.string().optional(), - dataPushed: z.boolean().optional(), + companyId: z.nullable(z.string()).optional(), + syncId: z.nullable(z.string()).optional(), + syncStatusCode: z.number().int().optional(), + syncStatus: z.nullable(z.string()).optional(), + errorMessage: z.nullable(z.string()).optional(), + syncExceptionMessage: z.nullable(z.string()).optional(), + syncUtc: z.string().optional(), + dataPushed: z.boolean().optional(), }); /** @@ -105,10 +109,28 @@ export const CompanySyncStatus$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CompanySyncStatus$ { - /** @deprecated use `CompanySyncStatus$inboundSchema` instead. */ - export const inboundSchema = CompanySyncStatus$inboundSchema; - /** @deprecated use `CompanySyncStatus$outboundSchema` instead. */ - export const outboundSchema = CompanySyncStatus$outboundSchema; - /** @deprecated use `CompanySyncStatus$Outbound` instead. */ - export type Outbound = CompanySyncStatus$Outbound; + /** @deprecated use `CompanySyncStatus$inboundSchema` instead. */ + export const inboundSchema = CompanySyncStatus$inboundSchema; + /** @deprecated use `CompanySyncStatus$outboundSchema` instead. */ + export const outboundSchema = CompanySyncStatus$outboundSchema; + /** @deprecated use `CompanySyncStatus$Outbound` instead. */ + export type Outbound = CompanySyncStatus$Outbound; +} + +export function companySyncStatusToJSON( + companySyncStatus: CompanySyncStatus, +): string { + return JSON.stringify( + CompanySyncStatus$outboundSchema.parse(companySyncStatus), + ); +} + +export function companySyncStatusFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CompanySyncStatus$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CompanySyncStatus' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/configuration.ts b/sync-for-commerce/src/sdk/models/shared/configuration.ts index bb305fcd6..f24af2c2a 100644 --- a/sync-for-commerce/src/sdk/models/shared/configuration.ts +++ b/sync-for-commerce/src/sdk/models/shared/configuration.ts @@ -1,75 +1,81 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - CommerceConfiguration, - CommerceConfiguration$inboundSchema, - CommerceConfiguration$Outbound, - CommerceConfiguration$outboundSchema, + CommerceConfiguration, + CommerceConfiguration$inboundSchema, + CommerceConfiguration$Outbound, + CommerceConfiguration$outboundSchema, } from "./commerceconfiguration.js"; import { - SyncSchedule, - SyncSchedule$inboundSchema, - SyncSchedule$Outbound, - SyncSchedule$outboundSchema, + SyncSchedule, + SyncSchedule$inboundSchema, + SyncSchedule$Outbound, + SyncSchedule$outboundSchema, } from "./syncschedule.js"; -import * as z from "zod"; export type Configuration = { - /** - * Unique identifier for a company. - */ - companyId?: any | undefined; - /** - * The company name defined in the accounting platform. - */ - accountingSoftwareCompanyName?: string | undefined; - /** - * True if Sync for Commerce is enabled for the company. - */ - enable?: boolean | undefined; - /** - * True if Sync for Commerce has been configured for the company. - */ - configured?: boolean | undefined; - schedule?: SyncSchedule | undefined; - configuration?: CommerceConfiguration | undefined; + /** + * Unique identifier for a company. + */ + companyId?: any | undefined; + /** + * The company name defined in the accounting software. + */ + accountingSoftwareCompanyName?: string | undefined; + /** + * True if Sync for Commerce is enabled for the company. + */ + enable?: boolean | undefined; + /** + * True if Sync for Commerce has been configured for the company. + */ + configured?: boolean | undefined; + schedule?: SyncSchedule | undefined; + configuration?: CommerceConfiguration | undefined; }; /** @internal */ -export const Configuration$inboundSchema: z.ZodType = - z.object({ - companyId: z.any().optional(), - accountingSoftwareCompanyName: z.string().optional(), - enable: z.boolean().optional(), - configured: z.boolean().optional(), - schedule: SyncSchedule$inboundSchema.optional(), - configuration: CommerceConfiguration$inboundSchema.optional(), - }); +export const Configuration$inboundSchema: z.ZodType< + Configuration, + z.ZodTypeDef, + unknown +> = z.object({ + companyId: z.any().optional(), + accountingSoftwareCompanyName: z.string().optional(), + enable: z.boolean().optional(), + configured: z.boolean().optional(), + schedule: SyncSchedule$inboundSchema.optional(), + configuration: CommerceConfiguration$inboundSchema.optional(), +}); /** @internal */ export type Configuration$Outbound = { - companyId?: any | undefined; - accountingSoftwareCompanyName?: string | undefined; - enable?: boolean | undefined; - configured?: boolean | undefined; - schedule?: SyncSchedule$Outbound | undefined; - configuration?: CommerceConfiguration$Outbound | undefined; + companyId?: any | undefined; + accountingSoftwareCompanyName?: string | undefined; + enable?: boolean | undefined; + configured?: boolean | undefined; + schedule?: SyncSchedule$Outbound | undefined; + configuration?: CommerceConfiguration$Outbound | undefined; }; /** @internal */ export const Configuration$outboundSchema: z.ZodType< - Configuration$Outbound, - z.ZodTypeDef, - Configuration + Configuration$Outbound, + z.ZodTypeDef, + Configuration > = z.object({ - companyId: z.any().optional(), - accountingSoftwareCompanyName: z.string().optional(), - enable: z.boolean().optional(), - configured: z.boolean().optional(), - schedule: SyncSchedule$outboundSchema.optional(), - configuration: CommerceConfiguration$outboundSchema.optional(), + companyId: z.any().optional(), + accountingSoftwareCompanyName: z.string().optional(), + enable: z.boolean().optional(), + configured: z.boolean().optional(), + schedule: SyncSchedule$outboundSchema.optional(), + configuration: CommerceConfiguration$outboundSchema.optional(), }); /** @@ -77,10 +83,24 @@ export const Configuration$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Configuration$ { - /** @deprecated use `Configuration$inboundSchema` instead. */ - export const inboundSchema = Configuration$inboundSchema; - /** @deprecated use `Configuration$outboundSchema` instead. */ - export const outboundSchema = Configuration$outboundSchema; - /** @deprecated use `Configuration$Outbound` instead. */ - export type Outbound = Configuration$Outbound; + /** @deprecated use `Configuration$inboundSchema` instead. */ + export const inboundSchema = Configuration$inboundSchema; + /** @deprecated use `Configuration$outboundSchema` instead. */ + export const outboundSchema = Configuration$outboundSchema; + /** @deprecated use `Configuration$Outbound` instead. */ + export type Outbound = Configuration$Outbound; +} + +export function configurationToJSON(configuration: Configuration): string { + return JSON.stringify(Configuration$outboundSchema.parse(configuration)); +} + +export function configurationFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Configuration$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Configuration' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/configurationmapsettings.ts b/sync-for-commerce/src/sdk/models/shared/configurationmapsettings.ts index e1145cb56..c951240d6 100644 --- a/sync-for-commerce/src/sdk/models/shared/configurationmapsettings.ts +++ b/sync-for-commerce/src/sdk/models/shared/configurationmapsettings.ts @@ -1,68 +1,71 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ClosedEnum } from "../../types/enums.js"; import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** - * The format commerce transactions are stored in the accounting platform. + * The format commerce transactions are stored in the accounting software. */ export const OutputFormat = { - JournalEntry: "JournalEntry", + JournalEntry: "JournalEntry", } as const; /** - * The format commerce transactions are stored in the accounting platform. + * The format commerce transactions are stored in the accounting software. */ export type OutputFormat = ClosedEnum; export type ConfigurationMapSettings = { - /** - * The format commerce transactions are stored in the accounting platform. - */ - outputFormat?: OutputFormat | undefined; + /** + * The format commerce transactions are stored in the accounting software. + */ + outputFormat?: OutputFormat | undefined; }; /** @internal */ export const OutputFormat$inboundSchema: z.ZodNativeEnum = - z.nativeEnum(OutputFormat); + z.nativeEnum(OutputFormat); /** @internal */ export const OutputFormat$outboundSchema: z.ZodNativeEnum = - OutputFormat$inboundSchema; + OutputFormat$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OutputFormat$ { - /** @deprecated use `OutputFormat$inboundSchema` instead. */ - export const inboundSchema = OutputFormat$inboundSchema; - /** @deprecated use `OutputFormat$outboundSchema` instead. */ - export const outboundSchema = OutputFormat$outboundSchema; + /** @deprecated use `OutputFormat$inboundSchema` instead. */ + export const inboundSchema = OutputFormat$inboundSchema; + /** @deprecated use `OutputFormat$outboundSchema` instead. */ + export const outboundSchema = OutputFormat$outboundSchema; } /** @internal */ export const ConfigurationMapSettings$inboundSchema: z.ZodType< - ConfigurationMapSettings, - z.ZodTypeDef, - unknown + ConfigurationMapSettings, + z.ZodTypeDef, + unknown > = z.object({ - outputFormat: OutputFormat$inboundSchema.optional(), + outputFormat: OutputFormat$inboundSchema.optional(), }); /** @internal */ export type ConfigurationMapSettings$Outbound = { - outputFormat?: string | undefined; + outputFormat?: string | undefined; }; /** @internal */ export const ConfigurationMapSettings$outboundSchema: z.ZodType< - ConfigurationMapSettings$Outbound, - z.ZodTypeDef, - ConfigurationMapSettings + ConfigurationMapSettings$Outbound, + z.ZodTypeDef, + ConfigurationMapSettings > = z.object({ - outputFormat: OutputFormat$outboundSchema.optional(), + outputFormat: OutputFormat$outboundSchema.optional(), }); /** @@ -70,10 +73,28 @@ export const ConfigurationMapSettings$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ConfigurationMapSettings$ { - /** @deprecated use `ConfigurationMapSettings$inboundSchema` instead. */ - export const inboundSchema = ConfigurationMapSettings$inboundSchema; - /** @deprecated use `ConfigurationMapSettings$outboundSchema` instead. */ - export const outboundSchema = ConfigurationMapSettings$outboundSchema; - /** @deprecated use `ConfigurationMapSettings$Outbound` instead. */ - export type Outbound = ConfigurationMapSettings$Outbound; + /** @deprecated use `ConfigurationMapSettings$inboundSchema` instead. */ + export const inboundSchema = ConfigurationMapSettings$inboundSchema; + /** @deprecated use `ConfigurationMapSettings$outboundSchema` instead. */ + export const outboundSchema = ConfigurationMapSettings$outboundSchema; + /** @deprecated use `ConfigurationMapSettings$Outbound` instead. */ + export type Outbound = ConfigurationMapSettings$Outbound; +} + +export function configurationMapSettingsToJSON( + configurationMapSettings: ConfigurationMapSettings, +): string { + return JSON.stringify( + ConfigurationMapSettings$outboundSchema.parse(configurationMapSettings), + ); +} + +export function configurationMapSettingsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ConfigurationMapSettings$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ConfigurationMapSettings' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/configurationoption.ts b/sync-for-commerce/src/sdk/models/shared/configurationoption.ts index 47dea7703..20118f229 100644 --- a/sync-for-commerce/src/sdk/models/shared/configurationoption.ts +++ b/sync-for-commerce/src/sdk/models/shared/configurationoption.ts @@ -1,44 +1,47 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ConfigurationOption = { - /** - * Name value of the option. - */ - name?: string | null | undefined; - /** - * Unique identifier for the option. - */ - id?: string | undefined; + /** + * Name value of the option. + */ + name?: string | null | undefined; + /** + * Unique identifier for the option. + */ + id?: string | undefined; }; /** @internal */ export const ConfigurationOption$inboundSchema: z.ZodType< - ConfigurationOption, - z.ZodTypeDef, - unknown + ConfigurationOption, + z.ZodTypeDef, + unknown > = z.object({ - name: z.nullable(z.string()).optional(), - id: z.string().optional(), + name: z.nullable(z.string()).optional(), + id: z.string().optional(), }); /** @internal */ export type ConfigurationOption$Outbound = { - name?: string | null | undefined; - id?: string | undefined; + name?: string | null | undefined; + id?: string | undefined; }; /** @internal */ export const ConfigurationOption$outboundSchema: z.ZodType< - ConfigurationOption$Outbound, - z.ZodTypeDef, - ConfigurationOption + ConfigurationOption$Outbound, + z.ZodTypeDef, + ConfigurationOption > = z.object({ - name: z.nullable(z.string()).optional(), - id: z.string().optional(), + name: z.nullable(z.string()).optional(), + id: z.string().optional(), }); /** @@ -46,10 +49,28 @@ export const ConfigurationOption$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ConfigurationOption$ { - /** @deprecated use `ConfigurationOption$inboundSchema` instead. */ - export const inboundSchema = ConfigurationOption$inboundSchema; - /** @deprecated use `ConfigurationOption$outboundSchema` instead. */ - export const outboundSchema = ConfigurationOption$outboundSchema; - /** @deprecated use `ConfigurationOption$Outbound` instead. */ - export type Outbound = ConfigurationOption$Outbound; + /** @deprecated use `ConfigurationOption$inboundSchema` instead. */ + export const inboundSchema = ConfigurationOption$inboundSchema; + /** @deprecated use `ConfigurationOption$outboundSchema` instead. */ + export const outboundSchema = ConfigurationOption$outboundSchema; + /** @deprecated use `ConfigurationOption$Outbound` instead. */ + export type Outbound = ConfigurationOption$Outbound; +} + +export function configurationOptionToJSON( + configurationOption: ConfigurationOption, +): string { + return JSON.stringify( + ConfigurationOption$outboundSchema.parse(configurationOption), + ); +} + +export function configurationOptionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ConfigurationOption$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ConfigurationOption' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/connection.ts b/sync-for-commerce/src/sdk/models/shared/connection.ts index 0daec4efa..c410ae668 100644 --- a/sync-for-commerce/src/sdk/models/shared/connection.ts +++ b/sync-for-commerce/src/sdk/models/shared/connection.ts @@ -1,20 +1,27 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - DataConnectionError, - DataConnectionError$inboundSchema, - DataConnectionError$Outbound, - DataConnectionError$outboundSchema, + DataConnectionError, + DataConnectionError$inboundSchema, + DataConnectionError$Outbound, + DataConnectionError$outboundSchema, } from "./dataconnectionerror.js"; import { - DataConnectionStatus, - DataConnectionStatus$inboundSchema, - DataConnectionStatus$outboundSchema, + DataConnectionStatus, + DataConnectionStatus$inboundSchema, + DataConnectionStatus$outboundSchema, } from "./dataconnectionstatus.js"; -import { SourceType, SourceType$inboundSchema, SourceType$outboundSchema } from "./sourcetype.js"; -import * as z from "zod"; +import { + SourceType, + SourceType$inboundSchema, + SourceType$outboundSchema, +} from "./sourcetype.js"; /** * A connection represents a [company's](https://docs.codat.io/sync-for-sync-for-commerce-api#/schemas/Company) connection to a data source and allows you to synchronize data (pull and/or push) with that source. @@ -31,152 +38,167 @@ import * as z from "zod"; * Before you can use a data connection to pull or push data, the company must grant you access to their business data by [linking the connection](https://docs.codat.io/auth-flow/overview). */ export type Connection = { - /** - * Unique identifier for a company's data connection. - */ - id: string; - /** - * A Codat ID representing the integration. - */ - integrationId: string; - /** - * A unique four-character ID that identifies the platform of the company's data connection. This ensures continuity if the platform changes its name in the future. - */ - integrationKey: string; - /** - * A source-specific ID used to distinguish between different sources originating from the same data connection. In general, a data connection is a single data source. However, for TrueLayer, `sourceId` is associated with a specific bank and has a many-to-one relationship with the `integrationId`. - */ - sourceId: string; - /** - * The type of platform of the connection. - */ - sourceType: SourceType; - /** - * Name of integration connected to company. - */ - platformName: string; - /** - * The link URL your customers can use to authorize access to their business application. - */ - linkUrl: string; - /** - * The current authorization status of the data connection. - */ - status: DataConnectionStatus; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - lastSync?: string | undefined; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - created: string; - dataConnectionErrors?: Array | undefined; - connectionInfo?: { [k: string]: string } | undefined; - additionalProperties?: any | undefined; + /** + * Unique identifier for a company's data connection. + */ + id: string; + /** + * A Codat ID representing the integration. + */ + integrationId: string; + /** + * A unique four-character ID that identifies the platform of the company's data connection. This ensures continuity if the platform changes its name in the future. + */ + integrationKey: string; + /** + * A source-specific ID used to distinguish between different sources originating from the same data connection. In general, a data connection is a single data source. However, for TrueLayer, `sourceId` is associated with a specific bank and has a many-to-one relationship with the `integrationId`. + */ + sourceId: string; + /** + * The type of platform of the connection. + */ + sourceType: SourceType; + /** + * Name of integration connected to company. + */ + platformName: string; + /** + * The link URL your customers can use to authorize access to their business application. + */ + linkUrl: string; + /** + * The current authorization status of the data connection. + */ + status: DataConnectionStatus; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + lastSync?: string | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + created: string; + dataConnectionErrors?: Array | null | undefined; + connectionInfo?: { [k: string]: string } | null | undefined; }; /** @internal */ -export const Connection$inboundSchema: z.ZodType = z.object({ - id: z.string(), - integrationId: z.string(), - integrationKey: z.string(), - sourceId: z.string(), - sourceType: SourceType$inboundSchema, - platformName: z.string(), - linkUrl: z.string(), - status: DataConnectionStatus$inboundSchema, - lastSync: z.string().optional(), - created: z.string(), - dataConnectionErrors: z.array(DataConnectionError$inboundSchema).optional(), - connectionInfo: z.record(z.string()).optional(), - additionalProperties: z.any().optional(), +export const Connection$inboundSchema: z.ZodType< + Connection, + z.ZodTypeDef, + unknown +> = z.object({ + id: z.string(), + integrationId: z.string(), + integrationKey: z.string(), + sourceId: z.string(), + sourceType: SourceType$inboundSchema, + platformName: z.string(), + linkUrl: z.string(), + status: DataConnectionStatus$inboundSchema, + lastSync: z.string().optional(), + created: z.string(), + dataConnectionErrors: z.nullable(z.array(DataConnectionError$inboundSchema)) + .optional(), + connectionInfo: z.nullable(z.record(z.string())).optional(), }); /** @internal */ export type Connection$Outbound = { - id: string; - integrationId: string; - integrationKey: string; - sourceId: string; - sourceType: string; - platformName: string; - linkUrl: string; - status: string; - lastSync?: string | undefined; - created: string; - dataConnectionErrors?: Array | undefined; - connectionInfo?: { [k: string]: string } | undefined; - additionalProperties?: any | undefined; + id: string; + integrationId: string; + integrationKey: string; + sourceId: string; + sourceType: string; + platformName: string; + linkUrl: string; + status: string; + lastSync?: string | undefined; + created: string; + dataConnectionErrors?: Array | null | undefined; + connectionInfo?: { [k: string]: string } | null | undefined; }; /** @internal */ -export const Connection$outboundSchema: z.ZodType = - z.object({ - id: z.string(), - integrationId: z.string(), - integrationKey: z.string(), - sourceId: z.string(), - sourceType: SourceType$outboundSchema, - platformName: z.string(), - linkUrl: z.string(), - status: DataConnectionStatus$outboundSchema, - lastSync: z.string().optional(), - created: z.string(), - dataConnectionErrors: z.array(DataConnectionError$outboundSchema).optional(), - connectionInfo: z.record(z.string()).optional(), - additionalProperties: z.any().optional(), - }); +export const Connection$outboundSchema: z.ZodType< + Connection$Outbound, + z.ZodTypeDef, + Connection +> = z.object({ + id: z.string(), + integrationId: z.string(), + integrationKey: z.string(), + sourceId: z.string(), + sourceType: SourceType$outboundSchema, + platformName: z.string(), + linkUrl: z.string(), + status: DataConnectionStatus$outboundSchema, + lastSync: z.string().optional(), + created: z.string(), + dataConnectionErrors: z.nullable(z.array(DataConnectionError$outboundSchema)) + .optional(), + connectionInfo: z.nullable(z.record(z.string())).optional(), +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Connection$ { - /** @deprecated use `Connection$inboundSchema` instead. */ - export const inboundSchema = Connection$inboundSchema; - /** @deprecated use `Connection$outboundSchema` instead. */ - export const outboundSchema = Connection$outboundSchema; - /** @deprecated use `Connection$Outbound` instead. */ - export type Outbound = Connection$Outbound; + /** @deprecated use `Connection$inboundSchema` instead. */ + export const inboundSchema = Connection$inboundSchema; + /** @deprecated use `Connection$outboundSchema` instead. */ + export const outboundSchema = Connection$outboundSchema; + /** @deprecated use `Connection$Outbound` instead. */ + export type Outbound = Connection$Outbound; +} + +export function connectionToJSON(connection: Connection): string { + return JSON.stringify(Connection$outboundSchema.parse(connection)); +} + +export function connectionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Connection$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Connection' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/connections.ts b/sync-for-commerce/src/sdk/models/shared/connections.ts index f10aeec1f..f954a6903 100644 --- a/sync-for-commerce/src/sdk/models/shared/connections.ts +++ b/sync-for-commerce/src/sdk/models/shared/connections.ts @@ -1,86 +1,108 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; import { remap as remap$ } from "../../../lib/primitives.js"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - Connection, - Connection$inboundSchema, - Connection$Outbound, - Connection$outboundSchema, + Connection, + Connection$inboundSchema, + Connection$Outbound, + Connection$outboundSchema, } from "./connection.js"; -import { Links, Links$inboundSchema, Links$Outbound, Links$outboundSchema } from "./links.js"; -import * as z from "zod"; +import { + Links, + Links$inboundSchema, + Links$Outbound, + Links$outboundSchema, +} from "./links.js"; export type Connections = { - results?: Array | undefined; - /** - * Current page number. - */ - pageNumber: number; - /** - * Number of items to return in results array. - */ - pageSize: number; - /** - * Total number of items. - */ - totalResults: number; - links: Links; + results?: Array | undefined; + /** + * Current page number. + */ + pageNumber: number; + /** + * Number of items to return in results array. + */ + pageSize: number; + /** + * Total number of items. + */ + totalResults: number; + links: Links; }; /** @internal */ -export const Connections$inboundSchema: z.ZodType = z - .object({ - results: z.array(Connection$inboundSchema).optional(), - pageNumber: z.number().int(), - pageSize: z.number().int(), - totalResults: z.number().int(), - _links: Links$inboundSchema, - }) - .transform((v) => { - return remap$(v, { - _links: "links", - }); - }); +export const Connections$inboundSchema: z.ZodType< + Connections, + z.ZodTypeDef, + unknown +> = z.object({ + results: z.array(Connection$inboundSchema).optional(), + pageNumber: z.number().int(), + pageSize: z.number().int(), + totalResults: z.number().int(), + _links: Links$inboundSchema, +}).transform((v) => { + return remap$(v, { + "_links": "links", + }); +}); /** @internal */ export type Connections$Outbound = { - results?: Array | undefined; - pageNumber: number; - pageSize: number; - totalResults: number; - _links: Links$Outbound; + results?: Array | undefined; + pageNumber: number; + pageSize: number; + totalResults: number; + _links: Links$Outbound; }; /** @internal */ export const Connections$outboundSchema: z.ZodType< - Connections$Outbound, - z.ZodTypeDef, - Connections -> = z - .object({ - results: z.array(Connection$outboundSchema).optional(), - pageNumber: z.number().int(), - pageSize: z.number().int(), - totalResults: z.number().int(), - links: Links$outboundSchema, - }) - .transform((v) => { - return remap$(v, { - links: "_links", - }); - }); + Connections$Outbound, + z.ZodTypeDef, + Connections +> = z.object({ + results: z.array(Connection$outboundSchema).optional(), + pageNumber: z.number().int(), + pageSize: z.number().int(), + totalResults: z.number().int(), + links: Links$outboundSchema, +}).transform((v) => { + return remap$(v, { + links: "_links", + }); +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Connections$ { - /** @deprecated use `Connections$inboundSchema` instead. */ - export const inboundSchema = Connections$inboundSchema; - /** @deprecated use `Connections$outboundSchema` instead. */ - export const outboundSchema = Connections$outboundSchema; - /** @deprecated use `Connections$Outbound` instead. */ - export type Outbound = Connections$Outbound; + /** @deprecated use `Connections$inboundSchema` instead. */ + export const inboundSchema = Connections$inboundSchema; + /** @deprecated use `Connections$outboundSchema` instead. */ + export const outboundSchema = Connections$outboundSchema; + /** @deprecated use `Connections$Outbound` instead. */ + export type Outbound = Connections$Outbound; +} + +export function connectionsToJSON(connections: Connections): string { + return JSON.stringify(Connections$outboundSchema.parse(connections)); +} + +export function connectionsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Connections$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Connections' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/connectionwebhook.ts b/sync-for-commerce/src/sdk/models/shared/connectionwebhook.ts new file mode 100644 index 000000000..af7bee025 --- /dev/null +++ b/sync-for-commerce/src/sdk/models/shared/connectionwebhook.ts @@ -0,0 +1,111 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; +import { + ConnectionWebhookPayload, + ConnectionWebhookPayload$inboundSchema, + ConnectionWebhookPayload$Outbound, + ConnectionWebhookPayload$outboundSchema, +} from "./connectionwebhookpayload.js"; + +export type ConnectionWebhook = { + /** + * Unique identifier of the event. + */ + id?: string | undefined; + /** + * The type of event. + */ + eventType?: string | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + generatedDate?: string | undefined; + payload?: ConnectionWebhookPayload | undefined; +}; + +/** @internal */ +export const ConnectionWebhook$inboundSchema: z.ZodType< + ConnectionWebhook, + z.ZodTypeDef, + unknown +> = z.object({ + id: z.string().optional(), + eventType: z.string().optional(), + generatedDate: z.string().optional(), + payload: ConnectionWebhookPayload$inboundSchema.optional(), +}); + +/** @internal */ +export type ConnectionWebhook$Outbound = { + id?: string | undefined; + eventType?: string | undefined; + generatedDate?: string | undefined; + payload?: ConnectionWebhookPayload$Outbound | undefined; +}; + +/** @internal */ +export const ConnectionWebhook$outboundSchema: z.ZodType< + ConnectionWebhook$Outbound, + z.ZodTypeDef, + ConnectionWebhook +> = z.object({ + id: z.string().optional(), + eventType: z.string().optional(), + generatedDate: z.string().optional(), + payload: ConnectionWebhookPayload$outboundSchema.optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ConnectionWebhook$ { + /** @deprecated use `ConnectionWebhook$inboundSchema` instead. */ + export const inboundSchema = ConnectionWebhook$inboundSchema; + /** @deprecated use `ConnectionWebhook$outboundSchema` instead. */ + export const outboundSchema = ConnectionWebhook$outboundSchema; + /** @deprecated use `ConnectionWebhook$Outbound` instead. */ + export type Outbound = ConnectionWebhook$Outbound; +} + +export function connectionWebhookToJSON( + connectionWebhook: ConnectionWebhook, +): string { + return JSON.stringify( + ConnectionWebhook$outboundSchema.parse(connectionWebhook), + ); +} + +export function connectionWebhookFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ConnectionWebhook$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ConnectionWebhook' from JSON`, + ); +} diff --git a/sync-for-commerce/src/sdk/models/shared/connectionwebhookpayload.ts b/sync-for-commerce/src/sdk/models/shared/connectionwebhookpayload.ts new file mode 100644 index 000000000..374663b4e --- /dev/null +++ b/sync-for-commerce/src/sdk/models/shared/connectionwebhookpayload.ts @@ -0,0 +1,96 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; +import { + CompanyReference, + CompanyReference$inboundSchema, + CompanyReference$Outbound, + CompanyReference$outboundSchema, +} from "./companyreference.js"; +import { + Connection, + Connection$inboundSchema, + Connection$Outbound, + Connection$outboundSchema, +} from "./connection.js"; + +export type ConnectionWebhookPayload = { + referenceCompany?: CompanyReference | undefined; + /** + * A connection represents a [company's](https://docs.codat.io/sync-for-sync-for-commerce-api#/schemas/Company) connection to a data source and allows you to synchronize data (pull and/or push) with that source. + * + * @remarks + * + * A company can have multiple data connections depending on the type of data source it is connecting to. For example, a single company can link to: + * + * - [Accounting data](https://docs.codat.io/accounting-api/overview) - 1 active connection. + * - [Banking data](https://docs.codat.io/banking-api/overview) - Multiple active connections. + * - [Commerce data](https://docs.codat.io/commerce-api/overview) - Multiple active connections. + * Any combination of accounting, banking, and commerce data connections is allowed. + * + * Before you can use a data connection to pull or push data, the company must grant you access to their business data by [linking the connection](https://docs.codat.io/auth-flow/overview). + */ + connection?: Connection | undefined; +}; + +/** @internal */ +export const ConnectionWebhookPayload$inboundSchema: z.ZodType< + ConnectionWebhookPayload, + z.ZodTypeDef, + unknown +> = z.object({ + referenceCompany: CompanyReference$inboundSchema.optional(), + connection: Connection$inboundSchema.optional(), +}); + +/** @internal */ +export type ConnectionWebhookPayload$Outbound = { + referenceCompany?: CompanyReference$Outbound | undefined; + connection?: Connection$Outbound | undefined; +}; + +/** @internal */ +export const ConnectionWebhookPayload$outboundSchema: z.ZodType< + ConnectionWebhookPayload$Outbound, + z.ZodTypeDef, + ConnectionWebhookPayload +> = z.object({ + referenceCompany: CompanyReference$outboundSchema.optional(), + connection: Connection$outboundSchema.optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ConnectionWebhookPayload$ { + /** @deprecated use `ConnectionWebhookPayload$inboundSchema` instead. */ + export const inboundSchema = ConnectionWebhookPayload$inboundSchema; + /** @deprecated use `ConnectionWebhookPayload$outboundSchema` instead. */ + export const outboundSchema = ConnectionWebhookPayload$outboundSchema; + /** @deprecated use `ConnectionWebhookPayload$Outbound` instead. */ + export type Outbound = ConnectionWebhookPayload$Outbound; +} + +export function connectionWebhookPayloadToJSON( + connectionWebhookPayload: ConnectionWebhookPayload, +): string { + return JSON.stringify( + ConnectionWebhookPayload$outboundSchema.parse(connectionWebhookPayload), + ); +} + +export function connectionWebhookPayloadFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ConnectionWebhookPayload$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ConnectionWebhookPayload' from JSON`, + ); +} diff --git a/sync-for-commerce/src/sdk/models/shared/createcompany.ts b/sync-for-commerce/src/sdk/models/shared/createcompany.ts index c2c1f5dd4..96a60b255 100644 --- a/sync-for-commerce/src/sdk/models/shared/createcompany.ts +++ b/sync-for-commerce/src/sdk/models/shared/createcompany.ts @@ -1,49 +1,54 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { Items, Items$inboundSchema, Items$Outbound, Items$outboundSchema } from "./items.js"; import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreateCompany = { - /** - * Name of company being connected. - */ - name: string; - /** - * Additional information about the company. This can be used to store foreign IDs, references, etc. - */ - description?: string | undefined; - /** - * Reference to the groups that the company is assigned to. - */ - groups?: Array | undefined; + /** + * Name of company being connected. + */ + name: string; + /** + * Additional information about the company. This can be used to store foreign IDs, references, etc. + */ + description?: string | undefined; + /** + * A collection of user-defined key-value pairs that store custom metadata against the company. + */ + tags?: { [k: string]: string } | undefined; }; /** @internal */ -export const CreateCompany$inboundSchema: z.ZodType = - z.object({ - name: z.string(), - description: z.string().optional(), - groups: z.array(Items$inboundSchema).optional(), - }); +export const CreateCompany$inboundSchema: z.ZodType< + CreateCompany, + z.ZodTypeDef, + unknown +> = z.object({ + name: z.string(), + description: z.string().optional(), + tags: z.record(z.string()).optional(), +}); /** @internal */ export type CreateCompany$Outbound = { - name: string; - description?: string | undefined; - groups?: Array | undefined; + name: string; + description?: string | undefined; + tags?: { [k: string]: string } | undefined; }; /** @internal */ export const CreateCompany$outboundSchema: z.ZodType< - CreateCompany$Outbound, - z.ZodTypeDef, - CreateCompany + CreateCompany$Outbound, + z.ZodTypeDef, + CreateCompany > = z.object({ - name: z.string(), - description: z.string().optional(), - groups: z.array(Items$outboundSchema).optional(), + name: z.string(), + description: z.string().optional(), + tags: z.record(z.string()).optional(), }); /** @@ -51,10 +56,24 @@ export const CreateCompany$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CreateCompany$ { - /** @deprecated use `CreateCompany$inboundSchema` instead. */ - export const inboundSchema = CreateCompany$inboundSchema; - /** @deprecated use `CreateCompany$outboundSchema` instead. */ - export const outboundSchema = CreateCompany$outboundSchema; - /** @deprecated use `CreateCompany$Outbound` instead. */ - export type Outbound = CreateCompany$Outbound; + /** @deprecated use `CreateCompany$inboundSchema` instead. */ + export const inboundSchema = CreateCompany$inboundSchema; + /** @deprecated use `CreateCompany$outboundSchema` instead. */ + export const outboundSchema = CreateCompany$outboundSchema; + /** @deprecated use `CreateCompany$Outbound` instead. */ + export type Outbound = CreateCompany$Outbound; +} + +export function createCompanyToJSON(createCompany: CreateCompany): string { + return JSON.stringify(CreateCompany$outboundSchema.parse(createCompany)); +} + +export function createCompanyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateCompany$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateCompany' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/dataconnectionerror.ts b/sync-for-commerce/src/sdk/models/shared/dataconnectionerror.ts index a149caa68..b94a57444 100644 --- a/sync-for-commerce/src/sdk/models/shared/dataconnectionerror.ts +++ b/sync-for-commerce/src/sdk/models/shared/dataconnectionerror.ts @@ -1,16 +1,19 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ClosedEnum } from "../../types/enums.js"; import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The current status of a transient error. Null statuses indicate that the error is not transient. */ export const ErrorStatus = { - Active: "Active", - Resolved: "Resolved", + Active: "Active", + Resolved: "Resolved", } as const; /** * The current status of a transient error. Null statuses indicate that the error is not transient. @@ -18,127 +21,123 @@ export const ErrorStatus = { export type ErrorStatus = ClosedEnum; export type DataConnectionError = { - /** - * The HTTP status code returned by the source platform when the error occurred. - */ - statusCode?: string | undefined; - /** - * A non-numeric status code/text returned by the source platform when the error occurred. - */ - statusText?: string | undefined; - /** - * A message about a error returned by Codat. - */ - errorMessage?: string | undefined; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - erroredOnUtc?: string | undefined; - /** - * The current status of a transient error. Null statuses indicate that the error is not transient. - */ - status?: ErrorStatus | null | undefined; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - resolvedOnUtc?: string | undefined; + /** + * The HTTP status code returned by the source platform when the error occurred. + */ + statusCode?: string | undefined; + /** + * A non-numeric status code/text returned by the source platform when the error occurred. + */ + statusText?: string | undefined; + /** + * A message about a error returned by Codat. + */ + errorMessage?: string | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + erroredOnUtc?: string | undefined; + /** + * The current status of a transient error. Null statuses indicate that the error is not transient. + */ + status?: ErrorStatus | null | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + resolvedOnUtc?: string | undefined; }; /** @internal */ -export const ErrorStatus$inboundSchema: z.ZodNativeEnum = - z.nativeEnum(ErrorStatus); +export const ErrorStatus$inboundSchema: z.ZodNativeEnum = z + .nativeEnum(ErrorStatus); /** @internal */ export const ErrorStatus$outboundSchema: z.ZodNativeEnum = - ErrorStatus$inboundSchema; + ErrorStatus$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ErrorStatus$ { - /** @deprecated use `ErrorStatus$inboundSchema` instead. */ - export const inboundSchema = ErrorStatus$inboundSchema; - /** @deprecated use `ErrorStatus$outboundSchema` instead. */ - export const outboundSchema = ErrorStatus$outboundSchema; + /** @deprecated use `ErrorStatus$inboundSchema` instead. */ + export const inboundSchema = ErrorStatus$inboundSchema; + /** @deprecated use `ErrorStatus$outboundSchema` instead. */ + export const outboundSchema = ErrorStatus$outboundSchema; } /** @internal */ export const DataConnectionError$inboundSchema: z.ZodType< - DataConnectionError, - z.ZodTypeDef, - unknown + DataConnectionError, + z.ZodTypeDef, + unknown > = z.object({ - statusCode: z.string().optional(), - statusText: z.string().optional(), - errorMessage: z.string().optional(), - erroredOnUtc: z.string().optional(), - status: z.nullable(ErrorStatus$inboundSchema).optional(), - resolvedOnUtc: z.string().optional(), + statusCode: z.string().optional(), + statusText: z.string().optional(), + errorMessage: z.string().optional(), + erroredOnUtc: z.string().optional(), + status: z.nullable(ErrorStatus$inboundSchema).optional(), + resolvedOnUtc: z.string().optional(), }); /** @internal */ export type DataConnectionError$Outbound = { - statusCode?: string | undefined; - statusText?: string | undefined; - errorMessage?: string | undefined; - erroredOnUtc?: string | undefined; - status?: string | null | undefined; - resolvedOnUtc?: string | undefined; + statusCode?: string | undefined; + statusText?: string | undefined; + errorMessage?: string | undefined; + erroredOnUtc?: string | undefined; + status?: string | null | undefined; + resolvedOnUtc?: string | undefined; }; /** @internal */ export const DataConnectionError$outboundSchema: z.ZodType< - DataConnectionError$Outbound, - z.ZodTypeDef, - DataConnectionError + DataConnectionError$Outbound, + z.ZodTypeDef, + DataConnectionError > = z.object({ - statusCode: z.string().optional(), - statusText: z.string().optional(), - errorMessage: z.string().optional(), - erroredOnUtc: z.string().optional(), - status: z.nullable(ErrorStatus$outboundSchema).optional(), - resolvedOnUtc: z.string().optional(), + statusCode: z.string().optional(), + statusText: z.string().optional(), + errorMessage: z.string().optional(), + erroredOnUtc: z.string().optional(), + status: z.nullable(ErrorStatus$outboundSchema).optional(), + resolvedOnUtc: z.string().optional(), }); /** @@ -146,10 +145,28 @@ export const DataConnectionError$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace DataConnectionError$ { - /** @deprecated use `DataConnectionError$inboundSchema` instead. */ - export const inboundSchema = DataConnectionError$inboundSchema; - /** @deprecated use `DataConnectionError$outboundSchema` instead. */ - export const outboundSchema = DataConnectionError$outboundSchema; - /** @deprecated use `DataConnectionError$Outbound` instead. */ - export type Outbound = DataConnectionError$Outbound; + /** @deprecated use `DataConnectionError$inboundSchema` instead. */ + export const inboundSchema = DataConnectionError$inboundSchema; + /** @deprecated use `DataConnectionError$outboundSchema` instead. */ + export const outboundSchema = DataConnectionError$outboundSchema; + /** @deprecated use `DataConnectionError$Outbound` instead. */ + export type Outbound = DataConnectionError$Outbound; +} + +export function dataConnectionErrorToJSON( + dataConnectionError: DataConnectionError, +): string { + return JSON.stringify( + DataConnectionError$outboundSchema.parse(dataConnectionError), + ); +} + +export function dataConnectionErrorFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DataConnectionError$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DataConnectionError' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/dataconnectionstatus.ts b/sync-for-commerce/src/sdk/models/shared/dataconnectionstatus.ts index 6064509ba..d96ea52c0 100644 --- a/sync-for-commerce/src/sdk/models/shared/dataconnectionstatus.ts +++ b/sync-for-commerce/src/sdk/models/shared/dataconnectionstatus.ts @@ -1,18 +1,18 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ClosedEnum } from "../../types/enums.js"; import * as z from "zod"; +import { ClosedEnum } from "../../types/enums.js"; /** * The current authorization status of the data connection. */ export const DataConnectionStatus = { - PendingAuth: "PendingAuth", - Linked: "Linked", - Unlinked: "Unlinked", - Deauthorized: "Deauthorized", + PendingAuth: "PendingAuth", + Linked: "Linked", + Unlinked: "Unlinked", + Deauthorized: "Deauthorized", } as const; /** * The current authorization status of the data connection. @@ -20,20 +20,22 @@ export const DataConnectionStatus = { export type DataConnectionStatus = ClosedEnum; /** @internal */ -export const DataConnectionStatus$inboundSchema: z.ZodNativeEnum = - z.nativeEnum(DataConnectionStatus); +export const DataConnectionStatus$inboundSchema: z.ZodNativeEnum< + typeof DataConnectionStatus +> = z.nativeEnum(DataConnectionStatus); /** @internal */ -export const DataConnectionStatus$outboundSchema: z.ZodNativeEnum = - DataConnectionStatus$inboundSchema; +export const DataConnectionStatus$outboundSchema: z.ZodNativeEnum< + typeof DataConnectionStatus +> = DataConnectionStatus$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace DataConnectionStatus$ { - /** @deprecated use `DataConnectionStatus$inboundSchema` instead. */ - export const inboundSchema = DataConnectionStatus$inboundSchema; - /** @deprecated use `DataConnectionStatus$outboundSchema` instead. */ - export const outboundSchema = DataConnectionStatus$outboundSchema; + /** @deprecated use `DataConnectionStatus$inboundSchema` instead. */ + export const inboundSchema = DataConnectionStatus$inboundSchema; + /** @deprecated use `DataConnectionStatus$outboundSchema` instead. */ + export const outboundSchema = DataConnectionStatus$outboundSchema; } diff --git a/sync-for-commerce/src/sdk/models/shared/datatypefeature.ts b/sync-for-commerce/src/sdk/models/shared/datatypefeature.ts index 723c5a76a..9b8c3828a 100644 --- a/sync-for-commerce/src/sdk/models/shared/datatypefeature.ts +++ b/sync-for-commerce/src/sdk/models/shared/datatypefeature.ts @@ -1,63 +1,66 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - SupportedFeature, - SupportedFeature$inboundSchema, - SupportedFeature$Outbound, - SupportedFeature$outboundSchema, + SupportedFeature, + SupportedFeature$inboundSchema, + SupportedFeature$Outbound, + SupportedFeature$outboundSchema, } from "./supportedfeature.js"; -import * as z from "zod"; /** * Available data types */ export const DataTypes = { - AccountTransactions: "accountTransactions", - BalanceSheet: "balanceSheet", - BankAccounts: "bankAccounts", - BankTransactions: "bankTransactions", - BillCreditNotes: "billCreditNotes", - BillPayments: "billPayments", - Bills: "bills", - CashFlowStatement: "cashFlowStatement", - ChartOfAccounts: "chartOfAccounts", - Company: "company", - CreditNotes: "creditNotes", - Customers: "customers", - DirectCosts: "directCosts", - DirectIncomes: "directIncomes", - Invoices: "invoices", - ItemReceipts: "itemReceipts", - Items: "items", - JournalEntries: "journalEntries", - Journals: "journals", - PaymentMethods: "paymentMethods", - Payments: "payments", - ProfitAndLoss: "profitAndLoss", - PurchaseOrders: "purchaseOrders", - SalesOrders: "salesOrders", - Suppliers: "suppliers", - TaxRates: "taxRates", - TrackingCategories: "trackingCategories", - Transfers: "transfers", - BankingAccountBalances: "banking-accountBalances", - BankingAccounts: "banking-accounts", - BankingTransactionCategories: "banking-transactionCategories", - BankingTransactions: "banking-transactions", - CommerceCompanyInfo: "commerce-companyInfo", - CommerceCustomers: "commerce-customers", - CommerceDisputes: "commerce-disputes", - CommerceLocations: "commerce-locations", - CommerceOrders: "commerce-orders", - CommercePaymentMethods: "commerce-paymentMethods", - CommercePayments: "commerce-payments", - CommerceProductCategories: "commerce-productCategories", - CommerceProducts: "commerce-products", - CommerceTaxComponents: "commerce-taxComponents", - CommerceTransactions: "commerce-transactions", + AccountTransactions: "accountTransactions", + BalanceSheet: "balanceSheet", + BankAccounts: "bankAccounts", + BankTransactions: "bankTransactions", + BillCreditNotes: "billCreditNotes", + BillPayments: "billPayments", + Bills: "bills", + CashFlowStatement: "cashFlowStatement", + ChartOfAccounts: "chartOfAccounts", + Company: "company", + CreditNotes: "creditNotes", + Customers: "customers", + DirectCosts: "directCosts", + DirectIncomes: "directIncomes", + Invoices: "invoices", + ItemReceipts: "itemReceipts", + Items: "items", + JournalEntries: "journalEntries", + Journals: "journals", + PaymentMethods: "paymentMethods", + Payments: "payments", + ProfitAndLoss: "profitAndLoss", + PurchaseOrders: "purchaseOrders", + SalesOrders: "salesOrders", + Suppliers: "suppliers", + TaxRates: "taxRates", + TrackingCategories: "trackingCategories", + Transfers: "transfers", + BankingAccountBalances: "banking-accountBalances", + BankingAccounts: "banking-accounts", + BankingTransactionCategories: "banking-transactionCategories", + BankingTransactions: "banking-transactions", + CommerceCompanyInfo: "commerce-companyInfo", + CommerceCustomers: "commerce-customers", + CommerceDisputes: "commerce-disputes", + CommerceLocations: "commerce-locations", + CommerceOrders: "commerce-orders", + CommercePaymentMethods: "commerce-paymentMethods", + CommercePayments: "commerce-payments", + CommerceProductCategories: "commerce-productCategories", + CommerceProducts: "commerce-products", + CommerceTaxComponents: "commerce-taxComponents", + CommerceTransactions: "commerce-transactions", } as const; /** * Available data types @@ -68,51 +71,56 @@ export type DataTypes = ClosedEnum; * Describes support for a given datatype and associated operations */ export type DataTypeFeature = { - /** - * Available data types - */ - dataType?: DataTypes | undefined; - supportedFeatures: Array; + /** + * Available data types + */ + dataType?: DataTypes | undefined; + supportedFeatures: Array; }; /** @internal */ -export const DataTypes$inboundSchema: z.ZodNativeEnum = z.nativeEnum(DataTypes); +export const DataTypes$inboundSchema: z.ZodNativeEnum = z + .nativeEnum(DataTypes); /** @internal */ -export const DataTypes$outboundSchema: z.ZodNativeEnum = DataTypes$inboundSchema; +export const DataTypes$outboundSchema: z.ZodNativeEnum = + DataTypes$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace DataTypes$ { - /** @deprecated use `DataTypes$inboundSchema` instead. */ - export const inboundSchema = DataTypes$inboundSchema; - /** @deprecated use `DataTypes$outboundSchema` instead. */ - export const outboundSchema = DataTypes$outboundSchema; + /** @deprecated use `DataTypes$inboundSchema` instead. */ + export const inboundSchema = DataTypes$inboundSchema; + /** @deprecated use `DataTypes$outboundSchema` instead. */ + export const outboundSchema = DataTypes$outboundSchema; } /** @internal */ -export const DataTypeFeature$inboundSchema: z.ZodType = - z.object({ - dataType: DataTypes$inboundSchema.optional(), - supportedFeatures: z.array(SupportedFeature$inboundSchema), - }); +export const DataTypeFeature$inboundSchema: z.ZodType< + DataTypeFeature, + z.ZodTypeDef, + unknown +> = z.object({ + dataType: DataTypes$inboundSchema.optional(), + supportedFeatures: z.array(SupportedFeature$inboundSchema), +}); /** @internal */ export type DataTypeFeature$Outbound = { - dataType?: string | undefined; - supportedFeatures: Array; + dataType?: string | undefined; + supportedFeatures: Array; }; /** @internal */ export const DataTypeFeature$outboundSchema: z.ZodType< - DataTypeFeature$Outbound, - z.ZodTypeDef, - DataTypeFeature + DataTypeFeature$Outbound, + z.ZodTypeDef, + DataTypeFeature > = z.object({ - dataType: DataTypes$outboundSchema.optional(), - supportedFeatures: z.array(SupportedFeature$outboundSchema), + dataType: DataTypes$outboundSchema.optional(), + supportedFeatures: z.array(SupportedFeature$outboundSchema), }); /** @@ -120,10 +128,26 @@ export const DataTypeFeature$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace DataTypeFeature$ { - /** @deprecated use `DataTypeFeature$inboundSchema` instead. */ - export const inboundSchema = DataTypeFeature$inboundSchema; - /** @deprecated use `DataTypeFeature$outboundSchema` instead. */ - export const outboundSchema = DataTypeFeature$outboundSchema; - /** @deprecated use `DataTypeFeature$Outbound` instead. */ - export type Outbound = DataTypeFeature$Outbound; + /** @deprecated use `DataTypeFeature$inboundSchema` instead. */ + export const inboundSchema = DataTypeFeature$inboundSchema; + /** @deprecated use `DataTypeFeature$outboundSchema` instead. */ + export const outboundSchema = DataTypeFeature$outboundSchema; + /** @deprecated use `DataTypeFeature$Outbound` instead. */ + export type Outbound = DataTypeFeature$Outbound; +} + +export function dataTypeFeatureToJSON( + dataTypeFeature: DataTypeFeature, +): string { + return JSON.stringify(DataTypeFeature$outboundSchema.parse(dataTypeFeature)); +} + +export function dataTypeFeatureFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DataTypeFeature$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DataTypeFeature' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/errorvalidation.ts b/sync-for-commerce/src/sdk/models/shared/errorvalidation.ts index 345f721db..05433e305 100644 --- a/sync-for-commerce/src/sdk/models/shared/errorvalidation.ts +++ b/sync-for-commerce/src/sdk/models/shared/errorvalidation.ts @@ -1,44 +1,50 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - ErrorValidationItem, - ErrorValidationItem$inboundSchema, - ErrorValidationItem$Outbound, - ErrorValidationItem$outboundSchema, + ErrorValidationItem, + ErrorValidationItem$inboundSchema, + ErrorValidationItem$Outbound, + ErrorValidationItem$outboundSchema, } from "./errorvalidationitem.js"; -import * as z from "zod"; /** * A human-readable object describing validation decisions Codat has made. If an operation has failed because of validation errors, they will be detailed here. */ export type ErrorValidation = { - errors?: Array | null | undefined; - warnings?: Array | null | undefined; + errors?: Array | null | undefined; + warnings?: Array | null | undefined; }; /** @internal */ -export const ErrorValidation$inboundSchema: z.ZodType = - z.object({ - errors: z.nullable(z.array(ErrorValidationItem$inboundSchema)).optional(), - warnings: z.nullable(z.array(ErrorValidationItem$inboundSchema)).optional(), - }); +export const ErrorValidation$inboundSchema: z.ZodType< + ErrorValidation, + z.ZodTypeDef, + unknown +> = z.object({ + errors: z.nullable(z.array(ErrorValidationItem$inboundSchema)).optional(), + warnings: z.nullable(z.array(ErrorValidationItem$inboundSchema)).optional(), +}); /** @internal */ export type ErrorValidation$Outbound = { - errors?: Array | null | undefined; - warnings?: Array | null | undefined; + errors?: Array | null | undefined; + warnings?: Array | null | undefined; }; /** @internal */ export const ErrorValidation$outboundSchema: z.ZodType< - ErrorValidation$Outbound, - z.ZodTypeDef, - ErrorValidation + ErrorValidation$Outbound, + z.ZodTypeDef, + ErrorValidation > = z.object({ - errors: z.nullable(z.array(ErrorValidationItem$outboundSchema)).optional(), - warnings: z.nullable(z.array(ErrorValidationItem$outboundSchema)).optional(), + errors: z.nullable(z.array(ErrorValidationItem$outboundSchema)).optional(), + warnings: z.nullable(z.array(ErrorValidationItem$outboundSchema)).optional(), }); /** @@ -46,10 +52,26 @@ export const ErrorValidation$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ErrorValidation$ { - /** @deprecated use `ErrorValidation$inboundSchema` instead. */ - export const inboundSchema = ErrorValidation$inboundSchema; - /** @deprecated use `ErrorValidation$outboundSchema` instead. */ - export const outboundSchema = ErrorValidation$outboundSchema; - /** @deprecated use `ErrorValidation$Outbound` instead. */ - export type Outbound = ErrorValidation$Outbound; + /** @deprecated use `ErrorValidation$inboundSchema` instead. */ + export const inboundSchema = ErrorValidation$inboundSchema; + /** @deprecated use `ErrorValidation$outboundSchema` instead. */ + export const outboundSchema = ErrorValidation$outboundSchema; + /** @deprecated use `ErrorValidation$Outbound` instead. */ + export type Outbound = ErrorValidation$Outbound; +} + +export function errorValidationToJSON( + errorValidation: ErrorValidation, +): string { + return JSON.stringify(ErrorValidation$outboundSchema.parse(errorValidation)); +} + +export function errorValidationFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ErrorValidation$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ErrorValidation' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/errorvalidationitem.ts b/sync-for-commerce/src/sdk/models/shared/errorvalidationitem.ts index 3dc4f80b9..786bbcb33 100644 --- a/sync-for-commerce/src/sdk/models/shared/errorvalidationitem.ts +++ b/sync-for-commerce/src/sdk/models/shared/errorvalidationitem.ts @@ -1,51 +1,54 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ErrorValidationItem = { - /** - * Unique identifier for a validation item. - */ - itemId?: string | null | undefined; - /** - * A message outlining validation item's issue. - */ - message?: string | null | undefined; - /** - * Name of validator. - */ - validatorName?: string | null | undefined; + /** + * Unique identifier for a validation item. + */ + itemId?: string | null | undefined; + /** + * A message outlining validation item's issue. + */ + message?: string | null | undefined; + /** + * Name of validator. + */ + validatorName?: string | null | undefined; }; /** @internal */ export const ErrorValidationItem$inboundSchema: z.ZodType< - ErrorValidationItem, - z.ZodTypeDef, - unknown + ErrorValidationItem, + z.ZodTypeDef, + unknown > = z.object({ - itemId: z.nullable(z.string()).optional(), - message: z.nullable(z.string()).optional(), - validatorName: z.nullable(z.string()).optional(), + itemId: z.nullable(z.string()).optional(), + message: z.nullable(z.string()).optional(), + validatorName: z.nullable(z.string()).optional(), }); /** @internal */ export type ErrorValidationItem$Outbound = { - itemId?: string | null | undefined; - message?: string | null | undefined; - validatorName?: string | null | undefined; + itemId?: string | null | undefined; + message?: string | null | undefined; + validatorName?: string | null | undefined; }; /** @internal */ export const ErrorValidationItem$outboundSchema: z.ZodType< - ErrorValidationItem$Outbound, - z.ZodTypeDef, - ErrorValidationItem + ErrorValidationItem$Outbound, + z.ZodTypeDef, + ErrorValidationItem > = z.object({ - itemId: z.nullable(z.string()).optional(), - message: z.nullable(z.string()).optional(), - validatorName: z.nullable(z.string()).optional(), + itemId: z.nullable(z.string()).optional(), + message: z.nullable(z.string()).optional(), + validatorName: z.nullable(z.string()).optional(), }); /** @@ -53,10 +56,28 @@ export const ErrorValidationItem$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ErrorValidationItem$ { - /** @deprecated use `ErrorValidationItem$inboundSchema` instead. */ - export const inboundSchema = ErrorValidationItem$inboundSchema; - /** @deprecated use `ErrorValidationItem$outboundSchema` instead. */ - export const outboundSchema = ErrorValidationItem$outboundSchema; - /** @deprecated use `ErrorValidationItem$Outbound` instead. */ - export type Outbound = ErrorValidationItem$Outbound; + /** @deprecated use `ErrorValidationItem$inboundSchema` instead. */ + export const inboundSchema = ErrorValidationItem$inboundSchema; + /** @deprecated use `ErrorValidationItem$outboundSchema` instead. */ + export const outboundSchema = ErrorValidationItem$outboundSchema; + /** @deprecated use `ErrorValidationItem$Outbound` instead. */ + export type Outbound = ErrorValidationItem$Outbound; +} + +export function errorValidationItemToJSON( + errorValidationItem: ErrorValidationItem, +): string { + return JSON.stringify( + ErrorValidationItem$outboundSchema.parse(errorValidationItem), + ); +} + +export function errorValidationItemFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ErrorValidationItem$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ErrorValidationItem' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/featurestate.ts b/sync-for-commerce/src/sdk/models/shared/featurestate.ts index 426279f73..ecbe89310 100644 --- a/sync-for-commerce/src/sdk/models/shared/featurestate.ts +++ b/sync-for-commerce/src/sdk/models/shared/featurestate.ts @@ -1,20 +1,20 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ClosedEnum } from "../../types/enums.js"; import * as z from "zod"; +import { ClosedEnum } from "../../types/enums.js"; /** * The current release state of the feature. */ export const FeatureState = { - Release: "Release", - Alpha: "Alpha", - Beta: "Beta", - Deprecated: "Deprecated", - NotSupported: "NotSupported", - NotImplemented: "NotImplemented", + Release: "Release", + Alpha: "Alpha", + Beta: "Beta", + Deprecated: "Deprecated", + NotSupported: "NotSupported", + NotImplemented: "NotImplemented", } as const; /** * The current release state of the feature. @@ -23,19 +23,19 @@ export type FeatureState = ClosedEnum; /** @internal */ export const FeatureState$inboundSchema: z.ZodNativeEnum = - z.nativeEnum(FeatureState); + z.nativeEnum(FeatureState); /** @internal */ export const FeatureState$outboundSchema: z.ZodNativeEnum = - FeatureState$inboundSchema; + FeatureState$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace FeatureState$ { - /** @deprecated use `FeatureState$inboundSchema` instead. */ - export const inboundSchema = FeatureState$inboundSchema; - /** @deprecated use `FeatureState$outboundSchema` instead. */ - export const outboundSchema = FeatureState$outboundSchema; + /** @deprecated use `FeatureState$inboundSchema` instead. */ + export const inboundSchema = FeatureState$inboundSchema; + /** @deprecated use `FeatureState$outboundSchema` instead. */ + export const outboundSchema = FeatureState$outboundSchema; } diff --git a/sync-for-commerce/src/sdk/models/shared/featuretype.ts b/sync-for-commerce/src/sdk/models/shared/featuretype.ts index 44ce8fa54..e3bcf473e 100644 --- a/sync-for-commerce/src/sdk/models/shared/featuretype.ts +++ b/sync-for-commerce/src/sdk/models/shared/featuretype.ts @@ -1,24 +1,24 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ClosedEnum } from "../../types/enums.js"; import * as z from "zod"; +import { ClosedEnum } from "../../types/enums.js"; /** * The type of feature. */ export const FeatureType = { - Get: "Get", - Post: "Post", - Categorization: "Categorization", - Delete: "Delete", - Put: "Put", - GetAsPdf: "GetAsPdf", - DownloadAttachment: "DownloadAttachment", - GetAttachment: "GetAttachment", - GetAttachments: "GetAttachments", - UploadAttachment: "UploadAttachment", + Get: "Get", + Post: "Post", + Categorization: "Categorization", + Delete: "Delete", + Put: "Put", + GetAsPdf: "GetAsPdf", + DownloadAttachment: "DownloadAttachment", + GetAttachment: "GetAttachment", + GetAttachments: "GetAttachments", + UploadAttachment: "UploadAttachment", } as const; /** * The type of feature. @@ -26,20 +26,20 @@ export const FeatureType = { export type FeatureType = ClosedEnum; /** @internal */ -export const FeatureType$inboundSchema: z.ZodNativeEnum = - z.nativeEnum(FeatureType); +export const FeatureType$inboundSchema: z.ZodNativeEnum = z + .nativeEnum(FeatureType); /** @internal */ export const FeatureType$outboundSchema: z.ZodNativeEnum = - FeatureType$inboundSchema; + FeatureType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace FeatureType$ { - /** @deprecated use `FeatureType$inboundSchema` instead. */ - export const inboundSchema = FeatureType$inboundSchema; - /** @deprecated use `FeatureType$outboundSchema` instead. */ - export const outboundSchema = FeatureType$outboundSchema; + /** @deprecated use `FeatureType$inboundSchema` instead. */ + export const inboundSchema = FeatureType$inboundSchema; + /** @deprecated use `FeatureType$outboundSchema` instead. */ + export const outboundSchema = FeatureType$outboundSchema; } diff --git a/sync-for-commerce/src/sdk/models/shared/feesconfiguration.ts b/sync-for-commerce/src/sdk/models/shared/feesconfiguration.ts index 8e126f04c..efb151e6f 100644 --- a/sync-for-commerce/src/sdk/models/shared/feesconfiguration.ts +++ b/sync-for-commerce/src/sdk/models/shared/feesconfiguration.ts @@ -1,54 +1,61 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - AccountConfiguration, - AccountConfiguration$inboundSchema, - AccountConfiguration$Outbound, - AccountConfiguration$outboundSchema, + AccountConfiguration, + AccountConfiguration$inboundSchema, + AccountConfiguration$Outbound, + AccountConfiguration$outboundSchema, } from "./accountconfiguration.js"; import { - FeesSupplier, - FeesSupplier$inboundSchema, - FeesSupplier$Outbound, - FeesSupplier$outboundSchema, + FeesSupplier, + FeesSupplier$inboundSchema, + FeesSupplier$Outbound, + FeesSupplier$outboundSchema, } from "./feessupplier.js"; -import * as z from "zod"; export type FeesConfiguration = { - feesSupplier?: FeesSupplier | undefined; - /** - * Boolean indicator to enable syncing fees. - */ - syncFees?: boolean | undefined; - accounts?: { [k: string]: AccountConfiguration } | null | undefined; + feesSupplier?: FeesSupplier | undefined; + /** + * Boolean indicator to enable syncing fees. + */ + syncFees?: boolean | undefined; + accounts?: { [k: string]: AccountConfiguration } | null | undefined; }; /** @internal */ -export const FeesConfiguration$inboundSchema: z.ZodType = - z.object({ - feesSupplier: FeesSupplier$inboundSchema.optional(), - syncFees: z.boolean().optional(), - accounts: z.nullable(z.record(AccountConfiguration$inboundSchema)).optional(), - }); +export const FeesConfiguration$inboundSchema: z.ZodType< + FeesConfiguration, + z.ZodTypeDef, + unknown +> = z.object({ + feesSupplier: FeesSupplier$inboundSchema.optional(), + syncFees: z.boolean().optional(), + accounts: z.nullable(z.record(AccountConfiguration$inboundSchema)).optional(), +}); /** @internal */ export type FeesConfiguration$Outbound = { - feesSupplier?: FeesSupplier$Outbound | undefined; - syncFees?: boolean | undefined; - accounts?: { [k: string]: AccountConfiguration$Outbound } | null | undefined; + feesSupplier?: FeesSupplier$Outbound | undefined; + syncFees?: boolean | undefined; + accounts?: { [k: string]: AccountConfiguration$Outbound } | null | undefined; }; /** @internal */ export const FeesConfiguration$outboundSchema: z.ZodType< - FeesConfiguration$Outbound, - z.ZodTypeDef, - FeesConfiguration + FeesConfiguration$Outbound, + z.ZodTypeDef, + FeesConfiguration > = z.object({ - feesSupplier: FeesSupplier$outboundSchema.optional(), - syncFees: z.boolean().optional(), - accounts: z.nullable(z.record(AccountConfiguration$outboundSchema)).optional(), + feesSupplier: FeesSupplier$outboundSchema.optional(), + syncFees: z.boolean().optional(), + accounts: z.nullable(z.record(AccountConfiguration$outboundSchema)) + .optional(), }); /** @@ -56,10 +63,28 @@ export const FeesConfiguration$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace FeesConfiguration$ { - /** @deprecated use `FeesConfiguration$inboundSchema` instead. */ - export const inboundSchema = FeesConfiguration$inboundSchema; - /** @deprecated use `FeesConfiguration$outboundSchema` instead. */ - export const outboundSchema = FeesConfiguration$outboundSchema; - /** @deprecated use `FeesConfiguration$Outbound` instead. */ - export type Outbound = FeesConfiguration$Outbound; + /** @deprecated use `FeesConfiguration$inboundSchema` instead. */ + export const inboundSchema = FeesConfiguration$inboundSchema; + /** @deprecated use `FeesConfiguration$outboundSchema` instead. */ + export const outboundSchema = FeesConfiguration$outboundSchema; + /** @deprecated use `FeesConfiguration$Outbound` instead. */ + export type Outbound = FeesConfiguration$Outbound; +} + +export function feesConfigurationToJSON( + feesConfiguration: FeesConfiguration, +): string { + return JSON.stringify( + FeesConfiguration$outboundSchema.parse(feesConfiguration), + ); +} + +export function feesConfigurationFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FeesConfiguration$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FeesConfiguration' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/feessupplier.ts b/sync-for-commerce/src/sdk/models/shared/feessupplier.ts index 27dacaad9..550e7f6e6 100644 --- a/sync-for-commerce/src/sdk/models/shared/feessupplier.ts +++ b/sync-for-commerce/src/sdk/models/shared/feessupplier.ts @@ -1,46 +1,55 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - ConfigurationOption, - ConfigurationOption$inboundSchema, - ConfigurationOption$Outbound, - ConfigurationOption$outboundSchema, + ConfigurationOption, + ConfigurationOption$inboundSchema, + ConfigurationOption$Outbound, + ConfigurationOption$outboundSchema, } from "./configurationoption.js"; -import * as z from "zod"; export type FeesSupplier = { - /** - * Selected supplier id from the list of supplier records on the accounting software. - */ - selectedSupplierId?: string | null | undefined; - /** - * List of supplier options from the list of supplier records on the accounting software. - */ - supplierOptions?: Array | null | undefined; + /** + * Selected supplier id from the list of supplier records on the accounting software. + */ + selectedSupplierId?: string | null | undefined; + /** + * List of supplier options from the list of supplier records on the accounting software. + */ + supplierOptions?: Array | null | undefined; }; /** @internal */ -export const FeesSupplier$inboundSchema: z.ZodType = z.object({ - selectedSupplierId: z.nullable(z.string()).optional(), - supplierOptions: z.nullable(z.array(ConfigurationOption$inboundSchema)).optional(), +export const FeesSupplier$inboundSchema: z.ZodType< + FeesSupplier, + z.ZodTypeDef, + unknown +> = z.object({ + selectedSupplierId: z.nullable(z.string()).optional(), + supplierOptions: z.nullable(z.array(ConfigurationOption$inboundSchema)) + .optional(), }); /** @internal */ export type FeesSupplier$Outbound = { - selectedSupplierId?: string | null | undefined; - supplierOptions?: Array | null | undefined; + selectedSupplierId?: string | null | undefined; + supplierOptions?: Array | null | undefined; }; /** @internal */ export const FeesSupplier$outboundSchema: z.ZodType< - FeesSupplier$Outbound, - z.ZodTypeDef, - FeesSupplier + FeesSupplier$Outbound, + z.ZodTypeDef, + FeesSupplier > = z.object({ - selectedSupplierId: z.nullable(z.string()).optional(), - supplierOptions: z.nullable(z.array(ConfigurationOption$outboundSchema)).optional(), + selectedSupplierId: z.nullable(z.string()).optional(), + supplierOptions: z.nullable(z.array(ConfigurationOption$outboundSchema)) + .optional(), }); /** @@ -48,10 +57,24 @@ export const FeesSupplier$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace FeesSupplier$ { - /** @deprecated use `FeesSupplier$inboundSchema` instead. */ - export const inboundSchema = FeesSupplier$inboundSchema; - /** @deprecated use `FeesSupplier$outboundSchema` instead. */ - export const outboundSchema = FeesSupplier$outboundSchema; - /** @deprecated use `FeesSupplier$Outbound` instead. */ - export type Outbound = FeesSupplier$Outbound; + /** @deprecated use `FeesSupplier$inboundSchema` instead. */ + export const inboundSchema = FeesSupplier$inboundSchema; + /** @deprecated use `FeesSupplier$outboundSchema` instead. */ + export const outboundSchema = FeesSupplier$outboundSchema; + /** @deprecated use `FeesSupplier$Outbound` instead. */ + export type Outbound = FeesSupplier$Outbound; +} + +export function feesSupplierToJSON(feesSupplier: FeesSupplier): string { + return JSON.stringify(FeesSupplier$outboundSchema.parse(feesSupplier)); +} + +export function feesSupplierFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FeesSupplier$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FeesSupplier' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/grouping.ts b/sync-for-commerce/src/sdk/models/shared/grouping.ts index 840e8e255..6900cc349 100644 --- a/sync-for-commerce/src/sdk/models/shared/grouping.ts +++ b/sync-for-commerce/src/sdk/models/shared/grouping.ts @@ -1,54 +1,78 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - GroupingLevels, - GroupingLevels$inboundSchema, - GroupingLevels$Outbound, - GroupingLevels$outboundSchema, + GroupingLevels, + GroupingLevels$inboundSchema, + GroupingLevels$Outbound, + GroupingLevels$outboundSchema, } from "./groupinglevels.js"; import { - GroupingPeriod, - GroupingPeriod$inboundSchema, - GroupingPeriod$Outbound, - GroupingPeriod$outboundSchema, + GroupingPeriod, + GroupingPeriod$inboundSchema, + GroupingPeriod$Outbound, + GroupingPeriod$outboundSchema, } from "./groupingperiod.js"; -import * as z from "zod"; export type Grouping = { - groupingPeriod?: GroupingPeriod | undefined; - groupingLevels?: GroupingLevels | undefined; + groupingPeriod?: GroupingPeriod | undefined; + groupingLevels?: GroupingLevels | undefined; }; /** @internal */ -export const Grouping$inboundSchema: z.ZodType = z.object({ - groupingPeriod: GroupingPeriod$inboundSchema.optional(), - groupingLevels: GroupingLevels$inboundSchema.optional(), +export const Grouping$inboundSchema: z.ZodType< + Grouping, + z.ZodTypeDef, + unknown +> = z.object({ + groupingPeriod: GroupingPeriod$inboundSchema.optional(), + groupingLevels: GroupingLevels$inboundSchema.optional(), }); /** @internal */ export type Grouping$Outbound = { - groupingPeriod?: GroupingPeriod$Outbound | undefined; - groupingLevels?: GroupingLevels$Outbound | undefined; + groupingPeriod?: GroupingPeriod$Outbound | undefined; + groupingLevels?: GroupingLevels$Outbound | undefined; }; /** @internal */ -export const Grouping$outboundSchema: z.ZodType = - z.object({ - groupingPeriod: GroupingPeriod$outboundSchema.optional(), - groupingLevels: GroupingLevels$outboundSchema.optional(), - }); +export const Grouping$outboundSchema: z.ZodType< + Grouping$Outbound, + z.ZodTypeDef, + Grouping +> = z.object({ + groupingPeriod: GroupingPeriod$outboundSchema.optional(), + groupingLevels: GroupingLevels$outboundSchema.optional(), +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Grouping$ { - /** @deprecated use `Grouping$inboundSchema` instead. */ - export const inboundSchema = Grouping$inboundSchema; - /** @deprecated use `Grouping$outboundSchema` instead. */ - export const outboundSchema = Grouping$outboundSchema; - /** @deprecated use `Grouping$Outbound` instead. */ - export type Outbound = Grouping$Outbound; + /** @deprecated use `Grouping$inboundSchema` instead. */ + export const inboundSchema = Grouping$inboundSchema; + /** @deprecated use `Grouping$outboundSchema` instead. */ + export const outboundSchema = Grouping$outboundSchema; + /** @deprecated use `Grouping$Outbound` instead. */ + export type Outbound = Grouping$Outbound; +} + +export function groupingToJSON(grouping: Grouping): string { + return JSON.stringify(Grouping$outboundSchema.parse(grouping)); +} + +export function groupingFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Grouping$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Grouping' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/groupinglevels.ts b/sync-for-commerce/src/sdk/models/shared/groupinglevels.ts index 6b79dba2f..687c6b2f7 100644 --- a/sync-for-commerce/src/sdk/models/shared/groupinglevels.ts +++ b/sync-for-commerce/src/sdk/models/shared/groupinglevels.ts @@ -1,47 +1,53 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - InvoiceLevelSelection, - InvoiceLevelSelection$inboundSchema, - InvoiceLevelSelection$Outbound, - InvoiceLevelSelection$outboundSchema, + InvoiceLevelSelection, + InvoiceLevelSelection$inboundSchema, + InvoiceLevelSelection$Outbound, + InvoiceLevelSelection$outboundSchema, } from "./invoicelevelselection.js"; import { - InvoiceLineLevelSelection, - InvoiceLineLevelSelection$inboundSchema, - InvoiceLineLevelSelection$Outbound, - InvoiceLineLevelSelection$outboundSchema, + InvoiceLineLevelSelection, + InvoiceLineLevelSelection$inboundSchema, + InvoiceLineLevelSelection$Outbound, + InvoiceLineLevelSelection$outboundSchema, } from "./invoicelinelevelselection.js"; -import * as z from "zod"; export type GroupingLevels = { - invoiceLevel?: InvoiceLevelSelection | undefined; - invoiceLineLevel?: InvoiceLineLevelSelection | undefined; + invoiceLevel?: InvoiceLevelSelection | undefined; + invoiceLineLevel?: InvoiceLineLevelSelection | undefined; }; /** @internal */ -export const GroupingLevels$inboundSchema: z.ZodType = - z.object({ - invoiceLevel: InvoiceLevelSelection$inboundSchema.optional(), - invoiceLineLevel: InvoiceLineLevelSelection$inboundSchema.optional(), - }); +export const GroupingLevels$inboundSchema: z.ZodType< + GroupingLevels, + z.ZodTypeDef, + unknown +> = z.object({ + invoiceLevel: InvoiceLevelSelection$inboundSchema.optional(), + invoiceLineLevel: InvoiceLineLevelSelection$inboundSchema.optional(), +}); /** @internal */ export type GroupingLevels$Outbound = { - invoiceLevel?: InvoiceLevelSelection$Outbound | undefined; - invoiceLineLevel?: InvoiceLineLevelSelection$Outbound | undefined; + invoiceLevel?: InvoiceLevelSelection$Outbound | undefined; + invoiceLineLevel?: InvoiceLineLevelSelection$Outbound | undefined; }; /** @internal */ export const GroupingLevels$outboundSchema: z.ZodType< - GroupingLevels$Outbound, - z.ZodTypeDef, - GroupingLevels + GroupingLevels$Outbound, + z.ZodTypeDef, + GroupingLevels > = z.object({ - invoiceLevel: InvoiceLevelSelection$outboundSchema.optional(), - invoiceLineLevel: InvoiceLineLevelSelection$outboundSchema.optional(), + invoiceLevel: InvoiceLevelSelection$outboundSchema.optional(), + invoiceLineLevel: InvoiceLineLevelSelection$outboundSchema.optional(), }); /** @@ -49,10 +55,24 @@ export const GroupingLevels$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GroupingLevels$ { - /** @deprecated use `GroupingLevels$inboundSchema` instead. */ - export const inboundSchema = GroupingLevels$inboundSchema; - /** @deprecated use `GroupingLevels$outboundSchema` instead. */ - export const outboundSchema = GroupingLevels$outboundSchema; - /** @deprecated use `GroupingLevels$Outbound` instead. */ - export type Outbound = GroupingLevels$Outbound; + /** @deprecated use `GroupingLevels$inboundSchema` instead. */ + export const inboundSchema = GroupingLevels$inboundSchema; + /** @deprecated use `GroupingLevels$outboundSchema` instead. */ + export const outboundSchema = GroupingLevels$outboundSchema; + /** @deprecated use `GroupingLevels$Outbound` instead. */ + export type Outbound = GroupingLevels$Outbound; +} + +export function groupingLevelsToJSON(groupingLevels: GroupingLevels): string { + return JSON.stringify(GroupingLevels$outboundSchema.parse(groupingLevels)); +} + +export function groupingLevelsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GroupingLevels$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GroupingLevels' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/groupingperiod.ts b/sync-for-commerce/src/sdk/models/shared/groupingperiod.ts index 97117634e..16ca2a61b 100644 --- a/sync-for-commerce/src/sdk/models/shared/groupingperiod.ts +++ b/sync-for-commerce/src/sdk/models/shared/groupingperiod.ts @@ -1,41 +1,47 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GroupingPeriod = { - /** - * Grouping period i.e. Daily sales. - */ - selectedGroupingPeriod?: string | null | undefined; - /** - * Array of grouping period options. - */ - groupingPeriodOptions?: Array | null | undefined; + /** + * Grouping period i.e. Daily sales. + */ + selectedGroupingPeriod?: string | null | undefined; + /** + * Array of grouping period options. + */ + groupingPeriodOptions?: Array | null | undefined; }; /** @internal */ -export const GroupingPeriod$inboundSchema: z.ZodType = - z.object({ - selectedGroupingPeriod: z.nullable(z.string()).optional(), - groupingPeriodOptions: z.nullable(z.array(z.string())).optional(), - }); +export const GroupingPeriod$inboundSchema: z.ZodType< + GroupingPeriod, + z.ZodTypeDef, + unknown +> = z.object({ + selectedGroupingPeriod: z.nullable(z.string()).optional(), + groupingPeriodOptions: z.nullable(z.array(z.string())).optional(), +}); /** @internal */ export type GroupingPeriod$Outbound = { - selectedGroupingPeriod?: string | null | undefined; - groupingPeriodOptions?: Array | null | undefined; + selectedGroupingPeriod?: string | null | undefined; + groupingPeriodOptions?: Array | null | undefined; }; /** @internal */ export const GroupingPeriod$outboundSchema: z.ZodType< - GroupingPeriod$Outbound, - z.ZodTypeDef, - GroupingPeriod + GroupingPeriod$Outbound, + z.ZodTypeDef, + GroupingPeriod > = z.object({ - selectedGroupingPeriod: z.nullable(z.string()).optional(), - groupingPeriodOptions: z.nullable(z.array(z.string())).optional(), + selectedGroupingPeriod: z.nullable(z.string()).optional(), + groupingPeriodOptions: z.nullable(z.array(z.string())).optional(), }); /** @@ -43,10 +49,24 @@ export const GroupingPeriod$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GroupingPeriod$ { - /** @deprecated use `GroupingPeriod$inboundSchema` instead. */ - export const inboundSchema = GroupingPeriod$inboundSchema; - /** @deprecated use `GroupingPeriod$outboundSchema` instead. */ - export const outboundSchema = GroupingPeriod$outboundSchema; - /** @deprecated use `GroupingPeriod$Outbound` instead. */ - export type Outbound = GroupingPeriod$Outbound; + /** @deprecated use `GroupingPeriod$inboundSchema` instead. */ + export const inboundSchema = GroupingPeriod$inboundSchema; + /** @deprecated use `GroupingPeriod$outboundSchema` instead. */ + export const outboundSchema = GroupingPeriod$outboundSchema; + /** @deprecated use `GroupingPeriod$Outbound` instead. */ + export type Outbound = GroupingPeriod$Outbound; +} + +export function groupingPeriodToJSON(groupingPeriod: GroupingPeriod): string { + return JSON.stringify(GroupingPeriod$outboundSchema.parse(groupingPeriod)); +} + +export function groupingPeriodFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GroupingPeriod$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GroupingPeriod' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/halref.ts b/sync-for-commerce/src/sdk/models/shared/halref.ts index 47f965cce..30ac29e93 100644 --- a/sync-for-commerce/src/sdk/models/shared/halref.ts +++ b/sync-for-commerce/src/sdk/models/shared/halref.ts @@ -1,29 +1,37 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type HalRef = { - /** - * Uri hypertext reference. - */ - href?: string | undefined; + /** + * Uri hypertext reference. + */ + href?: string | undefined; }; /** @internal */ -export const HalRef$inboundSchema: z.ZodType = z.object({ +export const HalRef$inboundSchema: z.ZodType = z + .object({ href: z.string().optional(), -}); + }); /** @internal */ export type HalRef$Outbound = { - href?: string | undefined; + href?: string | undefined; }; /** @internal */ -export const HalRef$outboundSchema: z.ZodType = z.object({ - href: z.string().optional(), +export const HalRef$outboundSchema: z.ZodType< + HalRef$Outbound, + z.ZodTypeDef, + HalRef +> = z.object({ + href: z.string().optional(), }); /** @@ -31,10 +39,24 @@ export const HalRef$outboundSchema: z.ZodType { + return safeParse( + jsonString, + (x) => HalRef$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'HalRef' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/imagereference.ts b/sync-for-commerce/src/sdk/models/shared/imagereference.ts index 2ba8c59f3..90d7db017 100644 --- a/sync-for-commerce/src/sdk/models/shared/imagereference.ts +++ b/sync-for-commerce/src/sdk/models/shared/imagereference.ts @@ -1,44 +1,50 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Image reference. */ export type ImageReference = { - /** - * Source URL for image. - */ - src?: string | undefined; - /** - * Alternative text when image is not available. - */ - alt?: string | undefined; + /** + * Source URL for image. + */ + src?: string | undefined; + /** + * Alternative text when image is not available. + */ + alt?: string | undefined; }; /** @internal */ -export const ImageReference$inboundSchema: z.ZodType = - z.object({ - src: z.string().optional(), - alt: z.string().optional(), - }); +export const ImageReference$inboundSchema: z.ZodType< + ImageReference, + z.ZodTypeDef, + unknown +> = z.object({ + src: z.string().optional(), + alt: z.string().optional(), +}); /** @internal */ export type ImageReference$Outbound = { - src?: string | undefined; - alt?: string | undefined; + src?: string | undefined; + alt?: string | undefined; }; /** @internal */ export const ImageReference$outboundSchema: z.ZodType< - ImageReference$Outbound, - z.ZodTypeDef, - ImageReference + ImageReference$Outbound, + z.ZodTypeDef, + ImageReference > = z.object({ - src: z.string().optional(), - alt: z.string().optional(), + src: z.string().optional(), + alt: z.string().optional(), }); /** @@ -46,10 +52,24 @@ export const ImageReference$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ImageReference$ { - /** @deprecated use `ImageReference$inboundSchema` instead. */ - export const inboundSchema = ImageReference$inboundSchema; - /** @deprecated use `ImageReference$outboundSchema` instead. */ - export const outboundSchema = ImageReference$outboundSchema; - /** @deprecated use `ImageReference$Outbound` instead. */ - export type Outbound = ImageReference$Outbound; + /** @deprecated use `ImageReference$inboundSchema` instead. */ + export const inboundSchema = ImageReference$inboundSchema; + /** @deprecated use `ImageReference$outboundSchema` instead. */ + export const outboundSchema = ImageReference$outboundSchema; + /** @deprecated use `ImageReference$Outbound` instead. */ + export type Outbound = ImageReference$Outbound; +} + +export function imageReferenceToJSON(imageReference: ImageReference): string { + return JSON.stringify(ImageReference$outboundSchema.parse(imageReference)); +} + +export function imageReferenceFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ImageReference$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ImageReference' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/index.ts b/sync-for-commerce/src/sdk/models/shared/index.ts index b9eac68a0..d7683e8ba 100644 --- a/sync-for-commerce/src/sdk/models/shared/index.ts +++ b/sync-for-commerce/src/sdk/models/shared/index.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export * from "./accountconfiguration.js"; @@ -11,12 +11,15 @@ export * from "./brandinglogo.js"; export * from "./commerceconfiguration.js"; export * from "./companies.js"; export * from "./company.js"; +export * from "./companyreference.js"; export * from "./companysyncstatus.js"; export * from "./configuration.js"; export * from "./configurationmapsettings.js"; export * from "./configurationoption.js"; export * from "./connection.js"; export * from "./connections.js"; +export * from "./connectionwebhook.js"; +export * from "./connectionwebhookpayload.js"; export * from "./createcompany.js"; export * from "./dataconnectionerror.js"; export * from "./dataconnectionstatus.js"; @@ -37,7 +40,6 @@ export * from "./integrations.js"; export * from "./invoicelevelselection.js"; export * from "./invoicelinelevelselection.js"; export * from "./invoicestatus.js"; -export * from "./items.js"; export * from "./links.js"; export * from "./locale.js"; export * from "./localization.js"; diff --git a/sync-for-commerce/src/sdk/models/shared/integration.ts b/sync-for-commerce/src/sdk/models/shared/integration.ts index 09181ef57..1cdbbb1e7 100644 --- a/sync-for-commerce/src/sdk/models/shared/integration.ts +++ b/sync-for-commerce/src/sdk/models/shared/integration.ts @@ -1,110 +1,121 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - DataTypeFeature, - DataTypeFeature$inboundSchema, - DataTypeFeature$Outbound, - DataTypeFeature$outboundSchema, + DataTypeFeature, + DataTypeFeature$inboundSchema, + DataTypeFeature$Outbound, + DataTypeFeature$outboundSchema, } from "./datatypefeature.js"; -import { SourceType, SourceType$inboundSchema, SourceType$outboundSchema } from "./sourcetype.js"; -import * as z from "zod"; +import { + SourceType, + SourceType$inboundSchema, + SourceType$outboundSchema, +} from "./sourcetype.js"; /** * An integration that Codat supports */ export type Integration = { - /** - * A unique 4-letter key to represent a platform in each integration. View [accounting](https://docs.codat.io/integrations/accounting/overview#platform-keys), [banking](https://docs.codat.io/integrations/banking/overview#platform-keys), and [commerce](https://docs.codat.io/integrations/commerce/overview#platform-keys) platform keys. - */ - key: string; - /** - * Static url for integration's logo. - */ - logoUrl: string; - /** - * Name of integration. - */ - name: string; - /** - * Whether this integration is enabled for your customers to use. - */ - enabled: boolean; - /** - * A source-specific ID used to distinguish between different sources originating from the same data connection. In general, a data connection is a single data source. However, for TrueLayer, `sourceId` is associated with a specific bank and has a many-to-one relationship with the `integrationId`. - */ - sourceId?: string | undefined; - /** - * The type of platform of the connection. - */ - sourceType?: SourceType | undefined; - /** - * A Codat ID representing the integration. - */ - integrationId?: string | undefined; - /** - * `True` if the integration is to an application installed and run locally on an SMBs computer. - */ - isOfflineConnector?: boolean | undefined; - /** - * `True` if the integration is currently in beta release. - */ - isBeta?: boolean | undefined; - /** - * The name of the data provider. - */ - dataProvidedBy?: string | undefined; - datatypeFeatures?: Array | undefined; + /** + * A unique 4-letter key to represent a platform in each integration. View [accounting](https://docs.codat.io/integrations/accounting/overview#platform-keys), [banking](https://docs.codat.io/integrations/banking/overview#platform-keys), and [commerce](https://docs.codat.io/integrations/commerce/overview#platform-keys) platform keys. + */ + key: string; + /** + * Static url for integration's logo. + */ + logoUrl: string; + /** + * Name of integration. + */ + name: string; + /** + * Whether this integration is enabled for your customers to use. + */ + enabled: boolean; + /** + * A source-specific ID used to distinguish between different sources originating from the same data connection. In general, a data connection is a single data source. However, for TrueLayer, `sourceId` is associated with a specific bank and has a many-to-one relationship with the `integrationId`. + */ + sourceId?: string | undefined; + /** + * The type of platform of the connection. + */ + sourceType?: SourceType | undefined; + /** + * A Codat ID representing the integration. + */ + integrationId?: string | undefined; + /** + * `True` if the integration is to an application installed and run locally on an SMBs computer. + */ + isOfflineConnector?: boolean | undefined; + /** + * `True` if the integration is currently in beta release. + */ + isBeta?: boolean | undefined; + /** + * The name of the data provider. + */ + dataProvidedBy?: string | undefined; + datatypeFeatures?: Array | undefined; }; /** @internal */ -export const Integration$inboundSchema: z.ZodType = z.object({ - key: z.string(), - logoUrl: z.string(), - name: z.string(), - enabled: z.boolean(), - sourceId: z.string().optional(), - sourceType: SourceType$inboundSchema.optional(), - integrationId: z.string().optional(), - isOfflineConnector: z.boolean().optional(), - isBeta: z.boolean().optional(), - dataProvidedBy: z.string().optional(), - datatypeFeatures: z.array(DataTypeFeature$inboundSchema).optional(), +export const Integration$inboundSchema: z.ZodType< + Integration, + z.ZodTypeDef, + unknown +> = z.object({ + key: z.string(), + logoUrl: z.string(), + name: z.string(), + enabled: z.boolean(), + sourceId: z.string().optional(), + sourceType: SourceType$inboundSchema.optional(), + integrationId: z.string().optional(), + isOfflineConnector: z.boolean().optional(), + isBeta: z.boolean().optional(), + dataProvidedBy: z.string().optional(), + datatypeFeatures: z.array(DataTypeFeature$inboundSchema).optional(), }); /** @internal */ export type Integration$Outbound = { - key: string; - logoUrl: string; - name: string; - enabled: boolean; - sourceId?: string | undefined; - sourceType?: string | undefined; - integrationId?: string | undefined; - isOfflineConnector?: boolean | undefined; - isBeta?: boolean | undefined; - dataProvidedBy?: string | undefined; - datatypeFeatures?: Array | undefined; + key: string; + logoUrl: string; + name: string; + enabled: boolean; + sourceId?: string | undefined; + sourceType?: string | undefined; + integrationId?: string | undefined; + isOfflineConnector?: boolean | undefined; + isBeta?: boolean | undefined; + dataProvidedBy?: string | undefined; + datatypeFeatures?: Array | undefined; }; /** @internal */ export const Integration$outboundSchema: z.ZodType< - Integration$Outbound, - z.ZodTypeDef, - Integration + Integration$Outbound, + z.ZodTypeDef, + Integration > = z.object({ - key: z.string(), - logoUrl: z.string(), - name: z.string(), - enabled: z.boolean(), - sourceId: z.string().optional(), - sourceType: SourceType$outboundSchema.optional(), - integrationId: z.string().optional(), - isOfflineConnector: z.boolean().optional(), - isBeta: z.boolean().optional(), - dataProvidedBy: z.string().optional(), - datatypeFeatures: z.array(DataTypeFeature$outboundSchema).optional(), + key: z.string(), + logoUrl: z.string(), + name: z.string(), + enabled: z.boolean(), + sourceId: z.string().optional(), + sourceType: SourceType$outboundSchema.optional(), + integrationId: z.string().optional(), + isOfflineConnector: z.boolean().optional(), + isBeta: z.boolean().optional(), + dataProvidedBy: z.string().optional(), + datatypeFeatures: z.array(DataTypeFeature$outboundSchema).optional(), }); /** @@ -112,10 +123,24 @@ export const Integration$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Integration$ { - /** @deprecated use `Integration$inboundSchema` instead. */ - export const inboundSchema = Integration$inboundSchema; - /** @deprecated use `Integration$outboundSchema` instead. */ - export const outboundSchema = Integration$outboundSchema; - /** @deprecated use `Integration$Outbound` instead. */ - export type Outbound = Integration$Outbound; + /** @deprecated use `Integration$inboundSchema` instead. */ + export const inboundSchema = Integration$inboundSchema; + /** @deprecated use `Integration$outboundSchema` instead. */ + export const outboundSchema = Integration$outboundSchema; + /** @deprecated use `Integration$Outbound` instead. */ + export type Outbound = Integration$Outbound; +} + +export function integrationToJSON(integration: Integration): string { + return JSON.stringify(Integration$outboundSchema.parse(integration)); +} + +export function integrationFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Integration$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Integration' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/integrations.ts b/sync-for-commerce/src/sdk/models/shared/integrations.ts index 7ec954ac8..0b1f022fc 100644 --- a/sync-for-commerce/src/sdk/models/shared/integrations.ts +++ b/sync-for-commerce/src/sdk/models/shared/integrations.ts @@ -1,86 +1,108 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; import { remap as remap$ } from "../../../lib/primitives.js"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - Integration, - Integration$inboundSchema, - Integration$Outbound, - Integration$outboundSchema, + Integration, + Integration$inboundSchema, + Integration$Outbound, + Integration$outboundSchema, } from "./integration.js"; -import { Links, Links$inboundSchema, Links$Outbound, Links$outboundSchema } from "./links.js"; -import * as z from "zod"; +import { + Links, + Links$inboundSchema, + Links$Outbound, + Links$outboundSchema, +} from "./links.js"; export type Integrations = { - results?: Array | undefined; - /** - * Current page number. - */ - pageNumber: number; - /** - * Number of items to return in results array. - */ - pageSize: number; - /** - * Total number of items. - */ - totalResults: number; - links: Links; + results?: Array | undefined; + /** + * Current page number. + */ + pageNumber: number; + /** + * Number of items to return in results array. + */ + pageSize: number; + /** + * Total number of items. + */ + totalResults: number; + links: Links; }; /** @internal */ -export const Integrations$inboundSchema: z.ZodType = z - .object({ - results: z.array(Integration$inboundSchema).optional(), - pageNumber: z.number().int(), - pageSize: z.number().int(), - totalResults: z.number().int(), - _links: Links$inboundSchema, - }) - .transform((v) => { - return remap$(v, { - _links: "links", - }); - }); +export const Integrations$inboundSchema: z.ZodType< + Integrations, + z.ZodTypeDef, + unknown +> = z.object({ + results: z.array(Integration$inboundSchema).optional(), + pageNumber: z.number().int(), + pageSize: z.number().int(), + totalResults: z.number().int(), + _links: Links$inboundSchema, +}).transform((v) => { + return remap$(v, { + "_links": "links", + }); +}); /** @internal */ export type Integrations$Outbound = { - results?: Array | undefined; - pageNumber: number; - pageSize: number; - totalResults: number; - _links: Links$Outbound; + results?: Array | undefined; + pageNumber: number; + pageSize: number; + totalResults: number; + _links: Links$Outbound; }; /** @internal */ export const Integrations$outboundSchema: z.ZodType< - Integrations$Outbound, - z.ZodTypeDef, - Integrations -> = z - .object({ - results: z.array(Integration$outboundSchema).optional(), - pageNumber: z.number().int(), - pageSize: z.number().int(), - totalResults: z.number().int(), - links: Links$outboundSchema, - }) - .transform((v) => { - return remap$(v, { - links: "_links", - }); - }); + Integrations$Outbound, + z.ZodTypeDef, + Integrations +> = z.object({ + results: z.array(Integration$outboundSchema).optional(), + pageNumber: z.number().int(), + pageSize: z.number().int(), + totalResults: z.number().int(), + links: Links$outboundSchema, +}).transform((v) => { + return remap$(v, { + links: "_links", + }); +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Integrations$ { - /** @deprecated use `Integrations$inboundSchema` instead. */ - export const inboundSchema = Integrations$inboundSchema; - /** @deprecated use `Integrations$outboundSchema` instead. */ - export const outboundSchema = Integrations$outboundSchema; - /** @deprecated use `Integrations$Outbound` instead. */ - export type Outbound = Integrations$Outbound; + /** @deprecated use `Integrations$inboundSchema` instead. */ + export const inboundSchema = Integrations$inboundSchema; + /** @deprecated use `Integrations$outboundSchema` instead. */ + export const outboundSchema = Integrations$outboundSchema; + /** @deprecated use `Integrations$Outbound` instead. */ + export type Outbound = Integrations$Outbound; +} + +export function integrationsToJSON(integrations: Integrations): string { + return JSON.stringify(Integrations$outboundSchema.parse(integrations)); +} + +export function integrationsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Integrations$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Integrations' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/invoicelevelselection.ts b/sync-for-commerce/src/sdk/models/shared/invoicelevelselection.ts index e0fb7c196..24b5bfb36 100644 --- a/sync-for-commerce/src/sdk/models/shared/invoicelevelselection.ts +++ b/sync-for-commerce/src/sdk/models/shared/invoicelevelselection.ts @@ -1,44 +1,47 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type InvoiceLevelSelection = { - /** - * Selected array of grouping options. - */ - selectedGroupByOptions?: Array | null | undefined; - /** - * Options for grouping sales. - */ - groupByOptions?: Array | null | undefined; + /** + * Selected array of grouping options. + */ + selectedGroupByOptions?: Array | null | undefined; + /** + * Options for grouping sales. + */ + groupByOptions?: Array | null | undefined; }; /** @internal */ export const InvoiceLevelSelection$inboundSchema: z.ZodType< - InvoiceLevelSelection, - z.ZodTypeDef, - unknown + InvoiceLevelSelection, + z.ZodTypeDef, + unknown > = z.object({ - selectedGroupByOptions: z.nullable(z.array(z.string())).optional(), - groupByOptions: z.nullable(z.array(z.string())).optional(), + selectedGroupByOptions: z.nullable(z.array(z.string())).optional(), + groupByOptions: z.nullable(z.array(z.string())).optional(), }); /** @internal */ export type InvoiceLevelSelection$Outbound = { - selectedGroupByOptions?: Array | null | undefined; - groupByOptions?: Array | null | undefined; + selectedGroupByOptions?: Array | null | undefined; + groupByOptions?: Array | null | undefined; }; /** @internal */ export const InvoiceLevelSelection$outboundSchema: z.ZodType< - InvoiceLevelSelection$Outbound, - z.ZodTypeDef, - InvoiceLevelSelection + InvoiceLevelSelection$Outbound, + z.ZodTypeDef, + InvoiceLevelSelection > = z.object({ - selectedGroupByOptions: z.nullable(z.array(z.string())).optional(), - groupByOptions: z.nullable(z.array(z.string())).optional(), + selectedGroupByOptions: z.nullable(z.array(z.string())).optional(), + groupByOptions: z.nullable(z.array(z.string())).optional(), }); /** @@ -46,10 +49,28 @@ export const InvoiceLevelSelection$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace InvoiceLevelSelection$ { - /** @deprecated use `InvoiceLevelSelection$inboundSchema` instead. */ - export const inboundSchema = InvoiceLevelSelection$inboundSchema; - /** @deprecated use `InvoiceLevelSelection$outboundSchema` instead. */ - export const outboundSchema = InvoiceLevelSelection$outboundSchema; - /** @deprecated use `InvoiceLevelSelection$Outbound` instead. */ - export type Outbound = InvoiceLevelSelection$Outbound; + /** @deprecated use `InvoiceLevelSelection$inboundSchema` instead. */ + export const inboundSchema = InvoiceLevelSelection$inboundSchema; + /** @deprecated use `InvoiceLevelSelection$outboundSchema` instead. */ + export const outboundSchema = InvoiceLevelSelection$outboundSchema; + /** @deprecated use `InvoiceLevelSelection$Outbound` instead. */ + export type Outbound = InvoiceLevelSelection$Outbound; +} + +export function invoiceLevelSelectionToJSON( + invoiceLevelSelection: InvoiceLevelSelection, +): string { + return JSON.stringify( + InvoiceLevelSelection$outboundSchema.parse(invoiceLevelSelection), + ); +} + +export function invoiceLevelSelectionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => InvoiceLevelSelection$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'InvoiceLevelSelection' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/invoicelinelevelselection.ts b/sync-for-commerce/src/sdk/models/shared/invoicelinelevelselection.ts index e8dcfe459..c93a69d34 100644 --- a/sync-for-commerce/src/sdk/models/shared/invoicelinelevelselection.ts +++ b/sync-for-commerce/src/sdk/models/shared/invoicelinelevelselection.ts @@ -1,44 +1,47 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type InvoiceLineLevelSelection = { - /** - * Invoice line level selection. - */ - selectedGroupByOptions?: Array | null | undefined; - /** - * Options for grouping on invoice lines. - */ - groupByOptions?: Array | null | undefined; + /** + * Invoice line level selection. + */ + selectedGroupByOptions?: Array | null | undefined; + /** + * Options for grouping on invoice lines. + */ + groupByOptions?: Array | null | undefined; }; /** @internal */ export const InvoiceLineLevelSelection$inboundSchema: z.ZodType< - InvoiceLineLevelSelection, - z.ZodTypeDef, - unknown + InvoiceLineLevelSelection, + z.ZodTypeDef, + unknown > = z.object({ - selectedGroupByOptions: z.nullable(z.array(z.string())).optional(), - groupByOptions: z.nullable(z.array(z.string())).optional(), + selectedGroupByOptions: z.nullable(z.array(z.string())).optional(), + groupByOptions: z.nullable(z.array(z.string())).optional(), }); /** @internal */ export type InvoiceLineLevelSelection$Outbound = { - selectedGroupByOptions?: Array | null | undefined; - groupByOptions?: Array | null | undefined; + selectedGroupByOptions?: Array | null | undefined; + groupByOptions?: Array | null | undefined; }; /** @internal */ export const InvoiceLineLevelSelection$outboundSchema: z.ZodType< - InvoiceLineLevelSelection$Outbound, - z.ZodTypeDef, - InvoiceLineLevelSelection + InvoiceLineLevelSelection$Outbound, + z.ZodTypeDef, + InvoiceLineLevelSelection > = z.object({ - selectedGroupByOptions: z.nullable(z.array(z.string())).optional(), - groupByOptions: z.nullable(z.array(z.string())).optional(), + selectedGroupByOptions: z.nullable(z.array(z.string())).optional(), + groupByOptions: z.nullable(z.array(z.string())).optional(), }); /** @@ -46,10 +49,28 @@ export const InvoiceLineLevelSelection$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace InvoiceLineLevelSelection$ { - /** @deprecated use `InvoiceLineLevelSelection$inboundSchema` instead. */ - export const inboundSchema = InvoiceLineLevelSelection$inboundSchema; - /** @deprecated use `InvoiceLineLevelSelection$outboundSchema` instead. */ - export const outboundSchema = InvoiceLineLevelSelection$outboundSchema; - /** @deprecated use `InvoiceLineLevelSelection$Outbound` instead. */ - export type Outbound = InvoiceLineLevelSelection$Outbound; + /** @deprecated use `InvoiceLineLevelSelection$inboundSchema` instead. */ + export const inboundSchema = InvoiceLineLevelSelection$inboundSchema; + /** @deprecated use `InvoiceLineLevelSelection$outboundSchema` instead. */ + export const outboundSchema = InvoiceLineLevelSelection$outboundSchema; + /** @deprecated use `InvoiceLineLevelSelection$Outbound` instead. */ + export type Outbound = InvoiceLineLevelSelection$Outbound; +} + +export function invoiceLineLevelSelectionToJSON( + invoiceLineLevelSelection: InvoiceLineLevelSelection, +): string { + return JSON.stringify( + InvoiceLineLevelSelection$outboundSchema.parse(invoiceLineLevelSelection), + ); +} + +export function invoiceLineLevelSelectionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => InvoiceLineLevelSelection$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'InvoiceLineLevelSelection' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/invoicestatus.ts b/sync-for-commerce/src/sdk/models/shared/invoicestatus.ts index 1af7eaf7a..9c6283fc9 100644 --- a/sync-for-commerce/src/sdk/models/shared/invoicestatus.ts +++ b/sync-for-commerce/src/sdk/models/shared/invoicestatus.ts @@ -1,41 +1,47 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type InvoiceStatus = { - /** - * Selected option for invoice status for invoice to be synced. - */ - selectedInvoiceStatus?: string | null | undefined; - /** - * Options for invoice statuses. - */ - invoiceStatusOptions?: Array | null | undefined; + /** + * Selected option for invoice status for invoice to be synced. + */ + selectedInvoiceStatus?: string | null | undefined; + /** + * Options for invoice statuses. + */ + invoiceStatusOptions?: Array | null | undefined; }; /** @internal */ -export const InvoiceStatus$inboundSchema: z.ZodType = - z.object({ - selectedInvoiceStatus: z.nullable(z.string()).optional(), - invoiceStatusOptions: z.nullable(z.array(z.string())).optional(), - }); +export const InvoiceStatus$inboundSchema: z.ZodType< + InvoiceStatus, + z.ZodTypeDef, + unknown +> = z.object({ + selectedInvoiceStatus: z.nullable(z.string()).optional(), + invoiceStatusOptions: z.nullable(z.array(z.string())).optional(), +}); /** @internal */ export type InvoiceStatus$Outbound = { - selectedInvoiceStatus?: string | null | undefined; - invoiceStatusOptions?: Array | null | undefined; + selectedInvoiceStatus?: string | null | undefined; + invoiceStatusOptions?: Array | null | undefined; }; /** @internal */ export const InvoiceStatus$outboundSchema: z.ZodType< - InvoiceStatus$Outbound, - z.ZodTypeDef, - InvoiceStatus + InvoiceStatus$Outbound, + z.ZodTypeDef, + InvoiceStatus > = z.object({ - selectedInvoiceStatus: z.nullable(z.string()).optional(), - invoiceStatusOptions: z.nullable(z.array(z.string())).optional(), + selectedInvoiceStatus: z.nullable(z.string()).optional(), + invoiceStatusOptions: z.nullable(z.array(z.string())).optional(), }); /** @@ -43,10 +49,24 @@ export const InvoiceStatus$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace InvoiceStatus$ { - /** @deprecated use `InvoiceStatus$inboundSchema` instead. */ - export const inboundSchema = InvoiceStatus$inboundSchema; - /** @deprecated use `InvoiceStatus$outboundSchema` instead. */ - export const outboundSchema = InvoiceStatus$outboundSchema; - /** @deprecated use `InvoiceStatus$Outbound` instead. */ - export type Outbound = InvoiceStatus$Outbound; + /** @deprecated use `InvoiceStatus$inboundSchema` instead. */ + export const inboundSchema = InvoiceStatus$inboundSchema; + /** @deprecated use `InvoiceStatus$outboundSchema` instead. */ + export const outboundSchema = InvoiceStatus$outboundSchema; + /** @deprecated use `InvoiceStatus$Outbound` instead. */ + export type Outbound = InvoiceStatus$Outbound; +} + +export function invoiceStatusToJSON(invoiceStatus: InvoiceStatus): string { + return JSON.stringify(InvoiceStatus$outboundSchema.parse(invoiceStatus)); +} + +export function invoiceStatusFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => InvoiceStatus$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'InvoiceStatus' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/items.ts b/sync-for-commerce/src/sdk/models/shared/items.ts deleted file mode 100644 index d6637ae4d..000000000 --- a/sync-for-commerce/src/sdk/models/shared/items.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. - */ - -import * as z from "zod"; - -export type Items = { - /** - * Unique identifier for the group. - */ - id?: string | undefined; -}; - -/** @internal */ -export const Items$inboundSchema: z.ZodType = z.object({ - id: z.string().optional(), -}); - -/** @internal */ -export type Items$Outbound = { - id?: string | undefined; -}; - -/** @internal */ -export const Items$outboundSchema: z.ZodType = z.object({ - id: z.string().optional(), -}); - -/** - * @internal - * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. - */ -export namespace Items$ { - /** @deprecated use `Items$inboundSchema` instead. */ - export const inboundSchema = Items$inboundSchema; - /** @deprecated use `Items$outboundSchema` instead. */ - export const outboundSchema = Items$outboundSchema; - /** @deprecated use `Items$Outbound` instead. */ - export type Outbound = Items$Outbound; -} diff --git a/sync-for-commerce/src/sdk/models/shared/links.ts b/sync-for-commerce/src/sdk/models/shared/links.ts index ae9916618..1a8a3117e 100644 --- a/sync-for-commerce/src/sdk/models/shared/links.ts +++ b/sync-for-commerce/src/sdk/models/shared/links.ts @@ -1,39 +1,52 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { HalRef, HalRef$inboundSchema, HalRef$Outbound, HalRef$outboundSchema } from "./halref.js"; import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; +import { + HalRef, + HalRef$inboundSchema, + HalRef$Outbound, + HalRef$outboundSchema, +} from "./halref.js"; export type Links = { - self: HalRef; - current: HalRef; - next?: HalRef | undefined; - previous?: HalRef | undefined; + self: HalRef; + current: HalRef; + next?: HalRef | undefined; + previous?: HalRef | undefined; }; /** @internal */ -export const Links$inboundSchema: z.ZodType = z.object({ +export const Links$inboundSchema: z.ZodType = z + .object({ self: HalRef$inboundSchema, current: HalRef$inboundSchema, next: HalRef$inboundSchema.optional(), previous: HalRef$inboundSchema.optional(), -}); + }); /** @internal */ export type Links$Outbound = { - self: HalRef$Outbound; - current: HalRef$Outbound; - next?: HalRef$Outbound | undefined; - previous?: HalRef$Outbound | undefined; + self: HalRef$Outbound; + current: HalRef$Outbound; + next?: HalRef$Outbound | undefined; + previous?: HalRef$Outbound | undefined; }; /** @internal */ -export const Links$outboundSchema: z.ZodType = z.object({ - self: HalRef$outboundSchema, - current: HalRef$outboundSchema, - next: HalRef$outboundSchema.optional(), - previous: HalRef$outboundSchema.optional(), +export const Links$outboundSchema: z.ZodType< + Links$Outbound, + z.ZodTypeDef, + Links +> = z.object({ + self: HalRef$outboundSchema, + current: HalRef$outboundSchema, + next: HalRef$outboundSchema.optional(), + previous: HalRef$outboundSchema.optional(), }); /** @@ -41,10 +54,24 @@ export const Links$outboundSchema: z.ZodType { + return safeParse( + jsonString, + (x) => Links$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Links' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/locale.ts b/sync-for-commerce/src/sdk/models/shared/locale.ts index 4f958e91a..d61f65826 100644 --- a/sync-for-commerce/src/sdk/models/shared/locale.ts +++ b/sync-for-commerce/src/sdk/models/shared/locale.ts @@ -1,29 +1,31 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ClosedEnum } from "../../types/enums.js"; import * as z from "zod"; +import { ClosedEnum } from "../../types/enums.js"; export const Locale = { - EnUs: "en-us", - FrFr: "fr-fr", + EnUs: "en-us", + FrFr: "fr-fr", } as const; export type Locale = ClosedEnum; /** @internal */ -export const Locale$inboundSchema: z.ZodNativeEnum = z.nativeEnum(Locale); +export const Locale$inboundSchema: z.ZodNativeEnum = z + .nativeEnum(Locale); /** @internal */ -export const Locale$outboundSchema: z.ZodNativeEnum = Locale$inboundSchema; +export const Locale$outboundSchema: z.ZodNativeEnum = + Locale$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Locale$ { - /** @deprecated use `Locale$inboundSchema` instead. */ - export const inboundSchema = Locale$inboundSchema; - /** @deprecated use `Locale$outboundSchema` instead. */ - export const outboundSchema = Locale$outboundSchema; + /** @deprecated use `Locale$inboundSchema` instead. */ + export const inboundSchema = Locale$inboundSchema; + /** @deprecated use `Locale$outboundSchema` instead. */ + export const outboundSchema = Locale$outboundSchema; } diff --git a/sync-for-commerce/src/sdk/models/shared/localization.ts b/sync-for-commerce/src/sdk/models/shared/localization.ts index 63106759b..54613adfd 100644 --- a/sync-for-commerce/src/sdk/models/shared/localization.ts +++ b/sync-for-commerce/src/sdk/models/shared/localization.ts @@ -1,40 +1,47 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type Localization = { - /** - * Value of the property. - */ - text?: string | null | undefined; - /** - * `True` if required. - */ - required?: boolean | undefined; + /** + * Value of the property. + */ + text?: string | null | undefined; + /** + * `True` if required. + */ + required?: boolean | undefined; }; /** @internal */ -export const Localization$inboundSchema: z.ZodType = z.object({ - text: z.nullable(z.string()).optional(), - required: z.boolean().optional(), +export const Localization$inboundSchema: z.ZodType< + Localization, + z.ZodTypeDef, + unknown +> = z.object({ + text: z.nullable(z.string()).optional(), + required: z.boolean().optional(), }); /** @internal */ export type Localization$Outbound = { - text?: string | null | undefined; - required?: boolean | undefined; + text?: string | null | undefined; + required?: boolean | undefined; }; /** @internal */ export const Localization$outboundSchema: z.ZodType< - Localization$Outbound, - z.ZodTypeDef, - Localization + Localization$Outbound, + z.ZodTypeDef, + Localization > = z.object({ - text: z.nullable(z.string()).optional(), - required: z.boolean().optional(), + text: z.nullable(z.string()).optional(), + required: z.boolean().optional(), }); /** @@ -42,10 +49,24 @@ export const Localization$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Localization$ { - /** @deprecated use `Localization$inboundSchema` instead. */ - export const inboundSchema = Localization$inboundSchema; - /** @deprecated use `Localization$outboundSchema` instead. */ - export const outboundSchema = Localization$outboundSchema; - /** @deprecated use `Localization$Outbound` instead. */ - export type Outbound = Localization$Outbound; + /** @deprecated use `Localization$inboundSchema` instead. */ + export const inboundSchema = Localization$inboundSchema; + /** @deprecated use `Localization$outboundSchema` instead. */ + export const outboundSchema = Localization$outboundSchema; + /** @deprecated use `Localization$Outbound` instead. */ + export type Outbound = Localization$Outbound; +} + +export function localizationToJSON(localization: Localization): string { + return JSON.stringify(Localization$outboundSchema.parse(localization)); +} + +export function localizationFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Localization$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Localization' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/newpaymentsconfiguration.ts b/sync-for-commerce/src/sdk/models/shared/newpaymentsconfiguration.ts index 5abf89c11..ce4f91fc4 100644 --- a/sync-for-commerce/src/sdk/models/shared/newpaymentsconfiguration.ts +++ b/sync-for-commerce/src/sdk/models/shared/newpaymentsconfiguration.ts @@ -1,47 +1,51 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - AccountConfiguration, - AccountConfiguration$inboundSchema, - AccountConfiguration$Outbound, - AccountConfiguration$outboundSchema, + AccountConfiguration, + AccountConfiguration$inboundSchema, + AccountConfiguration$Outbound, + AccountConfiguration$outboundSchema, } from "./accountconfiguration.js"; -import * as z from "zod"; export type NewPaymentsConfiguration = { - /** - * Boolean indicator for syncing payments. - */ - syncPayments?: boolean | undefined; - accounts?: { [k: string]: AccountConfiguration } | null | undefined; + /** + * Boolean indicator for syncing payments. + */ + syncPayments?: boolean | undefined; + accounts?: { [k: string]: AccountConfiguration } | null | undefined; }; /** @internal */ export const NewPaymentsConfiguration$inboundSchema: z.ZodType< - NewPaymentsConfiguration, - z.ZodTypeDef, - unknown + NewPaymentsConfiguration, + z.ZodTypeDef, + unknown > = z.object({ - syncPayments: z.boolean().optional(), - accounts: z.nullable(z.record(AccountConfiguration$inboundSchema)).optional(), + syncPayments: z.boolean().optional(), + accounts: z.nullable(z.record(AccountConfiguration$inboundSchema)).optional(), }); /** @internal */ export type NewPaymentsConfiguration$Outbound = { - syncPayments?: boolean | undefined; - accounts?: { [k: string]: AccountConfiguration$Outbound } | null | undefined; + syncPayments?: boolean | undefined; + accounts?: { [k: string]: AccountConfiguration$Outbound } | null | undefined; }; /** @internal */ export const NewPaymentsConfiguration$outboundSchema: z.ZodType< - NewPaymentsConfiguration$Outbound, - z.ZodTypeDef, - NewPaymentsConfiguration + NewPaymentsConfiguration$Outbound, + z.ZodTypeDef, + NewPaymentsConfiguration > = z.object({ - syncPayments: z.boolean().optional(), - accounts: z.nullable(z.record(AccountConfiguration$outboundSchema)).optional(), + syncPayments: z.boolean().optional(), + accounts: z.nullable(z.record(AccountConfiguration$outboundSchema)) + .optional(), }); /** @@ -49,10 +53,28 @@ export const NewPaymentsConfiguration$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace NewPaymentsConfiguration$ { - /** @deprecated use `NewPaymentsConfiguration$inboundSchema` instead. */ - export const inboundSchema = NewPaymentsConfiguration$inboundSchema; - /** @deprecated use `NewPaymentsConfiguration$outboundSchema` instead. */ - export const outboundSchema = NewPaymentsConfiguration$outboundSchema; - /** @deprecated use `NewPaymentsConfiguration$Outbound` instead. */ - export type Outbound = NewPaymentsConfiguration$Outbound; + /** @deprecated use `NewPaymentsConfiguration$inboundSchema` instead. */ + export const inboundSchema = NewPaymentsConfiguration$inboundSchema; + /** @deprecated use `NewPaymentsConfiguration$outboundSchema` instead. */ + export const outboundSchema = NewPaymentsConfiguration$outboundSchema; + /** @deprecated use `NewPaymentsConfiguration$Outbound` instead. */ + export type Outbound = NewPaymentsConfiguration$Outbound; +} + +export function newPaymentsConfigurationToJSON( + newPaymentsConfiguration: NewPaymentsConfiguration, +): string { + return JSON.stringify( + NewPaymentsConfiguration$outboundSchema.parse(newPaymentsConfiguration), + ); +} + +export function newPaymentsConfigurationFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => NewPaymentsConfiguration$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'NewPaymentsConfiguration' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/newtaxrates.ts b/sync-for-commerce/src/sdk/models/shared/newtaxrates.ts index 1a4e0f7eb..398b2d5fb 100644 --- a/sync-for-commerce/src/sdk/models/shared/newtaxrates.ts +++ b/sync-for-commerce/src/sdk/models/shared/newtaxrates.ts @@ -1,73 +1,101 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - ConfigurationOption, - ConfigurationOption$inboundSchema, - ConfigurationOption$Outbound, - ConfigurationOption$outboundSchema, + ConfigurationOption, + ConfigurationOption$inboundSchema, + ConfigurationOption$Outbound, + ConfigurationOption$outboundSchema, } from "./configurationoption.js"; import { - TaxRateMapping, - TaxRateMapping$inboundSchema, - TaxRateMapping$Outbound, - TaxRateMapping$outboundSchema, + TaxRateMapping, + TaxRateMapping$inboundSchema, + TaxRateMapping$Outbound, + TaxRateMapping$outboundSchema, } from "./taxratemapping.js"; -import * as z from "zod"; export type NewTaxRates = { - /** - * Array of accounting tax rate options. - */ - accountingTaxRateOptions?: Array | null | undefined; - /** - * Array of tax component options. - */ - commerceTaxRateOptions?: Array | null | undefined; - /** - * Array of tax component to rate mappings. - */ - taxRateMappings?: Array | null | undefined; - /** - * Default tax rate selected for sync. - */ - selectedDefaultZeroTaxRateId?: string | null | undefined; - /** - * Default zero tax rate selected for sync. - */ - defaultZeroTaxRateOptions?: Array | null | undefined; + /** + * Array of accounting tax rate options. + */ + accountingTaxRateOptions?: Array | null | undefined; + /** + * Array of tax component options. + */ + commerceTaxRateOptions?: Array | null | undefined; + /** + * Array of tax component to rate mappings. + */ + taxRateMappings?: Array | null | undefined; + /** + * Default tax rate selected for sync. + */ + selectedDefaultZeroTaxRateId?: string | null | undefined; + /** + * Default zero tax rate selected for sync. + */ + defaultZeroTaxRateOptions?: Array | null | undefined; }; /** @internal */ -export const NewTaxRates$inboundSchema: z.ZodType = z.object({ - accountingTaxRateOptions: z.nullable(z.array(ConfigurationOption$inboundSchema)).optional(), - commerceTaxRateOptions: z.nullable(z.array(ConfigurationOption$inboundSchema)).optional(), - taxRateMappings: z.nullable(z.array(TaxRateMapping$inboundSchema)).optional(), - selectedDefaultZeroTaxRateId: z.nullable(z.string()).optional(), - defaultZeroTaxRateOptions: z.nullable(z.array(ConfigurationOption$inboundSchema)).optional(), +export const NewTaxRates$inboundSchema: z.ZodType< + NewTaxRates, + z.ZodTypeDef, + unknown +> = z.object({ + accountingTaxRateOptions: z.nullable( + z.array(ConfigurationOption$inboundSchema), + ).optional(), + commerceTaxRateOptions: z.nullable(z.array(ConfigurationOption$inboundSchema)) + .optional(), + taxRateMappings: z.nullable(z.array(TaxRateMapping$inboundSchema)).optional(), + selectedDefaultZeroTaxRateId: z.nullable(z.string()).optional(), + defaultZeroTaxRateOptions: z.nullable( + z.array(ConfigurationOption$inboundSchema), + ).optional(), }); /** @internal */ export type NewTaxRates$Outbound = { - accountingTaxRateOptions?: Array | null | undefined; - commerceTaxRateOptions?: Array | null | undefined; - taxRateMappings?: Array | null | undefined; - selectedDefaultZeroTaxRateId?: string | null | undefined; - defaultZeroTaxRateOptions?: Array | null | undefined; + accountingTaxRateOptions?: + | Array + | null + | undefined; + commerceTaxRateOptions?: + | Array + | null + | undefined; + taxRateMappings?: Array | null | undefined; + selectedDefaultZeroTaxRateId?: string | null | undefined; + defaultZeroTaxRateOptions?: + | Array + | null + | undefined; }; /** @internal */ export const NewTaxRates$outboundSchema: z.ZodType< - NewTaxRates$Outbound, - z.ZodTypeDef, - NewTaxRates + NewTaxRates$Outbound, + z.ZodTypeDef, + NewTaxRates > = z.object({ - accountingTaxRateOptions: z.nullable(z.array(ConfigurationOption$outboundSchema)).optional(), - commerceTaxRateOptions: z.nullable(z.array(ConfigurationOption$outboundSchema)).optional(), - taxRateMappings: z.nullable(z.array(TaxRateMapping$outboundSchema)).optional(), - selectedDefaultZeroTaxRateId: z.nullable(z.string()).optional(), - defaultZeroTaxRateOptions: z.nullable(z.array(ConfigurationOption$outboundSchema)).optional(), + accountingTaxRateOptions: z.nullable( + z.array(ConfigurationOption$outboundSchema), + ).optional(), + commerceTaxRateOptions: z.nullable( + z.array(ConfigurationOption$outboundSchema), + ).optional(), + taxRateMappings: z.nullable(z.array(TaxRateMapping$outboundSchema)) + .optional(), + selectedDefaultZeroTaxRateId: z.nullable(z.string()).optional(), + defaultZeroTaxRateOptions: z.nullable( + z.array(ConfigurationOption$outboundSchema), + ).optional(), }); /** @@ -75,10 +103,24 @@ export const NewTaxRates$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace NewTaxRates$ { - /** @deprecated use `NewTaxRates$inboundSchema` instead. */ - export const inboundSchema = NewTaxRates$inboundSchema; - /** @deprecated use `NewTaxRates$outboundSchema` instead. */ - export const outboundSchema = NewTaxRates$outboundSchema; - /** @deprecated use `NewTaxRates$Outbound` instead. */ - export type Outbound = NewTaxRates$Outbound; + /** @deprecated use `NewTaxRates$inboundSchema` instead. */ + export const inboundSchema = NewTaxRates$inboundSchema; + /** @deprecated use `NewTaxRates$outboundSchema` instead. */ + export const outboundSchema = NewTaxRates$outboundSchema; + /** @deprecated use `NewTaxRates$Outbound` instead. */ + export type Outbound = NewTaxRates$Outbound; +} + +export function newTaxRatesToJSON(newTaxRates: NewTaxRates): string { + return JSON.stringify(NewTaxRates$outboundSchema.parse(newTaxRates)); +} + +export function newTaxRatesFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => NewTaxRates$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'NewTaxRates' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/paymentsconfiguration.ts b/sync-for-commerce/src/sdk/models/shared/paymentsconfiguration.ts index 12b246b29..d3d9f0a51 100644 --- a/sync-for-commerce/src/sdk/models/shared/paymentsconfiguration.ts +++ b/sync-for-commerce/src/sdk/models/shared/paymentsconfiguration.ts @@ -1,47 +1,51 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - AccountConfiguration, - AccountConfiguration$inboundSchema, - AccountConfiguration$Outbound, - AccountConfiguration$outboundSchema, + AccountConfiguration, + AccountConfiguration$inboundSchema, + AccountConfiguration$Outbound, + AccountConfiguration$outboundSchema, } from "./accountconfiguration.js"; -import * as z from "zod"; export type PaymentsConfiguration = { - /** - * Boolean indicator for syncing sales. - */ - syncPayments?: boolean | undefined; - accounts?: { [k: string]: AccountConfiguration } | null | undefined; + /** + * Boolean indicator for syncing sales. + */ + syncPayments?: boolean | undefined; + accounts?: { [k: string]: AccountConfiguration } | null | undefined; }; /** @internal */ export const PaymentsConfiguration$inboundSchema: z.ZodType< - PaymentsConfiguration, - z.ZodTypeDef, - unknown + PaymentsConfiguration, + z.ZodTypeDef, + unknown > = z.object({ - syncPayments: z.boolean().optional(), - accounts: z.nullable(z.record(AccountConfiguration$inboundSchema)).optional(), + syncPayments: z.boolean().optional(), + accounts: z.nullable(z.record(AccountConfiguration$inboundSchema)).optional(), }); /** @internal */ export type PaymentsConfiguration$Outbound = { - syncPayments?: boolean | undefined; - accounts?: { [k: string]: AccountConfiguration$Outbound } | null | undefined; + syncPayments?: boolean | undefined; + accounts?: { [k: string]: AccountConfiguration$Outbound } | null | undefined; }; /** @internal */ export const PaymentsConfiguration$outboundSchema: z.ZodType< - PaymentsConfiguration$Outbound, - z.ZodTypeDef, - PaymentsConfiguration + PaymentsConfiguration$Outbound, + z.ZodTypeDef, + PaymentsConfiguration > = z.object({ - syncPayments: z.boolean().optional(), - accounts: z.nullable(z.record(AccountConfiguration$outboundSchema)).optional(), + syncPayments: z.boolean().optional(), + accounts: z.nullable(z.record(AccountConfiguration$outboundSchema)) + .optional(), }); /** @@ -49,10 +53,28 @@ export const PaymentsConfiguration$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace PaymentsConfiguration$ { - /** @deprecated use `PaymentsConfiguration$inboundSchema` instead. */ - export const inboundSchema = PaymentsConfiguration$inboundSchema; - /** @deprecated use `PaymentsConfiguration$outboundSchema` instead. */ - export const outboundSchema = PaymentsConfiguration$outboundSchema; - /** @deprecated use `PaymentsConfiguration$Outbound` instead. */ - export type Outbound = PaymentsConfiguration$Outbound; + /** @deprecated use `PaymentsConfiguration$inboundSchema` instead. */ + export const inboundSchema = PaymentsConfiguration$inboundSchema; + /** @deprecated use `PaymentsConfiguration$outboundSchema` instead. */ + export const outboundSchema = PaymentsConfiguration$outboundSchema; + /** @deprecated use `PaymentsConfiguration$Outbound` instead. */ + export type Outbound = PaymentsConfiguration$Outbound; +} + +export function paymentsConfigurationToJSON( + paymentsConfiguration: PaymentsConfiguration, +): string { + return JSON.stringify( + PaymentsConfiguration$outboundSchema.parse(paymentsConfiguration), + ); +} + +export function paymentsConfigurationFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => PaymentsConfiguration$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'PaymentsConfiguration' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/salesconfiguration.ts b/sync-for-commerce/src/sdk/models/shared/salesconfiguration.ts index 1765d9de1..c96dc5c7b 100644 --- a/sync-for-commerce/src/sdk/models/shared/salesconfiguration.ts +++ b/sync-for-commerce/src/sdk/models/shared/salesconfiguration.ts @@ -1,97 +1,101 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - AccountConfiguration, - AccountConfiguration$inboundSchema, - AccountConfiguration$Outbound, - AccountConfiguration$outboundSchema, + AccountConfiguration, + AccountConfiguration$inboundSchema, + AccountConfiguration$Outbound, + AccountConfiguration$outboundSchema, } from "./accountconfiguration.js"; import { - Grouping, - Grouping$inboundSchema, - Grouping$Outbound, - Grouping$outboundSchema, + Grouping, + Grouping$inboundSchema, + Grouping$Outbound, + Grouping$outboundSchema, } from "./grouping.js"; import { - InvoiceStatus, - InvoiceStatus$inboundSchema, - InvoiceStatus$Outbound, - InvoiceStatus$outboundSchema, + InvoiceStatus, + InvoiceStatus$inboundSchema, + InvoiceStatus$Outbound, + InvoiceStatus$outboundSchema, } from "./invoicestatus.js"; import { - NewTaxRates, - NewTaxRates$inboundSchema, - NewTaxRates$Outbound, - NewTaxRates$outboundSchema, + NewTaxRates, + NewTaxRates$inboundSchema, + NewTaxRates$Outbound, + NewTaxRates$outboundSchema, } from "./newtaxrates.js"; import { - SalesCustomer, - SalesCustomer$inboundSchema, - SalesCustomer$Outbound, - SalesCustomer$outboundSchema, + SalesCustomer, + SalesCustomer$inboundSchema, + SalesCustomer$Outbound, + SalesCustomer$outboundSchema, } from "./salescustomer.js"; import { - TaxRateAmount, - TaxRateAmount$inboundSchema, - TaxRateAmount$Outbound, - TaxRateAmount$outboundSchema, + TaxRateAmount, + TaxRateAmount$inboundSchema, + TaxRateAmount$Outbound, + TaxRateAmount$outboundSchema, } from "./taxrateamount.js"; -import * as z from "zod"; export type SalesConfiguration = { - /** - * Boolean indicator for syncing sales. - */ - syncSales?: boolean | undefined; - accounts?: { [k: string]: AccountConfiguration } | null | undefined; - invoiceStatus?: InvoiceStatus | undefined; - salesCustomer?: SalesCustomer | undefined; - taxRates?: { [k: string]: TaxRateAmount } | null | undefined; - newTaxRates?: NewTaxRates | undefined; - grouping?: Grouping | undefined; + /** + * Boolean indicator for syncing sales. + */ + syncSales?: boolean | undefined; + accounts?: { [k: string]: AccountConfiguration } | null | undefined; + invoiceStatus?: InvoiceStatus | undefined; + salesCustomer?: SalesCustomer | undefined; + taxRates?: { [k: string]: TaxRateAmount } | null | undefined; + newTaxRates?: NewTaxRates | undefined; + grouping?: Grouping | undefined; }; /** @internal */ export const SalesConfiguration$inboundSchema: z.ZodType< - SalesConfiguration, - z.ZodTypeDef, - unknown + SalesConfiguration, + z.ZodTypeDef, + unknown > = z.object({ - syncSales: z.boolean().optional(), - accounts: z.nullable(z.record(AccountConfiguration$inboundSchema)).optional(), - invoiceStatus: InvoiceStatus$inboundSchema.optional(), - salesCustomer: SalesCustomer$inboundSchema.optional(), - taxRates: z.nullable(z.record(TaxRateAmount$inboundSchema)).optional(), - newTaxRates: NewTaxRates$inboundSchema.optional(), - grouping: Grouping$inboundSchema.optional(), + syncSales: z.boolean().optional(), + accounts: z.nullable(z.record(AccountConfiguration$inboundSchema)).optional(), + invoiceStatus: InvoiceStatus$inboundSchema.optional(), + salesCustomer: SalesCustomer$inboundSchema.optional(), + taxRates: z.nullable(z.record(TaxRateAmount$inboundSchema)).optional(), + newTaxRates: NewTaxRates$inboundSchema.optional(), + grouping: Grouping$inboundSchema.optional(), }); /** @internal */ export type SalesConfiguration$Outbound = { - syncSales?: boolean | undefined; - accounts?: { [k: string]: AccountConfiguration$Outbound } | null | undefined; - invoiceStatus?: InvoiceStatus$Outbound | undefined; - salesCustomer?: SalesCustomer$Outbound | undefined; - taxRates?: { [k: string]: TaxRateAmount$Outbound } | null | undefined; - newTaxRates?: NewTaxRates$Outbound | undefined; - grouping?: Grouping$Outbound | undefined; + syncSales?: boolean | undefined; + accounts?: { [k: string]: AccountConfiguration$Outbound } | null | undefined; + invoiceStatus?: InvoiceStatus$Outbound | undefined; + salesCustomer?: SalesCustomer$Outbound | undefined; + taxRates?: { [k: string]: TaxRateAmount$Outbound } | null | undefined; + newTaxRates?: NewTaxRates$Outbound | undefined; + grouping?: Grouping$Outbound | undefined; }; /** @internal */ export const SalesConfiguration$outboundSchema: z.ZodType< - SalesConfiguration$Outbound, - z.ZodTypeDef, - SalesConfiguration + SalesConfiguration$Outbound, + z.ZodTypeDef, + SalesConfiguration > = z.object({ - syncSales: z.boolean().optional(), - accounts: z.nullable(z.record(AccountConfiguration$outboundSchema)).optional(), - invoiceStatus: InvoiceStatus$outboundSchema.optional(), - salesCustomer: SalesCustomer$outboundSchema.optional(), - taxRates: z.nullable(z.record(TaxRateAmount$outboundSchema)).optional(), - newTaxRates: NewTaxRates$outboundSchema.optional(), - grouping: Grouping$outboundSchema.optional(), + syncSales: z.boolean().optional(), + accounts: z.nullable(z.record(AccountConfiguration$outboundSchema)) + .optional(), + invoiceStatus: InvoiceStatus$outboundSchema.optional(), + salesCustomer: SalesCustomer$outboundSchema.optional(), + taxRates: z.nullable(z.record(TaxRateAmount$outboundSchema)).optional(), + newTaxRates: NewTaxRates$outboundSchema.optional(), + grouping: Grouping$outboundSchema.optional(), }); /** @@ -99,10 +103,28 @@ export const SalesConfiguration$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SalesConfiguration$ { - /** @deprecated use `SalesConfiguration$inboundSchema` instead. */ - export const inboundSchema = SalesConfiguration$inboundSchema; - /** @deprecated use `SalesConfiguration$outboundSchema` instead. */ - export const outboundSchema = SalesConfiguration$outboundSchema; - /** @deprecated use `SalesConfiguration$Outbound` instead. */ - export type Outbound = SalesConfiguration$Outbound; + /** @deprecated use `SalesConfiguration$inboundSchema` instead. */ + export const inboundSchema = SalesConfiguration$inboundSchema; + /** @deprecated use `SalesConfiguration$outboundSchema` instead. */ + export const outboundSchema = SalesConfiguration$outboundSchema; + /** @deprecated use `SalesConfiguration$Outbound` instead. */ + export type Outbound = SalesConfiguration$Outbound; +} + +export function salesConfigurationToJSON( + salesConfiguration: SalesConfiguration, +): string { + return JSON.stringify( + SalesConfiguration$outboundSchema.parse(salesConfiguration), + ); +} + +export function salesConfigurationFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SalesConfiguration$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SalesConfiguration' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/salescustomer.ts b/sync-for-commerce/src/sdk/models/shared/salescustomer.ts index 35cb0f533..213ed6b98 100644 --- a/sync-for-commerce/src/sdk/models/shared/salescustomer.ts +++ b/sync-for-commerce/src/sdk/models/shared/salescustomer.ts @@ -1,47 +1,55 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - ConfigurationOption, - ConfigurationOption$inboundSchema, - ConfigurationOption$Outbound, - ConfigurationOption$outboundSchema, + ConfigurationOption, + ConfigurationOption$inboundSchema, + ConfigurationOption$Outbound, + ConfigurationOption$outboundSchema, } from "./configurationoption.js"; -import * as z from "zod"; export type SalesCustomer = { - /** - * Selected customer id from the list of customer records on the accounting software. - */ - selectedCustomerId?: string | null | undefined; - /** - * List of customer options from the list of customer records on the accounting software. - */ - customerOptions?: Array | null | undefined; + /** + * Selected customer id from the list of customer records on the accounting software. + */ + selectedCustomerId?: string | null | undefined; + /** + * List of customer options from the list of customer records on the accounting software. + */ + customerOptions?: Array | null | undefined; }; /** @internal */ -export const SalesCustomer$inboundSchema: z.ZodType = - z.object({ - selectedCustomerId: z.nullable(z.string()).optional(), - customerOptions: z.nullable(z.array(ConfigurationOption$inboundSchema)).optional(), - }); +export const SalesCustomer$inboundSchema: z.ZodType< + SalesCustomer, + z.ZodTypeDef, + unknown +> = z.object({ + selectedCustomerId: z.nullable(z.string()).optional(), + customerOptions: z.nullable(z.array(ConfigurationOption$inboundSchema)) + .optional(), +}); /** @internal */ export type SalesCustomer$Outbound = { - selectedCustomerId?: string | null | undefined; - customerOptions?: Array | null | undefined; + selectedCustomerId?: string | null | undefined; + customerOptions?: Array | null | undefined; }; /** @internal */ export const SalesCustomer$outboundSchema: z.ZodType< - SalesCustomer$Outbound, - z.ZodTypeDef, - SalesCustomer + SalesCustomer$Outbound, + z.ZodTypeDef, + SalesCustomer > = z.object({ - selectedCustomerId: z.nullable(z.string()).optional(), - customerOptions: z.nullable(z.array(ConfigurationOption$outboundSchema)).optional(), + selectedCustomerId: z.nullable(z.string()).optional(), + customerOptions: z.nullable(z.array(ConfigurationOption$outboundSchema)) + .optional(), }); /** @@ -49,10 +57,24 @@ export const SalesCustomer$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SalesCustomer$ { - /** @deprecated use `SalesCustomer$inboundSchema` instead. */ - export const inboundSchema = SalesCustomer$inboundSchema; - /** @deprecated use `SalesCustomer$outboundSchema` instead. */ - export const outboundSchema = SalesCustomer$outboundSchema; - /** @deprecated use `SalesCustomer$Outbound` instead. */ - export type Outbound = SalesCustomer$Outbound; + /** @deprecated use `SalesCustomer$inboundSchema` instead. */ + export const inboundSchema = SalesCustomer$inboundSchema; + /** @deprecated use `SalesCustomer$outboundSchema` instead. */ + export const outboundSchema = SalesCustomer$outboundSchema; + /** @deprecated use `SalesCustomer$Outbound` instead. */ + export type Outbound = SalesCustomer$Outbound; +} + +export function salesCustomerToJSON(salesCustomer: SalesCustomer): string { + return JSON.stringify(SalesCustomer$outboundSchema.parse(salesCustomer)); +} + +export function salesCustomerFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SalesCustomer$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SalesCustomer' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/security.ts b/sync-for-commerce/src/sdk/models/shared/security.ts index 8c77eac06..072d578cf 100644 --- a/sync-for-commerce/src/sdk/models/shared/security.ts +++ b/sync-for-commerce/src/sdk/models/shared/security.ts @@ -1,50 +1,71 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { remap as remap$ } from "../../../lib/primitives.js"; import * as z from "zod"; +import { remap as remap$ } from "../../../lib/primitives.js"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type Security = { - authHeader: string; + authHeader: string; }; /** @internal */ -export const Security$inboundSchema: z.ZodType = z - .object({ - auth_header: z.string(), - }) - .transform((v) => { - return remap$(v, { - auth_header: "authHeader", - }); - }); +export const Security$inboundSchema: z.ZodType< + Security, + z.ZodTypeDef, + unknown +> = z.object({ + auth_header: z.string(), +}).transform((v) => { + return remap$(v, { + "auth_header": "authHeader", + }); +}); /** @internal */ export type Security$Outbound = { - auth_header: string; + auth_header: string; }; /** @internal */ -export const Security$outboundSchema: z.ZodType = z - .object({ - authHeader: z.string(), - }) - .transform((v) => { - return remap$(v, { - authHeader: "auth_header", - }); - }); +export const Security$outboundSchema: z.ZodType< + Security$Outbound, + z.ZodTypeDef, + Security +> = z.object({ + authHeader: z.string(), +}).transform((v) => { + return remap$(v, { + authHeader: "auth_header", + }); +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Security$ { - /** @deprecated use `Security$inboundSchema` instead. */ - export const inboundSchema = Security$inboundSchema; - /** @deprecated use `Security$outboundSchema` instead. */ - export const outboundSchema = Security$outboundSchema; - /** @deprecated use `Security$Outbound` instead. */ - export type Outbound = Security$Outbound; + /** @deprecated use `Security$inboundSchema` instead. */ + export const inboundSchema = Security$inboundSchema; + /** @deprecated use `Security$outboundSchema` instead. */ + export const outboundSchema = Security$outboundSchema; + /** @deprecated use `Security$Outbound` instead. */ + export type Outbound = Security$Outbound; +} + +export function securityToJSON(security: Security): string { + return JSON.stringify(Security$outboundSchema.parse(security)); +} + +export function securityFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Security$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Security' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/sourcetype.ts b/sync-for-commerce/src/sdk/models/shared/sourcetype.ts index 939030fd4..1d75a0a3e 100644 --- a/sync-for-commerce/src/sdk/models/shared/sourcetype.ts +++ b/sync-for-commerce/src/sdk/models/shared/sourcetype.ts @@ -1,21 +1,21 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ClosedEnum } from "../../types/enums.js"; import * as z from "zod"; +import { ClosedEnum } from "../../types/enums.js"; /** * The type of platform of the connection. */ export const SourceType = { - Accounting: "Accounting", - Banking: "Banking", - BankFeed: "BankFeed", - Commerce: "Commerce", - Expense: "Expense", - Other: "Other", - Unknown: "Unknown", + Accounting: "Accounting", + Banking: "Banking", + BankFeed: "BankFeed", + Commerce: "Commerce", + Expense: "Expense", + Other: "Other", + Unknown: "Unknown", } as const; /** * The type of platform of the connection. @@ -23,20 +23,20 @@ export const SourceType = { export type SourceType = ClosedEnum; /** @internal */ -export const SourceType$inboundSchema: z.ZodNativeEnum = - z.nativeEnum(SourceType); +export const SourceType$inboundSchema: z.ZodNativeEnum = z + .nativeEnum(SourceType); /** @internal */ export const SourceType$outboundSchema: z.ZodNativeEnum = - SourceType$inboundSchema; + SourceType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SourceType$ { - /** @deprecated use `SourceType$inboundSchema` instead. */ - export const inboundSchema = SourceType$inboundSchema; - /** @deprecated use `SourceType$outboundSchema` instead. */ - export const outboundSchema = SourceType$outboundSchema; + /** @deprecated use `SourceType$inboundSchema` instead. */ + export const inboundSchema = SourceType$inboundSchema; + /** @deprecated use `SourceType$outboundSchema` instead. */ + export const outboundSchema = SourceType$outboundSchema; } diff --git a/sync-for-commerce/src/sdk/models/shared/supportedfeature.ts b/sync-for-commerce/src/sdk/models/shared/supportedfeature.ts index a0784647c..366980be4 100644 --- a/sync-for-commerce/src/sdk/models/shared/supportedfeature.ts +++ b/sync-for-commerce/src/sdk/models/shared/supportedfeature.ts @@ -1,51 +1,57 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - FeatureState, - FeatureState$inboundSchema, - FeatureState$outboundSchema, + FeatureState, + FeatureState$inboundSchema, + FeatureState$outboundSchema, } from "./featurestate.js"; import { - FeatureType, - FeatureType$inboundSchema, - FeatureType$outboundSchema, + FeatureType, + FeatureType$inboundSchema, + FeatureType$outboundSchema, } from "./featuretype.js"; -import * as z from "zod"; export type SupportedFeature = { - /** - * The type of feature. - */ - featureType: FeatureType; - /** - * The current release state of the feature. - */ - featureState: FeatureState; + /** + * The type of feature. + */ + featureType: FeatureType; + /** + * The current release state of the feature. + */ + featureState: FeatureState; }; /** @internal */ -export const SupportedFeature$inboundSchema: z.ZodType = - z.object({ - featureType: FeatureType$inboundSchema, - featureState: FeatureState$inboundSchema, - }); +export const SupportedFeature$inboundSchema: z.ZodType< + SupportedFeature, + z.ZodTypeDef, + unknown +> = z.object({ + featureType: FeatureType$inboundSchema, + featureState: FeatureState$inboundSchema, +}); /** @internal */ export type SupportedFeature$Outbound = { - featureType: string; - featureState: string; + featureType: string; + featureState: string; }; /** @internal */ export const SupportedFeature$outboundSchema: z.ZodType< - SupportedFeature$Outbound, - z.ZodTypeDef, - SupportedFeature + SupportedFeature$Outbound, + z.ZodTypeDef, + SupportedFeature > = z.object({ - featureType: FeatureType$outboundSchema, - featureState: FeatureState$outboundSchema, + featureType: FeatureType$outboundSchema, + featureState: FeatureState$outboundSchema, }); /** @@ -53,10 +59,28 @@ export const SupportedFeature$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SupportedFeature$ { - /** @deprecated use `SupportedFeature$inboundSchema` instead. */ - export const inboundSchema = SupportedFeature$inboundSchema; - /** @deprecated use `SupportedFeature$outboundSchema` instead. */ - export const outboundSchema = SupportedFeature$outboundSchema; - /** @deprecated use `SupportedFeature$Outbound` instead. */ - export type Outbound = SupportedFeature$Outbound; + /** @deprecated use `SupportedFeature$inboundSchema` instead. */ + export const inboundSchema = SupportedFeature$inboundSchema; + /** @deprecated use `SupportedFeature$outboundSchema` instead. */ + export const outboundSchema = SupportedFeature$outboundSchema; + /** @deprecated use `SupportedFeature$Outbound` instead. */ + export type Outbound = SupportedFeature$Outbound; +} + +export function supportedFeatureToJSON( + supportedFeature: SupportedFeature, +): string { + return JSON.stringify( + SupportedFeature$outboundSchema.parse(supportedFeature), + ); +} + +export function supportedFeatureFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SupportedFeature$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SupportedFeature' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/syncconnectiondeletedwebhook.ts b/sync-for-commerce/src/sdk/models/shared/syncconnectiondeletedwebhook.ts index 78ba30f3f..b6063fe54 100644 --- a/sync-for-commerce/src/sdk/models/shared/syncconnectiondeletedwebhook.ts +++ b/sync-for-commerce/src/sdk/models/shared/syncconnectiondeletedwebhook.ts @@ -1,120 +1,139 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { remap as remap$ } from "../../../lib/primitives.js"; import * as z from "zod"; +import { remap as remap$ } from "../../../lib/primitives.js"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * A Sync for Commerce connection is deleted. */ export type SyncConnectionDeletedWebhook = { - /** - * Unique identifier for your client in Codat. - */ - clientId?: string | undefined; - /** - * Name of your client in Codat. - */ - clientName?: string | undefined; - /** - * Unique identifier for your SMB in Codat. - */ - companyId?: string | undefined; - /** - * Unique identifier for the rule. - * - * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. - */ - ruleId?: string | undefined; - /** - * The type of rule. - */ - ruleType?: string | undefined; - /** - * Unique identifier of the webhook event. - */ - alertId?: string | undefined; - /** - * A human-readable message about the webhook. - */ - message?: string | undefined; + /** + * Unique identifier for your client in Codat. + */ + clientId?: string | undefined; + /** + * Name of your client in Codat. + */ + clientName?: string | undefined; + /** + * Unique identifier for your SMB in Codat. + */ + companyId?: string | undefined; + /** + * Unique identifier for the rule. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + ruleId?: string | undefined; + /** + * The type of rule. + */ + ruleType?: string | undefined; + /** + * Unique identifier of the webhook event. + */ + alertId?: string | undefined; + /** + * A human-readable message about the webhook. + */ + message?: string | undefined; }; /** @internal */ export const SyncConnectionDeletedWebhook$inboundSchema: z.ZodType< - SyncConnectionDeletedWebhook, - z.ZodTypeDef, - unknown -> = z - .object({ - ClientId: z.string().optional(), - ClientName: z.string().optional(), - CompanyId: z.string().optional(), - RuleId: z.string().optional(), - RuleType: z.string().optional(), - AlertId: z.string().optional(), - Message: z.string().optional(), - }) - .transform((v) => { - return remap$(v, { - ClientId: "clientId", - ClientName: "clientName", - CompanyId: "companyId", - RuleId: "ruleId", - RuleType: "ruleType", - AlertId: "alertId", - Message: "message", - }); - }); + SyncConnectionDeletedWebhook, + z.ZodTypeDef, + unknown +> = z.object({ + ClientId: z.string().optional(), + ClientName: z.string().optional(), + CompanyId: z.string().optional(), + RuleId: z.string().optional(), + RuleType: z.string().optional(), + AlertId: z.string().optional(), + Message: z.string().optional(), +}).transform((v) => { + return remap$(v, { + "ClientId": "clientId", + "ClientName": "clientName", + "CompanyId": "companyId", + "RuleId": "ruleId", + "RuleType": "ruleType", + "AlertId": "alertId", + "Message": "message", + }); +}); /** @internal */ export type SyncConnectionDeletedWebhook$Outbound = { - ClientId?: string | undefined; - ClientName?: string | undefined; - CompanyId?: string | undefined; - RuleId?: string | undefined; - RuleType?: string | undefined; - AlertId?: string | undefined; - Message?: string | undefined; + ClientId?: string | undefined; + ClientName?: string | undefined; + CompanyId?: string | undefined; + RuleId?: string | undefined; + RuleType?: string | undefined; + AlertId?: string | undefined; + Message?: string | undefined; }; /** @internal */ export const SyncConnectionDeletedWebhook$outboundSchema: z.ZodType< - SyncConnectionDeletedWebhook$Outbound, - z.ZodTypeDef, - SyncConnectionDeletedWebhook -> = z - .object({ - clientId: z.string().optional(), - clientName: z.string().optional(), - companyId: z.string().optional(), - ruleId: z.string().optional(), - ruleType: z.string().optional(), - alertId: z.string().optional(), - message: z.string().optional(), - }) - .transform((v) => { - return remap$(v, { - clientId: "ClientId", - clientName: "ClientName", - companyId: "CompanyId", - ruleId: "RuleId", - ruleType: "RuleType", - alertId: "AlertId", - message: "Message", - }); - }); + SyncConnectionDeletedWebhook$Outbound, + z.ZodTypeDef, + SyncConnectionDeletedWebhook +> = z.object({ + clientId: z.string().optional(), + clientName: z.string().optional(), + companyId: z.string().optional(), + ruleId: z.string().optional(), + ruleType: z.string().optional(), + alertId: z.string().optional(), + message: z.string().optional(), +}).transform((v) => { + return remap$(v, { + clientId: "ClientId", + clientName: "ClientName", + companyId: "CompanyId", + ruleId: "RuleId", + ruleType: "RuleType", + alertId: "AlertId", + message: "Message", + }); +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SyncConnectionDeletedWebhook$ { - /** @deprecated use `SyncConnectionDeletedWebhook$inboundSchema` instead. */ - export const inboundSchema = SyncConnectionDeletedWebhook$inboundSchema; - /** @deprecated use `SyncConnectionDeletedWebhook$outboundSchema` instead. */ - export const outboundSchema = SyncConnectionDeletedWebhook$outboundSchema; - /** @deprecated use `SyncConnectionDeletedWebhook$Outbound` instead. */ - export type Outbound = SyncConnectionDeletedWebhook$Outbound; + /** @deprecated use `SyncConnectionDeletedWebhook$inboundSchema` instead. */ + export const inboundSchema = SyncConnectionDeletedWebhook$inboundSchema; + /** @deprecated use `SyncConnectionDeletedWebhook$outboundSchema` instead. */ + export const outboundSchema = SyncConnectionDeletedWebhook$outboundSchema; + /** @deprecated use `SyncConnectionDeletedWebhook$Outbound` instead. */ + export type Outbound = SyncConnectionDeletedWebhook$Outbound; +} + +export function syncConnectionDeletedWebhookToJSON( + syncConnectionDeletedWebhook: SyncConnectionDeletedWebhook, +): string { + return JSON.stringify( + SyncConnectionDeletedWebhook$outboundSchema.parse( + syncConnectionDeletedWebhook, + ), + ); +} + +export function syncConnectionDeletedWebhookFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SyncConnectionDeletedWebhook$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SyncConnectionDeletedWebhook' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/syncflowurl.ts b/sync-for-commerce/src/sdk/models/shared/syncflowurl.ts index 740ee4f30..ddc95932a 100644 --- a/sync-for-commerce/src/sdk/models/shared/syncflowurl.ts +++ b/sync-for-commerce/src/sdk/models/shared/syncflowurl.ts @@ -1,33 +1,40 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type SyncFlowUrl = { - /** - * Sync flow URL. - */ - url?: string | undefined; + /** + * Sync flow URL. + */ + url?: string | undefined; }; /** @internal */ -export const SyncFlowUrl$inboundSchema: z.ZodType = z.object({ - url: z.string().optional(), +export const SyncFlowUrl$inboundSchema: z.ZodType< + SyncFlowUrl, + z.ZodTypeDef, + unknown +> = z.object({ + url: z.string().optional(), }); /** @internal */ export type SyncFlowUrl$Outbound = { - url?: string | undefined; + url?: string | undefined; }; /** @internal */ export const SyncFlowUrl$outboundSchema: z.ZodType< - SyncFlowUrl$Outbound, - z.ZodTypeDef, - SyncFlowUrl + SyncFlowUrl$Outbound, + z.ZodTypeDef, + SyncFlowUrl > = z.object({ - url: z.string().optional(), + url: z.string().optional(), }); /** @@ -35,10 +42,24 @@ export const SyncFlowUrl$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SyncFlowUrl$ { - /** @deprecated use `SyncFlowUrl$inboundSchema` instead. */ - export const inboundSchema = SyncFlowUrl$inboundSchema; - /** @deprecated use `SyncFlowUrl$outboundSchema` instead. */ - export const outboundSchema = SyncFlowUrl$outboundSchema; - /** @deprecated use `SyncFlowUrl$Outbound` instead. */ - export type Outbound = SyncFlowUrl$Outbound; + /** @deprecated use `SyncFlowUrl$inboundSchema` instead. */ + export const inboundSchema = SyncFlowUrl$inboundSchema; + /** @deprecated use `SyncFlowUrl$outboundSchema` instead. */ + export const outboundSchema = SyncFlowUrl$outboundSchema; + /** @deprecated use `SyncFlowUrl$Outbound` instead. */ + export type Outbound = SyncFlowUrl$Outbound; +} + +export function syncFlowUrlToJSON(syncFlowUrl: SyncFlowUrl): string { + return JSON.stringify(SyncFlowUrl$outboundSchema.parse(syncFlowUrl)); +} + +export function syncFlowUrlFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SyncFlowUrl$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SyncFlowUrl' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/syncfrequency.ts b/sync-for-commerce/src/sdk/models/shared/syncfrequency.ts index fd5af749a..fd6e3a92e 100644 --- a/sync-for-commerce/src/sdk/models/shared/syncfrequency.ts +++ b/sync-for-commerce/src/sdk/models/shared/syncfrequency.ts @@ -1,16 +1,16 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ClosedEnum } from "../../types/enums.js"; import * as z from "zod"; +import { ClosedEnum } from "../../types/enums.js"; /** * The frequency in which you want data to be synced. */ export const SyncFrequency = { - Daily: "Daily", - Monthly: "Monthly", + Daily: "Daily", + Monthly: "Monthly", } as const; /** * The frequency in which you want data to be synced. @@ -18,20 +18,22 @@ export const SyncFrequency = { export type SyncFrequency = ClosedEnum; /** @internal */ -export const SyncFrequency$inboundSchema: z.ZodNativeEnum = - z.nativeEnum(SyncFrequency); +export const SyncFrequency$inboundSchema: z.ZodNativeEnum< + typeof SyncFrequency +> = z.nativeEnum(SyncFrequency); /** @internal */ -export const SyncFrequency$outboundSchema: z.ZodNativeEnum = - SyncFrequency$inboundSchema; +export const SyncFrequency$outboundSchema: z.ZodNativeEnum< + typeof SyncFrequency +> = SyncFrequency$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SyncFrequency$ { - /** @deprecated use `SyncFrequency$inboundSchema` instead. */ - export const inboundSchema = SyncFrequency$inboundSchema; - /** @deprecated use `SyncFrequency$outboundSchema` instead. */ - export const outboundSchema = SyncFrequency$outboundSchema; + /** @deprecated use `SyncFrequency$inboundSchema` instead. */ + export const inboundSchema = SyncFrequency$inboundSchema; + /** @deprecated use `SyncFrequency$outboundSchema` instead. */ + export const outboundSchema = SyncFrequency$outboundSchema; } diff --git a/sync-for-commerce/src/sdk/models/shared/syncrange.ts b/sync-for-commerce/src/sdk/models/shared/syncrange.ts index 6ae7bc2a9..767e50c39 100644 --- a/sync-for-commerce/src/sdk/models/shared/syncrange.ts +++ b/sync-for-commerce/src/sdk/models/shared/syncrange.ts @@ -1,121 +1,162 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type DateRange = { - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - start: string; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - finish: string; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + start: string; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + finish: string; }; export type SyncRange = { - dateRange: DateRange; + dateRange: DateRange; }; /** @internal */ -export const DateRange$inboundSchema: z.ZodType = z.object({ - start: z.string(), - finish: z.string(), +export const DateRange$inboundSchema: z.ZodType< + DateRange, + z.ZodTypeDef, + unknown +> = z.object({ + start: z.string(), + finish: z.string(), }); /** @internal */ export type DateRange$Outbound = { - start: string; - finish: string; + start: string; + finish: string; }; /** @internal */ -export const DateRange$outboundSchema: z.ZodType = - z.object({ - start: z.string(), - finish: z.string(), - }); +export const DateRange$outboundSchema: z.ZodType< + DateRange$Outbound, + z.ZodTypeDef, + DateRange +> = z.object({ + start: z.string(), + finish: z.string(), +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace DateRange$ { - /** @deprecated use `DateRange$inboundSchema` instead. */ - export const inboundSchema = DateRange$inboundSchema; - /** @deprecated use `DateRange$outboundSchema` instead. */ - export const outboundSchema = DateRange$outboundSchema; - /** @deprecated use `DateRange$Outbound` instead. */ - export type Outbound = DateRange$Outbound; + /** @deprecated use `DateRange$inboundSchema` instead. */ + export const inboundSchema = DateRange$inboundSchema; + /** @deprecated use `DateRange$outboundSchema` instead. */ + export const outboundSchema = DateRange$outboundSchema; + /** @deprecated use `DateRange$Outbound` instead. */ + export type Outbound = DateRange$Outbound; +} + +export function dateRangeToJSON(dateRange: DateRange): string { + return JSON.stringify(DateRange$outboundSchema.parse(dateRange)); +} + +export function dateRangeFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DateRange$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DateRange' from JSON`, + ); } /** @internal */ -export const SyncRange$inboundSchema: z.ZodType = z.object({ - dateRange: z.lazy(() => DateRange$inboundSchema), +export const SyncRange$inboundSchema: z.ZodType< + SyncRange, + z.ZodTypeDef, + unknown +> = z.object({ + dateRange: z.lazy(() => DateRange$inboundSchema), }); /** @internal */ export type SyncRange$Outbound = { - dateRange: DateRange$Outbound; + dateRange: DateRange$Outbound; }; /** @internal */ -export const SyncRange$outboundSchema: z.ZodType = - z.object({ - dateRange: z.lazy(() => DateRange$outboundSchema), - }); +export const SyncRange$outboundSchema: z.ZodType< + SyncRange$Outbound, + z.ZodTypeDef, + SyncRange +> = z.object({ + dateRange: z.lazy(() => DateRange$outboundSchema), +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SyncRange$ { - /** @deprecated use `SyncRange$inboundSchema` instead. */ - export const inboundSchema = SyncRange$inboundSchema; - /** @deprecated use `SyncRange$outboundSchema` instead. */ - export const outboundSchema = SyncRange$outboundSchema; - /** @deprecated use `SyncRange$Outbound` instead. */ - export type Outbound = SyncRange$Outbound; + /** @deprecated use `SyncRange$inboundSchema` instead. */ + export const inboundSchema = SyncRange$inboundSchema; + /** @deprecated use `SyncRange$outboundSchema` instead. */ + export const outboundSchema = SyncRange$outboundSchema; + /** @deprecated use `SyncRange$Outbound` instead. */ + export type Outbound = SyncRange$Outbound; +} + +export function syncRangeToJSON(syncRange: SyncRange): string { + return JSON.stringify(SyncRange$outboundSchema.parse(syncRange)); +} + +export function syncRangeFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SyncRange$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SyncRange' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/syncschedule.ts b/sync-for-commerce/src/sdk/models/shared/syncschedule.ts index b3a9e688d..67e253383 100644 --- a/sync-for-commerce/src/sdk/models/shared/syncschedule.ts +++ b/sync-for-commerce/src/sdk/models/shared/syncschedule.ts @@ -1,83 +1,88 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - SyncFrequency, - SyncFrequency$inboundSchema, - SyncFrequency$outboundSchema, + SyncFrequency, + SyncFrequency$inboundSchema, + SyncFrequency$outboundSchema, } from "./syncfrequency.js"; -import * as z from "zod"; export type SyncSchedule = { - /** - * The frequency in which you want data to be synced. - */ - selectedFrequency?: SyncFrequency | undefined; - frequencyOptions?: Array | undefined; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - startDate?: string | undefined; - /** - * The hour you want to trigger a sync. - */ - syncHour?: number | undefined; - /** - * The timezone for the company. - */ - timeZone?: string | undefined; + /** + * The frequency in which you want data to be synced. + */ + selectedFrequency?: SyncFrequency | undefined; + frequencyOptions?: Array | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + startDate?: string | undefined; + /** + * The hour you want to trigger a sync. + */ + syncHour?: number | undefined; + /** + * The timezone for the company. + */ + timeZone?: string | undefined; }; /** @internal */ -export const SyncSchedule$inboundSchema: z.ZodType = z.object({ - selectedFrequency: SyncFrequency$inboundSchema.optional(), - frequencyOptions: z.array(SyncFrequency$inboundSchema).optional(), - startDate: z.string().optional(), - syncHour: z.number().int().optional(), - timeZone: z.string().optional(), +export const SyncSchedule$inboundSchema: z.ZodType< + SyncSchedule, + z.ZodTypeDef, + unknown +> = z.object({ + selectedFrequency: SyncFrequency$inboundSchema.optional(), + frequencyOptions: z.array(SyncFrequency$inboundSchema).optional(), + startDate: z.string().optional(), + syncHour: z.number().int().optional(), + timeZone: z.string().optional(), }); /** @internal */ export type SyncSchedule$Outbound = { - selectedFrequency?: string | undefined; - frequencyOptions?: Array | undefined; - startDate?: string | undefined; - syncHour?: number | undefined; - timeZone?: string | undefined; + selectedFrequency?: string | undefined; + frequencyOptions?: Array | undefined; + startDate?: string | undefined; + syncHour?: number | undefined; + timeZone?: string | undefined; }; /** @internal */ export const SyncSchedule$outboundSchema: z.ZodType< - SyncSchedule$Outbound, - z.ZodTypeDef, - SyncSchedule + SyncSchedule$Outbound, + z.ZodTypeDef, + SyncSchedule > = z.object({ - selectedFrequency: SyncFrequency$outboundSchema.optional(), - frequencyOptions: z.array(SyncFrequency$outboundSchema).optional(), - startDate: z.string().optional(), - syncHour: z.number().int().optional(), - timeZone: z.string().optional(), + selectedFrequency: SyncFrequency$outboundSchema.optional(), + frequencyOptions: z.array(SyncFrequency$outboundSchema).optional(), + startDate: z.string().optional(), + syncHour: z.number().int().optional(), + timeZone: z.string().optional(), }); /** @@ -85,10 +90,24 @@ export const SyncSchedule$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SyncSchedule$ { - /** @deprecated use `SyncSchedule$inboundSchema` instead. */ - export const inboundSchema = SyncSchedule$inboundSchema; - /** @deprecated use `SyncSchedule$outboundSchema` instead. */ - export const outboundSchema = SyncSchedule$outboundSchema; - /** @deprecated use `SyncSchedule$Outbound` instead. */ - export type Outbound = SyncSchedule$Outbound; + /** @deprecated use `SyncSchedule$inboundSchema` instead. */ + export const inboundSchema = SyncSchedule$inboundSchema; + /** @deprecated use `SyncSchedule$outboundSchema` instead. */ + export const outboundSchema = SyncSchedule$outboundSchema; + /** @deprecated use `SyncSchedule$Outbound` instead. */ + export type Outbound = SyncSchedule$Outbound; +} + +export function syncScheduleToJSON(syncSchedule: SyncSchedule): string { + return JSON.stringify(SyncSchedule$outboundSchema.parse(syncSchedule)); +} + +export function syncScheduleFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SyncSchedule$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SyncSchedule' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/syncstatus.ts b/sync-for-commerce/src/sdk/models/shared/syncstatus.ts index 8f8240e5f..956851e13 100644 --- a/sync-for-commerce/src/sdk/models/shared/syncstatus.ts +++ b/sync-for-commerce/src/sdk/models/shared/syncstatus.ts @@ -1,130 +1,152 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - Connection, - Connection$inboundSchema, - Connection$Outbound, - Connection$outboundSchema, + Connection, + Connection$inboundSchema, + Connection$Outbound, + Connection$outboundSchema, } from "./connection.js"; -import * as z from "zod"; /** * The status of syncing for a company and its connections. */ export type SyncStatus = { - companyId?: any | undefined; - /** - * Unique identifier for the sync in Codat. - */ - commerceSyncId?: string | undefined; - /** - * Unique identifier for the sync in Codat. - */ - syncId?: string | undefined; - /** - * Numerical status code sync of the company data. - */ - syncStatusCode?: number | undefined; - /** - * Status of the sync of the company data. This is linked to status code. - */ - syncStatus?: string | null | undefined; - /** - * Friendly error message for the sync operation. - */ - errorMessage?: string | null | undefined; - /** - * Exception message for the sync operation. - */ - syncExceptionMessage?: string | null | undefined; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - syncUtc?: string | undefined; - /** - * Boolean indicator for data being pushed during a sync operation. - */ - dataPushed?: boolean | undefined; - /** - * Array of containing objects data connection information for the company. - */ - dataConnections?: Array | null | undefined; + companyId?: any | undefined; + /** + * Unique identifier for the sync in Codat. + */ + commerceSyncId?: string | undefined; + /** + * Unique identifier for the sync in Codat. + */ + syncId?: string | undefined; + /** + * Numerical status code sync of the company data. + */ + syncStatusCode?: number | undefined; + /** + * Status of the sync of the company data. This is linked to status code. + */ + syncStatus?: string | null | undefined; + /** + * Friendly error message for the sync operation. + */ + errorMessage?: string | null | undefined; + /** + * Exception message for the sync operation. + */ + syncExceptionMessage?: string | null | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + syncUtc?: string | undefined; + /** + * Boolean indicator for data being pushed during a sync operation. + */ + dataPushed?: boolean | undefined; + /** + * Array of containing objects data connection information for the company. + */ + dataConnections?: Array | null | undefined; }; /** @internal */ -export const SyncStatus$inboundSchema: z.ZodType = z.object({ - companyId: z.any().optional(), - commerceSyncId: z.string().optional(), - syncId: z.string().optional(), - syncStatusCode: z.number().int().optional(), - syncStatus: z.nullable(z.string()).optional(), - errorMessage: z.nullable(z.string()).optional(), - syncExceptionMessage: z.nullable(z.string()).optional(), - syncUtc: z.string().optional(), - dataPushed: z.boolean().optional(), - dataConnections: z.nullable(z.array(Connection$inboundSchema)).optional(), +export const SyncStatus$inboundSchema: z.ZodType< + SyncStatus, + z.ZodTypeDef, + unknown +> = z.object({ + companyId: z.any().optional(), + commerceSyncId: z.string().optional(), + syncId: z.string().optional(), + syncStatusCode: z.number().int().optional(), + syncStatus: z.nullable(z.string()).optional(), + errorMessage: z.nullable(z.string()).optional(), + syncExceptionMessage: z.nullable(z.string()).optional(), + syncUtc: z.string().optional(), + dataPushed: z.boolean().optional(), + dataConnections: z.nullable(z.array(Connection$inboundSchema)).optional(), }); /** @internal */ export type SyncStatus$Outbound = { - companyId?: any | undefined; - commerceSyncId?: string | undefined; - syncId?: string | undefined; - syncStatusCode?: number | undefined; - syncStatus?: string | null | undefined; - errorMessage?: string | null | undefined; - syncExceptionMessage?: string | null | undefined; - syncUtc?: string | undefined; - dataPushed?: boolean | undefined; - dataConnections?: Array | null | undefined; + companyId?: any | undefined; + commerceSyncId?: string | undefined; + syncId?: string | undefined; + syncStatusCode?: number | undefined; + syncStatus?: string | null | undefined; + errorMessage?: string | null | undefined; + syncExceptionMessage?: string | null | undefined; + syncUtc?: string | undefined; + dataPushed?: boolean | undefined; + dataConnections?: Array | null | undefined; }; /** @internal */ -export const SyncStatus$outboundSchema: z.ZodType = - z.object({ - companyId: z.any().optional(), - commerceSyncId: z.string().optional(), - syncId: z.string().optional(), - syncStatusCode: z.number().int().optional(), - syncStatus: z.nullable(z.string()).optional(), - errorMessage: z.nullable(z.string()).optional(), - syncExceptionMessage: z.nullable(z.string()).optional(), - syncUtc: z.string().optional(), - dataPushed: z.boolean().optional(), - dataConnections: z.nullable(z.array(Connection$outboundSchema)).optional(), - }); +export const SyncStatus$outboundSchema: z.ZodType< + SyncStatus$Outbound, + z.ZodTypeDef, + SyncStatus +> = z.object({ + companyId: z.any().optional(), + commerceSyncId: z.string().optional(), + syncId: z.string().optional(), + syncStatusCode: z.number().int().optional(), + syncStatus: z.nullable(z.string()).optional(), + errorMessage: z.nullable(z.string()).optional(), + syncExceptionMessage: z.nullable(z.string()).optional(), + syncUtc: z.string().optional(), + dataPushed: z.boolean().optional(), + dataConnections: z.nullable(z.array(Connection$outboundSchema)).optional(), +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SyncStatus$ { - /** @deprecated use `SyncStatus$inboundSchema` instead. */ - export const inboundSchema = SyncStatus$inboundSchema; - /** @deprecated use `SyncStatus$outboundSchema` instead. */ - export const outboundSchema = SyncStatus$outboundSchema; - /** @deprecated use `SyncStatus$Outbound` instead. */ - export type Outbound = SyncStatus$Outbound; + /** @deprecated use `SyncStatus$inboundSchema` instead. */ + export const inboundSchema = SyncStatus$inboundSchema; + /** @deprecated use `SyncStatus$outboundSchema` instead. */ + export const outboundSchema = SyncStatus$outboundSchema; + /** @deprecated use `SyncStatus$Outbound` instead. */ + export type Outbound = SyncStatus$Outbound; +} + +export function syncStatusToJSON(syncStatus: SyncStatus): string { + return JSON.stringify(SyncStatus$outboundSchema.parse(syncStatus)); +} + +export function syncStatusFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SyncStatus$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SyncStatus' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/syncsummary.ts b/sync-for-commerce/src/sdk/models/shared/syncsummary.ts index 1701f78b3..a303159f4 100644 --- a/sync-for-commerce/src/sdk/models/shared/syncsummary.ts +++ b/sync-for-commerce/src/sdk/models/shared/syncsummary.ts @@ -1,147 +1,147 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - Connection, - Connection$inboundSchema, - Connection$Outbound, - Connection$outboundSchema, + Connection, + Connection$inboundSchema, + Connection$Outbound, + Connection$outboundSchema, } from "./connection.js"; -import * as z from "zod"; export type SyncDateRangeUtc = { - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - start?: string | undefined; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - finish?: string | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + start?: string | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + finish?: string | undefined; }; export type SyncSummary = { - syncDateRangeUtc?: SyncDateRangeUtc | undefined; - /** - * Unique identifier for your SMB in Codat. - */ - companyId?: string | undefined; - /** - * Unique identifier for the sync in Codat. - */ - commerceSyncId?: string | undefined; - /** - * Numerical status code sync of the company data. - */ - syncStatusCode?: number | undefined; - /** - * Status of the sync of the company data. This is linked to status code. - */ - syncStatus?: string | null | undefined; - /** - * Friendly error message for the sync operation. - */ - errorMessage?: string | null | undefined; - /** - * Exception message for the sync operation. - */ - syncExceptionMessage?: string | null | undefined; - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - syncUtc?: string | undefined; - /** - * Array of containing objects data connection information for the company. - */ - dataConnections?: Array | null | undefined; - /** - * Boolean indicator for data being pushed during a sync operation. - */ - dataPushed?: boolean | undefined; + syncDateRangeUtc?: SyncDateRangeUtc | undefined; + /** + * Unique identifier for your SMB in Codat. + */ + companyId?: string | undefined; + /** + * Unique identifier for the sync in Codat. + */ + commerceSyncId?: string | undefined; + /** + * Numerical status code sync of the company data. + */ + syncStatusCode?: number | undefined; + /** + * Status of the sync of the company data. This is linked to status code. + */ + syncStatus?: string | null | undefined; + /** + * Friendly error message for the sync operation. + */ + errorMessage?: string | null | undefined; + /** + * Exception message for the sync operation. + */ + syncExceptionMessage?: string | null | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + syncUtc?: string | undefined; + /** + * Array of containing objects data connection information for the company. + */ + dataConnections?: Array | null | undefined; + /** + * Boolean indicator for data being pushed during a sync operation. + */ + dataPushed?: boolean | undefined; }; /** @internal */ -export const SyncDateRangeUtc$inboundSchema: z.ZodType = - z.object({ - start: z.string().optional(), - finish: z.string().optional(), - }); +export const SyncDateRangeUtc$inboundSchema: z.ZodType< + SyncDateRangeUtc, + z.ZodTypeDef, + unknown +> = z.object({ + start: z.string().optional(), + finish: z.string().optional(), +}); /** @internal */ export type SyncDateRangeUtc$Outbound = { - start?: string | undefined; - finish?: string | undefined; + start?: string | undefined; + finish?: string | undefined; }; /** @internal */ export const SyncDateRangeUtc$outboundSchema: z.ZodType< - SyncDateRangeUtc$Outbound, - z.ZodTypeDef, - SyncDateRangeUtc + SyncDateRangeUtc$Outbound, + z.ZodTypeDef, + SyncDateRangeUtc > = z.object({ - start: z.string().optional(), - finish: z.string().optional(), + start: z.string().optional(), + finish: z.string().optional(), }); /** @@ -149,58 +149,80 @@ export const SyncDateRangeUtc$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SyncDateRangeUtc$ { - /** @deprecated use `SyncDateRangeUtc$inboundSchema` instead. */ - export const inboundSchema = SyncDateRangeUtc$inboundSchema; - /** @deprecated use `SyncDateRangeUtc$outboundSchema` instead. */ - export const outboundSchema = SyncDateRangeUtc$outboundSchema; - /** @deprecated use `SyncDateRangeUtc$Outbound` instead. */ - export type Outbound = SyncDateRangeUtc$Outbound; + /** @deprecated use `SyncDateRangeUtc$inboundSchema` instead. */ + export const inboundSchema = SyncDateRangeUtc$inboundSchema; + /** @deprecated use `SyncDateRangeUtc$outboundSchema` instead. */ + export const outboundSchema = SyncDateRangeUtc$outboundSchema; + /** @deprecated use `SyncDateRangeUtc$Outbound` instead. */ + export type Outbound = SyncDateRangeUtc$Outbound; +} + +export function syncDateRangeUtcToJSON( + syncDateRangeUtc: SyncDateRangeUtc, +): string { + return JSON.stringify( + SyncDateRangeUtc$outboundSchema.parse(syncDateRangeUtc), + ); +} + +export function syncDateRangeUtcFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SyncDateRangeUtc$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SyncDateRangeUtc' from JSON`, + ); } /** @internal */ -export const SyncSummary$inboundSchema: z.ZodType = z.object({ - syncDateRangeUtc: z.lazy(() => SyncDateRangeUtc$inboundSchema).optional(), - companyId: z.string().optional(), - commerceSyncId: z.string().optional(), - syncStatusCode: z.number().int().optional(), - syncStatus: z.nullable(z.string()).optional(), - errorMessage: z.nullable(z.string()).optional(), - syncExceptionMessage: z.nullable(z.string()).optional(), - syncUtc: z.string().optional(), - dataConnections: z.nullable(z.array(Connection$inboundSchema)).optional(), - dataPushed: z.boolean().optional(), +export const SyncSummary$inboundSchema: z.ZodType< + SyncSummary, + z.ZodTypeDef, + unknown +> = z.object({ + syncDateRangeUtc: z.lazy(() => SyncDateRangeUtc$inboundSchema).optional(), + companyId: z.string().optional(), + commerceSyncId: z.string().optional(), + syncStatusCode: z.number().int().optional(), + syncStatus: z.nullable(z.string()).optional(), + errorMessage: z.nullable(z.string()).optional(), + syncExceptionMessage: z.nullable(z.string()).optional(), + syncUtc: z.string().optional(), + dataConnections: z.nullable(z.array(Connection$inboundSchema)).optional(), + dataPushed: z.boolean().optional(), }); /** @internal */ export type SyncSummary$Outbound = { - syncDateRangeUtc?: SyncDateRangeUtc$Outbound | undefined; - companyId?: string | undefined; - commerceSyncId?: string | undefined; - syncStatusCode?: number | undefined; - syncStatus?: string | null | undefined; - errorMessage?: string | null | undefined; - syncExceptionMessage?: string | null | undefined; - syncUtc?: string | undefined; - dataConnections?: Array | null | undefined; - dataPushed?: boolean | undefined; + syncDateRangeUtc?: SyncDateRangeUtc$Outbound | undefined; + companyId?: string | undefined; + commerceSyncId?: string | undefined; + syncStatusCode?: number | undefined; + syncStatus?: string | null | undefined; + errorMessage?: string | null | undefined; + syncExceptionMessage?: string | null | undefined; + syncUtc?: string | undefined; + dataConnections?: Array | null | undefined; + dataPushed?: boolean | undefined; }; /** @internal */ export const SyncSummary$outboundSchema: z.ZodType< - SyncSummary$Outbound, - z.ZodTypeDef, - SyncSummary + SyncSummary$Outbound, + z.ZodTypeDef, + SyncSummary > = z.object({ - syncDateRangeUtc: z.lazy(() => SyncDateRangeUtc$outboundSchema).optional(), - companyId: z.string().optional(), - commerceSyncId: z.string().optional(), - syncStatusCode: z.number().int().optional(), - syncStatus: z.nullable(z.string()).optional(), - errorMessage: z.nullable(z.string()).optional(), - syncExceptionMessage: z.nullable(z.string()).optional(), - syncUtc: z.string().optional(), - dataConnections: z.nullable(z.array(Connection$outboundSchema)).optional(), - dataPushed: z.boolean().optional(), + syncDateRangeUtc: z.lazy(() => SyncDateRangeUtc$outboundSchema).optional(), + companyId: z.string().optional(), + commerceSyncId: z.string().optional(), + syncStatusCode: z.number().int().optional(), + syncStatus: z.nullable(z.string()).optional(), + errorMessage: z.nullable(z.string()).optional(), + syncExceptionMessage: z.nullable(z.string()).optional(), + syncUtc: z.string().optional(), + dataConnections: z.nullable(z.array(Connection$outboundSchema)).optional(), + dataPushed: z.boolean().optional(), }); /** @@ -208,10 +230,24 @@ export const SyncSummary$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SyncSummary$ { - /** @deprecated use `SyncSummary$inboundSchema` instead. */ - export const inboundSchema = SyncSummary$inboundSchema; - /** @deprecated use `SyncSummary$outboundSchema` instead. */ - export const outboundSchema = SyncSummary$outboundSchema; - /** @deprecated use `SyncSummary$Outbound` instead. */ - export type Outbound = SyncSummary$Outbound; + /** @deprecated use `SyncSummary$inboundSchema` instead. */ + export const inboundSchema = SyncSummary$inboundSchema; + /** @deprecated use `SyncSummary$outboundSchema` instead. */ + export const outboundSchema = SyncSummary$outboundSchema; + /** @deprecated use `SyncSummary$Outbound` instead. */ + export type Outbound = SyncSummary$Outbound; +} + +export function syncSummaryToJSON(syncSummary: SyncSummary): string { + return JSON.stringify(SyncSummary$outboundSchema.parse(syncSummary)); +} + +export function syncSummaryFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SyncSummary$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SyncSummary' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/synctolatestargs.ts b/sync-for-commerce/src/sdk/models/shared/synctolatestargs.ts index a7db82838..a5a501f23 100644 --- a/sync-for-commerce/src/sdk/models/shared/synctolatestargs.ts +++ b/sync-for-commerce/src/sdk/models/shared/synctolatestargs.ts @@ -1,54 +1,58 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type SyncToLatestArgs = { - /** - * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: - * - * @remarks - * - * ``` - * 2020-10-08T22:40:50Z - * 2021-01-01T00:00:00 - * ``` - * - * - * - * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: - * - * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` - * - Unqualified local time: `2021-11-15T01:00:00` - * - UTC time offsets: `2021-11-15T01:00:00-05:00` - * - * > Time zones - * > - * > Not all dates from Codat will contain information about time zones. - * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. - */ - syncTo?: string | undefined; + /** + * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: + * + * @remarks + * + * ``` + * 2020-10-08T22:40:50Z + * 2021-01-01T00:00:00 + * ``` + * + * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: + * + * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` + * - Unqualified local time: `2021-11-15T01:00:00` + * - UTC time offsets: `2021-11-15T01:00:00-05:00` + * + * > Time zones + * > + * > Not all dates from Codat will contain information about time zones. + * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. + */ + syncTo?: string | undefined; }; /** @internal */ -export const SyncToLatestArgs$inboundSchema: z.ZodType = - z.object({ - syncTo: z.string().optional(), - }); +export const SyncToLatestArgs$inboundSchema: z.ZodType< + SyncToLatestArgs, + z.ZodTypeDef, + unknown +> = z.object({ + syncTo: z.string().optional(), +}); /** @internal */ export type SyncToLatestArgs$Outbound = { - syncTo?: string | undefined; + syncTo?: string | undefined; }; /** @internal */ export const SyncToLatestArgs$outboundSchema: z.ZodType< - SyncToLatestArgs$Outbound, - z.ZodTypeDef, - SyncToLatestArgs + SyncToLatestArgs$Outbound, + z.ZodTypeDef, + SyncToLatestArgs > = z.object({ - syncTo: z.string().optional(), + syncTo: z.string().optional(), }); /** @@ -56,10 +60,28 @@ export const SyncToLatestArgs$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SyncToLatestArgs$ { - /** @deprecated use `SyncToLatestArgs$inboundSchema` instead. */ - export const inboundSchema = SyncToLatestArgs$inboundSchema; - /** @deprecated use `SyncToLatestArgs$outboundSchema` instead. */ - export const outboundSchema = SyncToLatestArgs$outboundSchema; - /** @deprecated use `SyncToLatestArgs$Outbound` instead. */ - export type Outbound = SyncToLatestArgs$Outbound; + /** @deprecated use `SyncToLatestArgs$inboundSchema` instead. */ + export const inboundSchema = SyncToLatestArgs$inboundSchema; + /** @deprecated use `SyncToLatestArgs$outboundSchema` instead. */ + export const outboundSchema = SyncToLatestArgs$outboundSchema; + /** @deprecated use `SyncToLatestArgs$Outbound` instead. */ + export type Outbound = SyncToLatestArgs$Outbound; +} + +export function syncToLatestArgsToJSON( + syncToLatestArgs: SyncToLatestArgs, +): string { + return JSON.stringify( + SyncToLatestArgs$outboundSchema.parse(syncToLatestArgs), + ); +} + +export function syncToLatestArgsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SyncToLatestArgs$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SyncToLatestArgs' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/taxrateamount.ts b/sync-for-commerce/src/sdk/models/shared/taxrateamount.ts index 6804c1519..09bfef3d3 100644 --- a/sync-for-commerce/src/sdk/models/shared/taxrateamount.ts +++ b/sync-for-commerce/src/sdk/models/shared/taxrateamount.ts @@ -1,47 +1,55 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - ConfigurationOption, - ConfigurationOption$inboundSchema, - ConfigurationOption$Outbound, - ConfigurationOption$outboundSchema, + ConfigurationOption, + ConfigurationOption$inboundSchema, + ConfigurationOption$Outbound, + ConfigurationOption$outboundSchema, } from "./configurationoption.js"; -import * as z from "zod"; export type TaxRateAmount = { - /** - * Selected tax rate id from the list of tax rates on the accounting software. - */ - selectedTaxRateId?: string | null | undefined; - /** - * Array of tax rate options object. - */ - taxRateOptions?: Array | null | undefined; + /** + * Selected tax rate id from the list of tax rates on the accounting software. + */ + selectedTaxRateId?: string | null | undefined; + /** + * Array of tax rate options object. + */ + taxRateOptions?: Array | null | undefined; }; /** @internal */ -export const TaxRateAmount$inboundSchema: z.ZodType = - z.object({ - selectedTaxRateId: z.nullable(z.string()).optional(), - taxRateOptions: z.nullable(z.array(ConfigurationOption$inboundSchema)).optional(), - }); +export const TaxRateAmount$inboundSchema: z.ZodType< + TaxRateAmount, + z.ZodTypeDef, + unknown +> = z.object({ + selectedTaxRateId: z.nullable(z.string()).optional(), + taxRateOptions: z.nullable(z.array(ConfigurationOption$inboundSchema)) + .optional(), +}); /** @internal */ export type TaxRateAmount$Outbound = { - selectedTaxRateId?: string | null | undefined; - taxRateOptions?: Array | null | undefined; + selectedTaxRateId?: string | null | undefined; + taxRateOptions?: Array | null | undefined; }; /** @internal */ export const TaxRateAmount$outboundSchema: z.ZodType< - TaxRateAmount$Outbound, - z.ZodTypeDef, - TaxRateAmount + TaxRateAmount$Outbound, + z.ZodTypeDef, + TaxRateAmount > = z.object({ - selectedTaxRateId: z.nullable(z.string()).optional(), - taxRateOptions: z.nullable(z.array(ConfigurationOption$outboundSchema)).optional(), + selectedTaxRateId: z.nullable(z.string()).optional(), + taxRateOptions: z.nullable(z.array(ConfigurationOption$outboundSchema)) + .optional(), }); /** @@ -49,10 +57,24 @@ export const TaxRateAmount$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TaxRateAmount$ { - /** @deprecated use `TaxRateAmount$inboundSchema` instead. */ - export const inboundSchema = TaxRateAmount$inboundSchema; - /** @deprecated use `TaxRateAmount$outboundSchema` instead. */ - export const outboundSchema = TaxRateAmount$outboundSchema; - /** @deprecated use `TaxRateAmount$Outbound` instead. */ - export type Outbound = TaxRateAmount$Outbound; + /** @deprecated use `TaxRateAmount$inboundSchema` instead. */ + export const inboundSchema = TaxRateAmount$inboundSchema; + /** @deprecated use `TaxRateAmount$outboundSchema` instead. */ + export const outboundSchema = TaxRateAmount$outboundSchema; + /** @deprecated use `TaxRateAmount$Outbound` instead. */ + export type Outbound = TaxRateAmount$Outbound; +} + +export function taxRateAmountToJSON(taxRateAmount: TaxRateAmount): string { + return JSON.stringify(TaxRateAmount$outboundSchema.parse(taxRateAmount)); +} + +export function taxRateAmountFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => TaxRateAmount$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'TaxRateAmount' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/taxratemapping.ts b/sync-for-commerce/src/sdk/models/shared/taxratemapping.ts index 2b7b70fbb..5a77513ad 100644 --- a/sync-for-commerce/src/sdk/models/shared/taxratemapping.ts +++ b/sync-for-commerce/src/sdk/models/shared/taxratemapping.ts @@ -1,41 +1,47 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type TaxRateMapping = { - /** - * Selected tax component id from the list of tax components on the commerce software. - */ - selectedCommerceTaxRateIds?: Array | null | undefined; - /** - * Selected tax rate id from the list of tax rates on the accounting software. - */ - selectedAccountingTaxRateId?: string | null | undefined; + /** + * Selected tax component id from the list of tax components on the commerce software. + */ + selectedCommerceTaxRateIds?: Array | null | undefined; + /** + * Selected tax rate id from the list of tax rates on the accounting software. + */ + selectedAccountingTaxRateId?: string | null | undefined; }; /** @internal */ -export const TaxRateMapping$inboundSchema: z.ZodType = - z.object({ - selectedCommerceTaxRateIds: z.nullable(z.array(z.string())).optional(), - selectedAccountingTaxRateId: z.nullable(z.string()).optional(), - }); +export const TaxRateMapping$inboundSchema: z.ZodType< + TaxRateMapping, + z.ZodTypeDef, + unknown +> = z.object({ + selectedCommerceTaxRateIds: z.nullable(z.array(z.string())).optional(), + selectedAccountingTaxRateId: z.nullable(z.string()).optional(), +}); /** @internal */ export type TaxRateMapping$Outbound = { - selectedCommerceTaxRateIds?: Array | null | undefined; - selectedAccountingTaxRateId?: string | null | undefined; + selectedCommerceTaxRateIds?: Array | null | undefined; + selectedAccountingTaxRateId?: string | null | undefined; }; /** @internal */ export const TaxRateMapping$outboundSchema: z.ZodType< - TaxRateMapping$Outbound, - z.ZodTypeDef, - TaxRateMapping + TaxRateMapping$Outbound, + z.ZodTypeDef, + TaxRateMapping > = z.object({ - selectedCommerceTaxRateIds: z.nullable(z.array(z.string())).optional(), - selectedAccountingTaxRateId: z.nullable(z.string()).optional(), + selectedCommerceTaxRateIds: z.nullable(z.array(z.string())).optional(), + selectedAccountingTaxRateId: z.nullable(z.string()).optional(), }); /** @@ -43,10 +49,24 @@ export const TaxRateMapping$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TaxRateMapping$ { - /** @deprecated use `TaxRateMapping$inboundSchema` instead. */ - export const inboundSchema = TaxRateMapping$inboundSchema; - /** @deprecated use `TaxRateMapping$outboundSchema` instead. */ - export const outboundSchema = TaxRateMapping$outboundSchema; - /** @deprecated use `TaxRateMapping$Outbound` instead. */ - export type Outbound = TaxRateMapping$Outbound; + /** @deprecated use `TaxRateMapping$inboundSchema` instead. */ + export const inboundSchema = TaxRateMapping$inboundSchema; + /** @deprecated use `TaxRateMapping$outboundSchema` instead. */ + export const outboundSchema = TaxRateMapping$outboundSchema; + /** @deprecated use `TaxRateMapping$Outbound` instead. */ + export type Outbound = TaxRateMapping$Outbound; +} + +export function taxRateMappingToJSON(taxRateMapping: TaxRateMapping): string { + return JSON.stringify(TaxRateMapping$outboundSchema.parse(taxRateMapping)); +} + +export function taxRateMappingFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => TaxRateMapping$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'TaxRateMapping' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/updateconnection.ts b/sync-for-commerce/src/sdk/models/shared/updateconnection.ts index 6e4f89787..6911d9aca 100644 --- a/sync-for-commerce/src/sdk/models/shared/updateconnection.ts +++ b/sync-for-commerce/src/sdk/models/shared/updateconnection.ts @@ -1,39 +1,45 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { - DataConnectionStatus, - DataConnectionStatus$inboundSchema, - DataConnectionStatus$outboundSchema, + DataConnectionStatus, + DataConnectionStatus$inboundSchema, + DataConnectionStatus$outboundSchema, } from "./dataconnectionstatus.js"; -import * as z from "zod"; export type UpdateConnection = { - /** - * The current authorization status of the data connection. - */ - status?: DataConnectionStatus | undefined; + /** + * The current authorization status of the data connection. + */ + status?: DataConnectionStatus | undefined; }; /** @internal */ -export const UpdateConnection$inboundSchema: z.ZodType = - z.object({ - status: DataConnectionStatus$inboundSchema.optional(), - }); +export const UpdateConnection$inboundSchema: z.ZodType< + UpdateConnection, + z.ZodTypeDef, + unknown +> = z.object({ + status: DataConnectionStatus$inboundSchema.optional(), +}); /** @internal */ export type UpdateConnection$Outbound = { - status?: string | undefined; + status?: string | undefined; }; /** @internal */ export const UpdateConnection$outboundSchema: z.ZodType< - UpdateConnection$Outbound, - z.ZodTypeDef, - UpdateConnection + UpdateConnection$Outbound, + z.ZodTypeDef, + UpdateConnection > = z.object({ - status: DataConnectionStatus$outboundSchema.optional(), + status: DataConnectionStatus$outboundSchema.optional(), }); /** @@ -41,10 +47,28 @@ export const UpdateConnection$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace UpdateConnection$ { - /** @deprecated use `UpdateConnection$inboundSchema` instead. */ - export const inboundSchema = UpdateConnection$inboundSchema; - /** @deprecated use `UpdateConnection$outboundSchema` instead. */ - export const outboundSchema = UpdateConnection$outboundSchema; - /** @deprecated use `UpdateConnection$Outbound` instead. */ - export type Outbound = UpdateConnection$Outbound; + /** @deprecated use `UpdateConnection$inboundSchema` instead. */ + export const inboundSchema = UpdateConnection$inboundSchema; + /** @deprecated use `UpdateConnection$outboundSchema` instead. */ + export const outboundSchema = UpdateConnection$outboundSchema; + /** @deprecated use `UpdateConnection$Outbound` instead. */ + export type Outbound = UpdateConnection$Outbound; +} + +export function updateConnectionToJSON( + updateConnection: UpdateConnection, +): string { + return JSON.stringify( + UpdateConnection$outboundSchema.parse(updateConnection), + ); +} + +export function updateConnectionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => UpdateConnection$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'UpdateConnection' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/models/shared/visibleaccounts.ts b/sync-for-commerce/src/sdk/models/shared/visibleaccounts.ts index 79aeb5ac3..1a122c1c4 100644 --- a/sync-for-commerce/src/sdk/models/shared/visibleaccounts.ts +++ b/sync-for-commerce/src/sdk/models/shared/visibleaccounts.ts @@ -1,34 +1,40 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type VisibleAccounts = { - /** - * Visible accounts on sync flow. - */ - visibleAccounts?: Array | null | undefined; + /** + * Visible accounts on sync flow. + */ + visibleAccounts?: Array | null | undefined; }; /** @internal */ -export const VisibleAccounts$inboundSchema: z.ZodType = - z.object({ - visibleAccounts: z.nullable(z.array(z.string())).optional(), - }); +export const VisibleAccounts$inboundSchema: z.ZodType< + VisibleAccounts, + z.ZodTypeDef, + unknown +> = z.object({ + visibleAccounts: z.nullable(z.array(z.string())).optional(), +}); /** @internal */ export type VisibleAccounts$Outbound = { - visibleAccounts?: Array | null | undefined; + visibleAccounts?: Array | null | undefined; }; /** @internal */ export const VisibleAccounts$outboundSchema: z.ZodType< - VisibleAccounts$Outbound, - z.ZodTypeDef, - VisibleAccounts + VisibleAccounts$Outbound, + z.ZodTypeDef, + VisibleAccounts > = z.object({ - visibleAccounts: z.nullable(z.array(z.string())).optional(), + visibleAccounts: z.nullable(z.array(z.string())).optional(), }); /** @@ -36,10 +42,26 @@ export const VisibleAccounts$outboundSchema: z.ZodType< * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace VisibleAccounts$ { - /** @deprecated use `VisibleAccounts$inboundSchema` instead. */ - export const inboundSchema = VisibleAccounts$inboundSchema; - /** @deprecated use `VisibleAccounts$outboundSchema` instead. */ - export const outboundSchema = VisibleAccounts$outboundSchema; - /** @deprecated use `VisibleAccounts$Outbound` instead. */ - export type Outbound = VisibleAccounts$Outbound; + /** @deprecated use `VisibleAccounts$inboundSchema` instead. */ + export const inboundSchema = VisibleAccounts$inboundSchema; + /** @deprecated use `VisibleAccounts$outboundSchema` instead. */ + export const outboundSchema = VisibleAccounts$outboundSchema; + /** @deprecated use `VisibleAccounts$Outbound` instead. */ + export type Outbound = VisibleAccounts$Outbound; +} + +export function visibleAccountsToJSON( + visibleAccounts: VisibleAccounts, +): string { + return JSON.stringify(VisibleAccounts$outboundSchema.parse(visibleAccounts)); +} + +export function visibleAccountsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => VisibleAccounts$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'VisibleAccounts' from JSON`, + ); } diff --git a/sync-for-commerce/src/sdk/sdk.ts b/sync-for-commerce/src/sdk/sdk.ts index 53dd4f121..f222d22fa 100644 --- a/sync-for-commerce/src/sdk/sdk.ts +++ b/sync-for-commerce/src/sdk/sdk.ts @@ -1,10 +1,7 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks/hooks.js"; -import { SDKOptions, serverURLFromOptions } from "../lib/config.js"; -import { HTTPClient } from "../lib/http.js"; import { ClientSDK } from "../lib/sdks.js"; import { AdvancedControls } from "./advancedcontrols.js"; import { Connections } from "./connections.js"; @@ -13,54 +10,28 @@ import { Sync } from "./sync.js"; import { SyncFlowSettings } from "./syncflowsettings.js"; export class CodatSyncCommerce extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - - private _connections?: Connections; - get connections(): Connections { - return (this._connections ??= new Connections(this.options$)); - } - - private _advancedControls?: AdvancedControls; - get advancedControls(): AdvancedControls { - return (this._advancedControls ??= new AdvancedControls(this.options$)); - } - - private _integrations?: Integrations; - get integrations(): Integrations { - return (this._integrations ??= new Integrations(this.options$)); - } - - private _syncFlowSettings?: SyncFlowSettings; - get syncFlowSettings(): SyncFlowSettings { - return (this._syncFlowSettings ??= new SyncFlowSettings(this.options$)); - } - - private _sync?: Sync; - get sync(): Sync { - return (this._sync ??= new Sync(this.options$)); - } + private _connections?: Connections; + get connections(): Connections { + return (this._connections ??= new Connections(this._options)); + } + + private _advancedControls?: AdvancedControls; + get advancedControls(): AdvancedControls { + return (this._advancedControls ??= new AdvancedControls(this._options)); + } + + private _integrations?: Integrations; + get integrations(): Integrations { + return (this._integrations ??= new Integrations(this._options)); + } + + private _syncFlowSettings?: SyncFlowSettings; + get syncFlowSettings(): SyncFlowSettings { + return (this._syncFlowSettings ??= new SyncFlowSettings(this._options)); + } + + private _sync?: Sync; + get sync(): Sync { + return (this._sync ??= new Sync(this._options)); + } } diff --git a/sync-for-commerce/src/sdk/sync.ts b/sync-for-commerce/src/sdk/sync.ts index 5164354ff..d8a032771 100644 --- a/sync-for-commerce/src/sdk/sync.ts +++ b/sync-for-commerce/src/sdk/sync.ts @@ -1,720 +1,136 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks/hooks.js"; -import { SDKOptions, serverURLFromOptions } from "../lib/config.js"; -import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js"; -import { HTTPClient } from "../lib/http.js"; -import * as schemas$ from "../lib/schemas.js"; +import { syncGet } from "../funcs/syncGet.js"; +import { syncGetLastSuccessfulSync } from "../funcs/syncGetLastSuccessfulSync.js"; +import { syncGetLatestSync } from "../funcs/syncGetLatestSync.js"; +import { syncGetStatus } from "../funcs/syncGetStatus.js"; +import { syncList } from "../funcs/syncList.js"; +import { syncRequest } from "../funcs/syncRequest.js"; +import { syncRequestForDateRange } from "../funcs/syncRequestForDateRange.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; -import * as errors from "./models/errors/index.js"; import * as operations from "./models/operations/index.js"; import * as shared from "./models/shared/index.js"; -import * as z from "zod"; +import { unwrapAsync } from "./types/fp.js"; export class Sync extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - - /** - * Initiate new sync - * - * @remarks - * Run a Commerce sync from the last successful sync up to the date provided (optional), otherwise UtcNow is used.\r\nIf there was no previously successful sync, the start date in the config is used. - */ - async request( - request: operations.RequestSyncRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.RequestSyncRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = encodeJSON$("body", payload$.SyncToLatestArgs, { explode: true }); - - const pathParams$ = { - companyId: encodeSimple$("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent("/companies/{companyId}/sync/commerce/latest")( - pathParams$ - ); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "request-sync", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["400", "401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.SyncSummary$inboundSchema) - .json([400, 401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Initiate sync for specific range - * - * @remarks - * Initiate a sync for the specified start date to the specified finish date in the request payload. - */ - async requestForDateRange( - request: operations.RequestSyncForDateRangeRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.RequestSyncForDateRangeRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = encodeJSON$("body", payload$.SyncRange, { explode: true }); - - const pathParams$ = { - companyId: encodeSimple$("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent( - "/meta/companies/{companyId}/sync/commerce/historic" - )(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "request-sync-for-date-range", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["400", "401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.SyncSummary$inboundSchema) - .json([400, 401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Get sync status - * - * @remarks - * Gets a list of sync statuses. - */ - async getStatus( - request: operations.GetSyncStatusRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.GetSyncStatusRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - companyId: encodeSimple$("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent("/meta/companies/{companyId}/sync/commerce/status")( - pathParams$ - ); - - const query$ = ""; - - const headers$ = new Headers({ - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "get-sync-status", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.SyncStatus$inboundSchema) - .json([401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Last successful sync - * - * @remarks - * Gets the status of the last successful sync - */ - async getLastSuccessfulSync( - request: operations.GetLastSuccessfulSyncRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.GetLastSuccessfulSyncRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - companyId: encodeSimple$("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent( - "/companies/{companyId}/sync/commerce/syncs/lastSuccessful/status" - )(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "get-last-successful-sync", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.CompanySyncStatus$inboundSchema) - .json([401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Latest sync status - * - * @remarks - * Gets the latest sync status - */ - async getLatestSync( - request: operations.GetLatestSyncRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.GetLatestSyncRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - companyId: encodeSimple$("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent( - "/companies/{companyId}/sync/commerce/syncs/latest/status" - )(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "get-latest-sync", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.CompanySyncStatus$inboundSchema) - .json([401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Get sync status - * - * @remarks - * Get the sync status for a specified sync - */ - async get( - request: operations.GetSyncByIdRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.GetSyncByIdRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - companyId: encodeSimple$("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - syncId: encodeSimple$("syncId", payload$.syncId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent( - "/companies/{companyId}/sync/commerce/syncs/{syncId}/status" - )(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "get-sync-by-id", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.CompanySyncStatus$inboundSchema) - .json([401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * List sync statuses - * - * @remarks - * Gets a list of sync statuses - */ - async list( - request: operations.ListSyncsRequest, - options?: RequestOptions - ): Promise> { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.ListSyncsRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - companyId: encodeSimple$("companyId", payload$.companyId, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent( - "/companies/{companyId}/sync/commerce/syncs/list/status" - )(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "list-syncs", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher>() - .json(200, z.array(shared.CompanySyncStatus$inboundSchema)) - .json([401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } + /** + * Initiate new sync + * + * @remarks + * Run a Commerce sync from the last successful sync up to the date provided (optional), otherwise UtcNow is used.\r\nIf there was no previously successful sync, the start date in the config is used. + */ + async request( + request: operations.RequestSyncRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(syncRequest( + this, + request, + options, + )); + } + + /** + * Initiate sync for specific range + * + * @remarks + * Initiate a sync for the specified start date to the specified finish date in the request payload. + */ + async requestForDateRange( + request: operations.RequestSyncForDateRangeRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(syncRequestForDateRange( + this, + request, + options, + )); + } + + /** + * Get sync status + * + * @remarks + * Gets a list of sync statuses. + */ + async getStatus( + request: operations.GetSyncStatusRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(syncGetStatus( + this, + request, + options, + )); + } + + /** + * Last successful sync + * + * @remarks + * Gets the status of the last successful sync + */ + async getLastSuccessfulSync( + request: operations.GetLastSuccessfulSyncRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(syncGetLastSuccessfulSync( + this, + request, + options, + )); + } + + /** + * Latest sync status + * + * @remarks + * Gets the latest sync status + */ + async getLatestSync( + request: operations.GetLatestSyncRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(syncGetLatestSync( + this, + request, + options, + )); + } + + /** + * Get sync status + * + * @remarks + * Get the sync status for a specified sync + */ + async get( + request: operations.GetSyncByIdRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(syncGet( + this, + request, + options, + )); + } + + /** + * List sync statuses + * + * @remarks + * Gets a list of sync statuses + */ + async list( + request: operations.ListSyncsRequest, + options?: RequestOptions, + ): Promise> { + return unwrapAsync(syncList( + this, + request, + options, + )); + } } diff --git a/sync-for-commerce/src/sdk/syncflowsettings.ts b/sync-for-commerce/src/sdk/syncflowsettings.ts index b8b61cc3a..910a05f05 100644 --- a/sync-for-commerce/src/sdk/syncflowsettings.ts +++ b/sync-for-commerce/src/sdk/syncflowsettings.ts @@ -1,423 +1,82 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks/hooks.js"; -import { SDKOptions, serverURLFromOptions } from "../lib/config.js"; -import { - encodeFormQuery as encodeFormQuery$, - encodeJSON as encodeJSON$, - encodeSimple as encodeSimple$, -} from "../lib/encodings.js"; -import { HTTPClient } from "../lib/http.js"; -import * as schemas$ from "../lib/schemas.js"; +import { syncFlowSettingsGetConfigTextSyncFlow } from "../funcs/syncFlowSettingsGetConfigTextSyncFlow.js"; +import { syncFlowSettingsGetVisibleAccounts } from "../funcs/syncFlowSettingsGetVisibleAccounts.js"; +import { syncFlowSettingsUpdateConfigTextSyncFlow } from "../funcs/syncFlowSettingsUpdateConfigTextSyncFlow.js"; +import { syncFlowSettingsUpdateVisibleAccountsSyncFlow } from "../funcs/syncFlowSettingsUpdateVisibleAccountsSyncFlow.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; -import * as errors from "./models/errors/index.js"; import * as operations from "./models/operations/index.js"; import * as shared from "./models/shared/index.js"; -import * as z from "zod"; +import { unwrapAsync } from "./types/fp.js"; export class SyncFlowSettings extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - - /** - * Get preferences for text fields - * - * @remarks - * Return preferences set for the text fields on sync flow. - */ - async getConfigTextSyncFlow( - request: operations.GetConfigTextSyncFlowRequest, - options?: RequestOptions - ): Promise<{ [k: string]: shared.Localization }> { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.GetConfigTextSyncFlowRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const path$ = this.templateURLComponent("/sync/commerce/config/ui/text")(); - - const query$ = encodeFormQuery$({ - locale: payload$.locale, - }); - - const headers$ = new Headers({ - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "get-config-text-sync-flow", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["401", "402", "403", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher<{ [k: string]: shared.Localization }>() - .json(200, z.record(shared.Localization$inboundSchema)) - .json([401, 402, 403, 429, 500, 503], errors.ErrorMessage$inboundSchema, { err: true }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Update preferences for text fields - * - * @remarks - * Set preferences for the text fields on sync flow. - */ - async updateConfigTextSyncFlow( - request: operations.UpdateConfigTextSyncFlowRequest, - options?: RequestOptions - ): Promise<{ [k: string]: shared.Localization }> { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.UpdateConfigTextSyncFlowRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = encodeJSON$("body", payload$.RequestBody, { explode: true }); - - const path$ = this.templateURLComponent("/sync/commerce/config/ui/text")(); - - const query$ = encodeFormQuery$({ - locale: payload$.locale, - }); - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "update-config-text-sync-flow", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "PATCH", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["400", "401", "402", "403", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher<{ [k: string]: shared.Localization }>() - .json(200, z.record(shared.Localization$inboundSchema)) - .json([400, 401, 402, 403, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * List visible accounts - * - * @remarks - * Return accounts which are visible on sync flow. - */ - async getVisibleAccounts( - request: operations.GetVisibleAccountsRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.GetVisibleAccountsRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - clientId: encodeSimple$("clientId", payload$.clientId, { - explode: false, - charEncoding: "percent", - }), - platformKey: encodeSimple$("platformKey", payload$.platformKey, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent( - "/clients/{clientId}/config/ui/accounts/platform/{platformKey}" - )(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "get-visible-accounts", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.VisibleAccounts$inboundSchema) - .json([401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } - - /** - * Update visible accounts - * - * @remarks - * Update which accounts are visible on sync flow. - */ - async updateVisibleAccountsSyncFlow( - request: operations.UpdateVisibleAccountsSyncFlowRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => - operations.UpdateVisibleAccountsSyncFlowRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = encodeJSON$("body", payload$.VisibleAccounts, { explode: true }); - - const pathParams$ = { - platformKey: encodeSimple$("platformKey", payload$.platformKey, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent( - "/sync/commerce/config/ui/accounts/platform/{platformKey}" - )(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - }); - - let security$; - if (typeof this.options$.authHeader === "function") { - security$ = { authHeader: await this.options$.authHeader() }; - } else if (this.options$.authHeader) { - security$ = { authHeader: this.options$.authHeader }; - } else { - security$ = {}; - } - const context = { - operationID: "update-visible-accounts-sync-flow", - oAuth2Scopes: [], - securitySource: this.options$.authHeader, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["400", "401", "402", "403", "404", "429", "4XX", "500", "503", "5XX"], - retryConfig: options?.retries || - this.options$.retryConfig || { - strategy: "backoff", - backoff: { - initialInterval: 500, - maxInterval: 60000, - exponent: 1.5, - maxElapsedTime: 3600000, - }, - retryConnectionErrors: true, - }, - retryCodes: options?.retryCodes || ["408", "429", "5XX"], - }); - - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, - }; - - const [result$] = await this.matcher() - .json(200, shared.VisibleAccounts$inboundSchema) - .json([400, 401, 402, 403, 404, 429, 500, 503], errors.ErrorMessage$inboundSchema, { - err: true, - }) - .fail(["4XX", "5XX"]) - .match(response, { extraFields: responseFields$ }); - - return result$; - } + /** + * Get preferences for text fields + * + * @remarks + * Return preferences set for the text fields on sync flow. + */ + async getConfigTextSyncFlow( + request: operations.GetConfigTextSyncFlowRequest, + options?: RequestOptions, + ): Promise<{ [k: string]: shared.Localization }> { + return unwrapAsync(syncFlowSettingsGetConfigTextSyncFlow( + this, + request, + options, + )); + } + + /** + * Update preferences for text fields + * + * @remarks + * Set preferences for the text fields on sync flow. + */ + async updateConfigTextSyncFlow( + request: operations.UpdateConfigTextSyncFlowRequest, + options?: RequestOptions, + ): Promise<{ [k: string]: shared.Localization }> { + return unwrapAsync(syncFlowSettingsUpdateConfigTextSyncFlow( + this, + request, + options, + )); + } + + /** + * List visible accounts + * + * @remarks + * Return accounts which are visible on sync flow. + */ + async getVisibleAccounts( + request: operations.GetVisibleAccountsRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(syncFlowSettingsGetVisibleAccounts( + this, + request, + options, + )); + } + + /** + * Update visible accounts + * + * @remarks + * Update which accounts are visible on sync flow. + */ + async updateVisibleAccountsSyncFlow( + request: operations.UpdateVisibleAccountsSyncFlowRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(syncFlowSettingsUpdateVisibleAccountsSyncFlow( + this, + request, + options, + )); + } } diff --git a/sync-for-commerce/src/sdk/types/blobs.ts b/sync-for-commerce/src/sdk/types/blobs.ts index cbb8a57f7..4ce846023 100644 --- a/sync-for-commerce/src/sdk/types/blobs.ts +++ b/sync-for-commerce/src/sdk/types/blobs.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; diff --git a/sync-for-commerce/src/sdk/types/constdatetime.ts b/sync-for-commerce/src/sdk/types/constdatetime.ts new file mode 100644 index 000000000..c0a4409c7 --- /dev/null +++ b/sync-for-commerce/src/sdk/types/constdatetime.ts @@ -0,0 +1,15 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; + +export function constDateTime( + val: string, +): z.ZodType { + return z.custom((v) => { + return ( + typeof v === "string" && new Date(v).getTime() === new Date(val).getTime() + ); + }, `Value must be equivelant to ${val}`); +} diff --git a/sync-for-commerce/src/sdk/types/enums.ts b/sync-for-commerce/src/sdk/types/enums.ts index 4de0142be..6fb6d9109 100644 --- a/sync-for-commerce/src/sdk/types/enums.ts +++ b/sync-for-commerce/src/sdk/types/enums.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ declare const __brand: unique symbol; diff --git a/sync-for-commerce/src/sdk/types/fp.ts b/sync-for-commerce/src/sdk/types/fp.ts new file mode 100644 index 000000000..ccbe51eac --- /dev/null +++ b/sync-for-commerce/src/sdk/types/fp.ts @@ -0,0 +1,50 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/** + * A monad that captures the result of a function call or an error if it was not + * successful. Railway programming, enabled by this type, can be a nicer + * alternative to traditional exception throwing because it allows functions to + * declare all _known_ errors with static types and then check for them + * exhaustively in application code. Thrown exception have a type of `unknown` + * and break out of regular control flow of programs making them harder to + * inspect and more verbose work with due to try-catch blocks. + */ +export type Result = + | { ok: true; value: T; error?: never } + | { ok: false; value?: never; error: E }; + +export function OK(value: V): Result { + return { ok: true, value }; +} + +export function ERR(error: E): Result { + return { ok: false, error }; +} + +/** + * unwrap is a convenience function for extracting a value from a result or + * throwing if there was an error. + */ +export function unwrap(r: Result): T { + if (!r.ok) { + throw r.error; + } + return r.value; +} + +/** + * unwrapAsync is a convenience function for resolving a value from a Promise + * of a result or rejecting if an error occurred. + */ +export async function unwrapAsync( + pr: Promise>, +): Promise { + const r = await pr; + if (!r.ok) { + throw r.error; + } + + return r.value; +} diff --git a/sync-for-commerce/src/sdk/types/index.ts b/sync-for-commerce/src/sdk/types/index.ts index 374373e9b..e124e817b 100644 --- a/sync-for-commerce/src/sdk/types/index.ts +++ b/sync-for-commerce/src/sdk/types/index.ts @@ -1,10 +1,11 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export { RFCDate } from "./rfcdate.js"; export { blobLikeSchema, isBlobLike } from "./blobs.js"; -export type { Paginator, PageIterator } from "./operations.js"; -export { createPageIterator } from "./operations.js"; export { catchUnrecognizedEnum } from "./enums.js"; -export type { OpenEnum, ClosedEnum, Unrecognized } from "./enums.js"; +export type { ClosedEnum, OpenEnum, Unrecognized } from "./enums.js"; +export type { Result } from "./fp.js"; +export type { PageIterator, Paginator } from "./operations.js"; +export { createPageIterator } from "./operations.js"; +export { RFCDate } from "./rfcdate.js"; diff --git a/sync-for-commerce/src/sdk/types/operations.ts b/sync-for-commerce/src/sdk/types/operations.ts index 7f8335147..0952f6f4d 100644 --- a/sync-for-commerce/src/sdk/types/operations.ts +++ b/sync-for-commerce/src/sdk/types/operations.ts @@ -1,25 +1,99 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export type Paginator = () => Promise> | null; +import { Result } from "./fp.js"; -export type PageIterator = Result & { - next: Paginator; - [Symbol.asyncIterator]: () => AsyncIterableIterator; +export type Paginator = () => Promise }> | null; + +export type PageIterator = V & { + next: Paginator; + [Symbol.asyncIterator]: () => AsyncIterableIterator; }; -export function createPageIterator( - page: Result & { next: Paginator }, -): { [Symbol.asyncIterator]: () => AsyncIterableIterator } { +export function createPageIterator( + page: V & { next: Paginator }, + halt: (v: V) => boolean, +): { + [Symbol.asyncIterator]: () => AsyncIterableIterator; +} { return { [Symbol.asyncIterator]: async function* paginator() { yield page; + if (halt(page)) { + return; + } let p: typeof page | null = page; for (p = await p.next(); p != null; p = await p.next()) { yield p; + if (halt(p)) { + return; + } } }, }; } + +/** + * This utility create a special iterator that yields a single value and + * terminates. It is useful in paginated SDK functions that have early return + * paths when things go wrong. + */ +export function haltIterator(v: V): PageIterator { + return { + ...v, + next: () => null, + [Symbol.asyncIterator]: async function* paginator() { + yield v; + }, + }; +} + +/** + * Converts an async iterator of `Result` into an async iterator of `V`. + * When error results occur, the underlying error value is thrown. + */ +export async function unwrapResultIterator( + iteratorPromise: Promise>>, +): Promise> { + const resultIter = await iteratorPromise; + + if (!resultIter.ok) { + throw resultIter.error; + } + + return { + ...resultIter.value, + next: unwrapPaginator(resultIter.next), + [Symbol.asyncIterator]: async function* paginator() { + for await (const page of resultIter) { + if (!page.ok) { + throw page.error; + } + yield page.value; + } + }, + }; +} + +function unwrapPaginator( + paginator: Paginator>, +): Paginator { + return () => { + const nextResult = paginator(); + if (nextResult == null) { + return null; + } + return nextResult.then((res) => { + if (!res.ok) { + throw res.error; + } + const out = { + ...res.value, + next: unwrapPaginator(res.next), + }; + return out; + }); + }; +} diff --git a/sync-for-commerce/src/sdk/types/rfcdate.ts b/sync-for-commerce/src/sdk/types/rfcdate.ts index e80b69320..c79b3f53a 100644 --- a/sync-for-commerce/src/sdk/types/rfcdate.ts +++ b/sync-for-commerce/src/sdk/types/rfcdate.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ const dateRE = /^\d{4}-\d{2}-\d{2}$/; diff --git a/sync-for-commerce/src/sdk/types/streams.ts b/sync-for-commerce/src/sdk/types/streams.ts new file mode 100644 index 000000000..a0163e7a9 --- /dev/null +++ b/sync-for-commerce/src/sdk/types/streams.ts @@ -0,0 +1,21 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +export function isReadableStream( + val: unknown, +): val is ReadableStream { + if (typeof val !== "object" || val === null) { + return false; + } + + // Check for the presence of methods specific to ReadableStream + const stream = val as ReadableStream; + + // ReadableStream has methods like getReader, cancel, and tee + return ( + typeof stream.getReader === "function" && + typeof stream.cancel === "function" && + typeof stream.tee === "function" + ); +}