Skip to content

Commit

Permalink
refactor(ledger): Clean OpenAPI and generate client for Ledger only (…
Browse files Browse the repository at this point in the history
…#1715)
  • Loading branch information
flemzord authored Sep 24, 2024
1 parent 3e15b29 commit 03b9a6b
Show file tree
Hide file tree
Showing 246 changed files with 9,656 additions and 363 deletions.
23 changes: 14 additions & 9 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
VERSION 0.8

IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core
IMPORT github.com/formancehq/earthly:tags/v0.16.0 AS core
IMPORT ../../releases AS releases
IMPORT ../.. AS stack
IMPORT .. AS components

Expand Down Expand Up @@ -116,7 +117,10 @@ pre-commit:
BUILD --pass-args +tidy
END
BUILD --pass-args +lint
BUILD +openapi
WAIT
BUILD +openapi
END
BUILD +generate-client

bench:
FROM core+builder-image
Expand Down Expand Up @@ -175,14 +179,15 @@ tidy:
release:
BUILD --pass-args stack+goreleaser --path=components/ledger

generate-sdk:
generate-client:
FROM node:20-alpine
RUN apk update && apk add yq git
RUN apk update && apk add yq jq
WORKDIR /src
COPY (stack+speakeasy/speakeasy) /bin/speakeasy
ARG version=v0.0.0
COPY openapi/v2.yaml openapi.yaml
COPY (core+sources-speakeasy/speakeasy) /bin/speakeasy
COPY (+openapi/openapi.yaml) openapi.yaml
RUN cat ./openapi.yaml | yq e -o json > openapi.json
COPY (releases+sources/src/openapi-overlay.json) openapi-overlay.json
RUN jq -s '.[0] * .[1]' openapi.json openapi-overlay.json > final.json
COPY --dir pkg/client client
RUN --secret SPEAKEASY_API_KEY speakeasy generate sdk -s ./openapi.yaml -o ./client -l go

RUN --secret SPEAKEASY_API_KEY speakeasy generate sdk -s ./final.json -o ./client -l go
SAVE ARTIFACT client AS LOCAL ./pkg/client
8 changes: 8 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3706,3 +3706,11 @@ components:
properties:
data:
$ref: '#/components/schemas/V2Ledger'
securitySchemes:
Authorization:
type: oauth2
flows:
clientCredentials:
tokenUrl: /api/auth/oauth/token
refreshUrl: /api/auth/oauth/token
scopes: {}
9 changes: 9 additions & 0 deletions openapi/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,15 @@ paths:
- Authorization:
- ledger:read
components:
securitySchemes:
Authorization:
type: oauth2
flows:
clientCredentials:
tokenUrl: '/api/auth/oauth/token'
refreshUrl: '/api/auth/oauth/token'
scopes: { }

schemas:
AccountsCursorResponse:
type: object
Expand Down
12 changes: 9 additions & 3 deletions openapi/v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ info:
servers:
- url: http://localhost:8080/
paths:
x-speakeasy-errors:
statusCodes:
- default
/v2/_info:
get:
tags:
Expand Down Expand Up @@ -1254,6 +1251,15 @@ paths:
- Authorization:
- ledger:write
components:
securitySchemes:
Authorization:
type: oauth2
flows:
clientCredentials:
tokenUrl: '/api/auth/oauth/token'
refreshUrl: '/api/auth/oauth/token'
scopes: { }

schemas:
V2AccountsCursorResponse:
type: object
Expand Down
176 changes: 161 additions & 15 deletions pkg/client/.speakeasy/gen.lock
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
lockVersion: 2.0.0
id: a9ac79e1-e429-4ee3-96c4-ec973f19bec3
management:
docChecksum: 359dd8cb16193447c993d3d336785c37
docChecksum: ca116951d61ec04bcf24308e613bf2d7
docVersion: LEDGER_VERSION
speakeasyVersion: 1.346.0
generationVersion: 2.379.3
releaseVersion: 0.2.0
configChecksum: 09df02129c4cf02489fa2f86475a8a45
speakeasyVersion: 1.351.0
generationVersion: 2.384.1
releaseVersion: 0.3.0
configChecksum: c8d8f683fb8781c1d3ca28aa7371d52e
features:
go:
additionalDependencies: 0.1.0
constsAndDefaults: 0.1.4
core: 3.5.2
defaultEnabledRetries: 0.2.0
deprecations: 2.81.1
devContainers: 2.90.0
downloadStreams: 0.1.1
envVarSecurityUsage: 0.2.0
envVarSecurityUsage: 0.2.1
errors: 2.81.9
flattening: 2.81.1
getRequestBodies: 2.81.1
globalSecurity: 2.82.9
globalSecurityCallbacks: 0.1.0
globalServerURLs: 2.82.2
ignores: 2.81.1
intellisenseMarkdownSupport: 0.1.0
nameOverrides: 2.81.2
nullables: 0.1.0
oauth2ClientCredentials: 0.1.1
responseFormat: 0.1.2
retries: 2.83.0
sdkHooks: 0.1.0
unions: 2.85.8
generatedFiles:
- v1.go
- v2.go
- ledger.go
- formance.go
Expand All @@ -48,6 +55,26 @@ generatedFiles:
- internal/utils/retries.go
- internal/utils/security.go
- internal/utils/utils.go
- /models/operations/getinfo.go
- /models/operations/getledgerinfo.go
- /models/operations/countaccounts.go
- /models/operations/listaccounts.go
- /models/operations/getaccount.go
- /models/operations/addmetadatatoaccount.go
- /models/operations/getmapping.go
- /models/operations/updatemapping.go
- /models/operations/runscript.go
- /models/operations/readstats.go
- /models/operations/counttransactions.go
- /models/operations/listtransactions.go
- /models/operations/createtransaction.go
- /models/operations/gettransaction.go
- /models/operations/addmetadataontransaction.go
- /models/operations/reverttransaction.go
- /models/operations/createtransactions.go
- /models/operations/getbalances.go
- /models/operations/getbalancesaggregated.go
- /models/operations/listlogs.go
- /models/operations/v2getinfo.go
- /models/operations/v2listledgers.go
- /models/operations/v2getledger.go
Expand All @@ -74,10 +101,41 @@ generatedFiles:
- /models/operations/v2listlogs.go
- /models/operations/v2importlogs.go
- /models/operations/v2exportlogs.go
- /models/sdkerrors/v2errorresponse.go
- /models/components/configinforesponse.go
- /models/components/configinfo.go
- /models/components/config.go
- /models/components/ledgerstorage.go
- /models/components/httpmetadata.go
- /models/components/errorsenum.go
- /models/components/ledgerinforesponse.go
- /models/components/ledgerinfo.go
- /models/components/migrationinfo.go
- /models/components/accountscursorresponse.go
- /models/components/account.go
- /models/components/accountresponse.go
- /models/components/accountwithvolumesandbalances.go
- /models/components/volume.go
- /models/components/mappingresponse.go
- /models/components/mapping.go
- /models/components/contract.go
- /models/components/scriptresponse.go
- /models/components/transaction.go
- /models/components/posting.go
- /models/components/script.go
- /models/components/statsresponse.go
- /models/components/stats.go
- /models/components/transactionscursorresponse.go
- /models/components/transactionsresponse.go
- /models/components/posttransaction.go
- /models/components/transactionresponse.go
- /models/components/transactions.go
- /models/components/transactiondata.go
- /models/components/balancescursorresponse.go
- /models/components/aggregatebalancesresponse.go
- /models/components/logscursorresponse.go
- /models/components/log.go
- /models/components/v2errorsenum.go
- /models/components/v2configinforesponse.go
- /models/components/httpmetadata.go
- /models/components/v2ledgerlistresponse.go
- /models/components/v2ledger.go
- /models/components/v2getledgerresponse.go
Expand Down Expand Up @@ -113,6 +171,49 @@ generatedFiles:
- /models/components/v2volumeswithbalance.go
- /models/components/v2logscursorresponse.go
- /models/components/v2log.go
- /models/components/security.go
- /models/sdkerrors/errorresponse.go
- /models/sdkerrors/v2errorresponse.go
- docs/models/operations/getinforesponse.md
- docs/models/operations/getledgerinforequest.md
- docs/models/operations/getledgerinforesponse.md
- docs/models/operations/countaccountsrequest.md
- docs/models/operations/countaccountsresponse.md
- docs/models/operations/listaccountsrequest.md
- docs/models/operations/listaccountsresponse.md
- docs/models/operations/getaccountrequest.md
- docs/models/operations/getaccountresponse.md
- docs/models/operations/addmetadatatoaccountrequest.md
- docs/models/operations/addmetadatatoaccountresponse.md
- docs/models/operations/getmappingrequest.md
- docs/models/operations/getmappingresponse.md
- docs/models/operations/updatemappingrequest.md
- docs/models/operations/updatemappingresponse.md
- docs/models/operations/runscriptrequest.md
- docs/models/operations/runscriptresponse.md
- docs/models/operations/readstatsrequest.md
- docs/models/operations/readstatsresponse.md
- docs/models/operations/metadata.md
- docs/models/operations/counttransactionsrequest.md
- docs/models/operations/counttransactionsresponse.md
- docs/models/operations/listtransactionsrequest.md
- docs/models/operations/listtransactionsresponse.md
- docs/models/operations/createtransactionrequest.md
- docs/models/operations/createtransactionresponse.md
- docs/models/operations/gettransactionrequest.md
- docs/models/operations/gettransactionresponse.md
- docs/models/operations/addmetadataontransactionrequest.md
- docs/models/operations/addmetadataontransactionresponse.md
- docs/models/operations/reverttransactionrequest.md
- docs/models/operations/reverttransactionresponse.md
- docs/models/operations/createtransactionsrequest.md
- docs/models/operations/createtransactionsresponse.md
- docs/models/operations/getbalancesrequest.md
- docs/models/operations/getbalancesresponse.md
- docs/models/operations/getbalancesaggregatedrequest.md
- docs/models/operations/getbalancesaggregatedresponse.md
- docs/models/operations/listlogsrequest.md
- docs/models/operations/listlogsresponse.md
- docs/models/operations/v2getinforesponse.md
- docs/models/operations/v2listledgersrequest.md
- docs/models/operations/v2listledgersresponse.md
Expand Down Expand Up @@ -165,19 +266,59 @@ generatedFiles:
- docs/models/operations/v2importlogsresponse.md
- docs/models/operations/v2exportlogsrequest.md
- docs/models/operations/v2exportlogsresponse.md
- docs/models/sdkerrors/v2errorresponse.md
- docs/models/components/v2errorsenum.md
- docs/models/components/v2configinforesponse.md
- docs/models/components/configinforesponse.md
- docs/models/components/configinfo.md
- docs/models/components/config.md
- docs/models/components/ledgerstorage.md
- docs/models/components/httpmetadata.md
- docs/models/components/errorsenum.md
- docs/models/components/ledgerinforesponse.md
- docs/models/components/storage.md
- docs/models/components/ledgerinfo.md
- docs/models/components/state.md
- docs/models/components/migrationinfo.md
- docs/models/components/cursor.md
- docs/models/components/accountscursorresponse.md
- docs/models/components/account.md
- docs/models/components/accountresponse.md
- docs/models/components/accountwithvolumesandbalances.md
- docs/models/components/volume.md
- docs/models/components/mappingresponse.md
- docs/models/components/mapping.md
- docs/models/components/expr.md
- docs/models/components/contract.md
- docs/models/components/scriptresponse.md
- docs/models/components/transaction.md
- docs/models/components/posting.md
- docs/models/components/script.md
- docs/models/components/statsresponse.md
- docs/models/components/stats.md
- docs/models/components/transactionscursorresponsecursor.md
- docs/models/components/transactionscursorresponse.md
- docs/models/components/transactionsresponse.md
- docs/models/components/posttransactionscript.md
- docs/models/components/posttransaction.md
- docs/models/components/transactionresponse.md
- docs/models/components/transactions.md
- docs/models/components/transactiondata.md
- docs/models/components/balancescursorresponsecursor.md
- docs/models/components/balancescursorresponse.md
- docs/models/components/aggregatebalancesresponse.md
- docs/models/components/logscursorresponsecursor.md
- docs/models/components/logscursorresponse.md
- docs/models/components/type.md
- docs/models/components/log.md
- docs/models/components/v2errorsenum.md
- docs/models/components/v2configinforesponse.md
- docs/models/components/v2ledgerlistresponsecursor.md
- docs/models/components/v2ledgerlistresponse.md
- docs/models/components/v2ledger.md
- docs/models/components/v2getledgerresponse.md
- docs/models/components/v2createledgerrequest.md
- docs/models/components/v2ledgerinforesponse.md
- docs/models/components/storage.md
- docs/models/components/v2ledgerinfostorage.md
- docs/models/components/v2ledgerinfo.md
- docs/models/components/state.md
- docs/models/components/v2migrationinfostate.md
- docs/models/components/v2migrationinfo.md
- docs/models/components/v2bulkresponse.md
- docs/models/components/v2bulkelementresulterror.md
Expand All @@ -190,7 +331,7 @@ generatedFiles:
- docs/models/components/v2posting.md
- docs/models/components/v2bulkelement.md
- docs/models/components/v2bulkelementcreatetransaction.md
- docs/models/components/script.md
- docs/models/components/v2posttransactionscript.md
- docs/models/components/v2posttransaction.md
- docs/models/components/data.md
- docs/models/components/v2bulkelementaddmetadata.md
Expand Down Expand Up @@ -219,11 +360,15 @@ generatedFiles:
- docs/models/components/v2volumeswithbalance.md
- docs/models/components/v2logscursorresponsecursor.md
- docs/models/components/v2logscursorresponse.md
- docs/models/components/type.md
- docs/models/components/v2logtype.md
- docs/models/components/v2log.md
- docs/models/components/security.md
- docs/models/sdkerrors/errorresponse.md
- docs/models/sdkerrors/v2errorresponse.md
- docs/sdks/formance/README.md
- docs/sdks/ledger/README.md
- docs/models/operations/option.md
- docs/sdks/v1/README.md
- docs/sdks/v2/README.md
- USAGE.md
- models/operations/options.go
Expand All @@ -232,4 +377,5 @@ generatedFiles:
- .devcontainer/devcontainer.json
- .devcontainer/setup.sh
- internal/hooks/hooks.go
- internal/hooks/clientcredentials.go
- CONTRIBUTING.md
2 changes: 1 addition & 1 deletion pkg/client/.speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: true
go:
version: 0.2.0
version: 0.3.0
additionalDependencies: {}
allowUnknownFieldsInWeakUnions: false
clientServerStatusCodesAsErrors: true
Expand Down
Loading

0 comments on commit 03b9a6b

Please sign in to comment.