From 8d402932c1b235302ec16d03e7c69e44c059754d Mon Sep 17 00:00:00 2001 From: Ryan Martin Date: Fri, 2 Aug 2024 23:42:57 +0700 Subject: [PATCH] feat: customize sdk method names --- .github/workflows/sdk_generation.yaml | 1 - .speakeasy/gen.yaml | 2 +- .speakeasy/workflow.lock | 10 +- cardinal/sdk/typescript/.speakeasy/gen.lock | 24 +- cardinal/sdk/typescript/README.md | 26 +- cardinal/sdk/typescript/USAGE.md | 2 +- .../postquerygamequerynamerequest.md | 9 + ...d => postquerygamequerynamerequestbody.md} | 2 +- ... => postquerygamequerynameresponsebody.md} | 2 +- .../postqueryquerygroupquerynamerequest.md | 10 - .../operations/posttxtxgrouptxnamerequest.md | 10 - .../typescript/docs/sdks/cardinal/README.md | 140 +-- cardinal/sdk/typescript/jsr.json | 2 +- cardinal/sdk/typescript/package-lock.json | 4 +- cardinal/sdk/typescript/package.json | 2 +- cardinal/sdk/typescript/src/lib/config.ts | 6 +- .../typescript/src/models/operations/index.ts | 3 +- .../operations/postquerygamequeryname.ts | 138 +++ .../postqueryquerygroupqueryname.ts | 145 --- .../models/operations/posttxtxgrouptxname.ts | 78 -- cardinal/sdk/typescript/src/sdk/sdk.ts | 200 +--- cardinal/server/docs/docs.go | 52 +- cardinal/server/docs/openapi.json | 860 ++++++++++-------- cardinal/server/docs/swagger.json | 52 +- cardinal/server/docs/swagger.yaml | 37 +- cardinal/server/handler/query.go | 16 + makefiles/test.mk | 8 +- scripts/customize-openapi.js | 28 + 28 files changed, 898 insertions(+), 971 deletions(-) create mode 100644 cardinal/sdk/typescript/docs/models/operations/postquerygamequerynamerequest.md rename cardinal/sdk/typescript/docs/models/operations/{postqueryquerygroupquerynamerequestbody.md => postquerygamequerynamerequestbody.md} (78%) rename cardinal/sdk/typescript/docs/models/operations/{postqueryquerygroupquerynameresponsebody.md => postquerygamequerynameresponsebody.md} (78%) delete mode 100644 cardinal/sdk/typescript/docs/models/operations/postqueryquerygroupquerynamerequest.md delete mode 100644 cardinal/sdk/typescript/docs/models/operations/posttxtxgrouptxnamerequest.md create mode 100644 cardinal/sdk/typescript/src/models/operations/postquerygamequeryname.ts delete mode 100644 cardinal/sdk/typescript/src/models/operations/postqueryquerygroupqueryname.ts delete mode 100644 cardinal/sdk/typescript/src/models/operations/posttxtxgrouptxname.ts create mode 100644 scripts/customize-openapi.js diff --git a/.github/workflows/sdk_generation.yaml b/.github/workflows/sdk_generation.yaml index 77520bf3a..5fcea4696 100644 --- a/.github/workflows/sdk_generation.yaml +++ b/.github/workflows/sdk_generation.yaml @@ -27,7 +27,6 @@ jobs: mode: pr set_version: ${{ github.event.inputs.set_version }} speakeasy_version: latest - working_directory: cardinal/sdk/typescript secrets: github_access_token: ${{ secrets.GITHUB_TOKEN }} speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }} diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index d3d9d9ed3..2e765a16f 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: true typescript: - version: 0.0.1 + version: 0.2.2 additionalDependencies: dependencies: {} devDependencies: {} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 257b065ee..494d48ef0 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,17 +1,17 @@ -speakeasyVersion: 1.351.0 +speakeasyVersion: 1.352.0 sources: cardinal: sourceNamespace: cardinal - sourceRevisionDigest: sha256:bacc6ce74a7a215de483bc5bb59e8b673b157ff8f8a7ccf7f14d45487a4826d1 - sourceBlobDigest: sha256:1da8f0bf0677aa13c17ea695edf9d54154114521f0cd10320e6e5c0e8d99e338 + sourceRevisionDigest: sha256:4cc32242239a8a1d711fafed51ea35a0ac5047e15877ab6fd2e7d3bf41a61716 + sourceBlobDigest: sha256:0c2627da1d3124fd952e346bc3c92c28138b31c60eaac80735332a7a90ad9af3 tags: - latest targets: cardinal-ts: source: cardinal sourceNamespace: cardinal - sourceRevisionDigest: sha256:bacc6ce74a7a215de483bc5bb59e8b673b157ff8f8a7ccf7f14d45487a4826d1 - sourceBlobDigest: sha256:1da8f0bf0677aa13c17ea695edf9d54154114521f0cd10320e6e5c0e8d99e338 + sourceRevisionDigest: sha256:4cc32242239a8a1d711fafed51ea35a0ac5047e15877ab6fd2e7d3bf41a61716 + sourceBlobDigest: sha256:0c2627da1d3124fd952e346bc3c92c28138b31c60eaac80735332a7a90ad9af3 outLocation: cardinal/sdk/typescript workflow: workflowVersion: 1.0.0 diff --git a/cardinal/sdk/typescript/.speakeasy/gen.lock b/cardinal/sdk/typescript/.speakeasy/gen.lock index 93246808d..f0338f035 100644 --- a/cardinal/sdk/typescript/.speakeasy/gen.lock +++ b/cardinal/sdk/typescript/.speakeasy/gen.lock @@ -1,20 +1,22 @@ lockVersion: 2.0.0 id: fc6bc2ef-bea2-433a-a006-bbd7c75eb7e5 management: - docChecksum: d11e4c607c38b470780d0598f8624aec + docChecksum: bca4de5ed616447f5a60b1d34a234055 docVersion: 0.0.1 - speakeasyVersion: 1.351.0 - generationVersion: 2.384.1 - releaseVersion: 0.0.1 - configChecksum: 48b480cf853884a3cf0893af8e50dbfa + speakeasyVersion: 1.352.0 + generationVersion: 2.384.4 + releaseVersion: 0.2.2 + configChecksum: e54b7a7f6ee784433e085cd30e3d2e69 features: typescript: additionalDependencies: 0.1.0 - core: 3.11.11 + core: 3.11.12 defaultEnabledRetries: 0.1.0 envVarSecurityUsage: 0.1.0 globalSecurityCallbacks: 0.1.0 globalServerURLs: 2.82.4 + ignores: 2.81.1 + nameOverrides: 2.81.2 responseFormat: 0.2.3 retries: 2.83.0 sdkHooks: 0.1.0 @@ -59,9 +61,8 @@ generatedFiles: - src/models/components/cardinalserverhandlertransaction.ts - src/models/components/cardinalserverhandlergetworldresponse.ts - src/models/components/pkgworlddevworldenginecardinaltypesfielddetail.ts - - src/models/operations/postqueryquerygroupqueryname.ts + - src/models/operations/postquerygamequeryname.ts - src/models/operations/posttxgametxname.ts - - src/models/operations/posttxtxgrouptxname.ts - src/models/errors/index.ts - src/models/components/index.ts - src/models/operations/index.ts @@ -82,11 +83,10 @@ generatedFiles: - docs/models/components/cardinalserverhandlergetworldresponse.md - docs/models/components/fields.md - docs/models/components/pkgworlddevworldenginecardinaltypesfielddetail.md - - docs/models/operations/postqueryquerygroupquerynamerequestbody.md - - docs/models/operations/postqueryquerygroupquerynamerequest.md - - docs/models/operations/postqueryquerygroupquerynameresponsebody.md + - docs/models/operations/postquerygamequerynamerequestbody.md + - docs/models/operations/postquerygamequerynamerequest.md + - docs/models/operations/postquerygamequerynameresponsebody.md - docs/models/operations/posttxgametxnamerequest.md - - docs/models/operations/posttxtxgrouptxnamerequest.md - docs/lib/utils/retryconfig.md - docs/sdks/cardinal/README.md - USAGE.md diff --git a/cardinal/sdk/typescript/README.md b/cardinal/sdk/typescript/README.md index 3b0ce328f..d76efe0d1 100644 --- a/cardinal/sdk/typescript/README.md +++ b/cardinal/sdk/typescript/README.md @@ -64,7 +64,7 @@ import { Cardinal } from "cardinal"; const cardinal = new Cardinal(); async function run() { - const result = await cardinal.postCql({}); + const result = await cardinal.queryCql({}); // Handle the result console.log(result); @@ -80,15 +80,13 @@ run(); ### [Cardinal SDK](docs/sdks/cardinal/README.md) -* [postCql](docs/sdks/cardinal/README.md#postcql) - Executes a CQL (Cardinal Query Language) query -* [postDebugState](docs/sdks/cardinal/README.md#postdebugstate) - Retrieves a list of all entities in the game state -* [getEvents](docs/sdks/cardinal/README.md#getevents) - Establishes a new websocket connection to retrieve system events +* [queryCql](docs/sdks/cardinal/README.md#querycql) - Executes a CQL (Cardinal Query Language) query +* [getDebugState](docs/sdks/cardinal/README.md#getdebugstate) - Retrieves a list of all entities in the game state * [getHealth](docs/sdks/cardinal/README.md#gethealth) - Retrieves the status of the server and game loop -* [postQueryReceiptsList](docs/sdks/cardinal/README.md#postqueryreceiptslist) - Retrieves all transaction receipts -* [postQueryQueryGroupQueryName](docs/sdks/cardinal/README.md#postqueryquerygroupqueryname) - Executes a query -* [postTxGameTxName](docs/sdks/cardinal/README.md#posttxgametxname) - Submits a transaction -* [postTxPersonaCreatePersona](docs/sdks/cardinal/README.md#posttxpersonacreatepersona) - Creates a persona -* [postTxTxGroupTxName](docs/sdks/cardinal/README.md#posttxtxgrouptxname) - Submits a transaction +* [query](docs/sdks/cardinal/README.md#query) - Executes a query +* [getReceipts](docs/sdks/cardinal/README.md#getreceipts) - Retrieves all transaction receipts +* [transact](docs/sdks/cardinal/README.md#transact) - Submits a transaction +* [createPersona](docs/sdks/cardinal/README.md#createpersona) - Creates a persona * [getWorld](docs/sdks/cardinal/README.md#getworld) - Retrieves details of the game world @@ -104,7 +102,7 @@ import { Cardinal } from "cardinal"; const cardinal = new Cardinal(); async function run() { - const result = await cardinal.postCql( + const result = await cardinal.queryCql( {}, { retries: { @@ -146,7 +144,7 @@ const cardinal = new Cardinal({ }); async function run() { - const result = await cardinal.postCql({}); + const result = await cardinal.queryCql({}); // Handle the result console.log(result); @@ -178,7 +176,7 @@ const cardinal = new Cardinal(); async function run() { let result; try { - result = await cardinal.postCql({}); + result = await cardinal.queryCql({}); } catch (err) { switch (true) { case err instanceof SDKValidationError: { @@ -222,7 +220,7 @@ const cardinal = new Cardinal({ }); async function run() { - const result = await cardinal.postCql({}); + const result = await cardinal.queryCql({}); // Handle the result console.log(result); @@ -245,7 +243,7 @@ const cardinal = new Cardinal({ }); async function run() { - const result = await cardinal.postCql({}); + const result = await cardinal.queryCql({}); // Handle the result console.log(result); diff --git a/cardinal/sdk/typescript/USAGE.md b/cardinal/sdk/typescript/USAGE.md index 98d4b8da5..bb2a1c810 100644 --- a/cardinal/sdk/typescript/USAGE.md +++ b/cardinal/sdk/typescript/USAGE.md @@ -5,7 +5,7 @@ import { Cardinal } from "cardinal"; const cardinal = new Cardinal(); async function run() { - const result = await cardinal.postCql({}); + const result = await cardinal.queryCql({}); // Handle the result console.log(result); diff --git a/cardinal/sdk/typescript/docs/models/operations/postquerygamequerynamerequest.md b/cardinal/sdk/typescript/docs/models/operations/postquerygamequerynamerequest.md new file mode 100644 index 000000000..91d7acadb --- /dev/null +++ b/cardinal/sdk/typescript/docs/models/operations/postquerygamequerynamerequest.md @@ -0,0 +1,9 @@ +# PostQueryGameQueryNameRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `queryName` | *string* | :heavy_check_mark: | Name of a registered query | +| `requestBody` | [operations.PostQueryGameQueryNameRequestBody](../../models/operations/postquerygamequerynamerequestbody.md) | :heavy_check_mark: | Query to be executed | \ No newline at end of file diff --git a/cardinal/sdk/typescript/docs/models/operations/postqueryquerygroupquerynamerequestbody.md b/cardinal/sdk/typescript/docs/models/operations/postquerygamequerynamerequestbody.md similarity index 78% rename from cardinal/sdk/typescript/docs/models/operations/postqueryquerygroupquerynamerequestbody.md rename to cardinal/sdk/typescript/docs/models/operations/postquerygamequerynamerequestbody.md index 0593ed4cd..f11d2c340 100644 --- a/cardinal/sdk/typescript/docs/models/operations/postqueryquerygroupquerynamerequestbody.md +++ b/cardinal/sdk/typescript/docs/models/operations/postquerygamequerynamerequestbody.md @@ -1,4 +1,4 @@ -# PostQueryQueryGroupQueryNameRequestBody +# PostQueryGameQueryNameRequestBody Query to be executed diff --git a/cardinal/sdk/typescript/docs/models/operations/postqueryquerygroupquerynameresponsebody.md b/cardinal/sdk/typescript/docs/models/operations/postquerygamequerynameresponsebody.md similarity index 78% rename from cardinal/sdk/typescript/docs/models/operations/postqueryquerygroupquerynameresponsebody.md rename to cardinal/sdk/typescript/docs/models/operations/postquerygamequerynameresponsebody.md index d50f5e149..86ecd65f8 100644 --- a/cardinal/sdk/typescript/docs/models/operations/postqueryquerygroupquerynameresponsebody.md +++ b/cardinal/sdk/typescript/docs/models/operations/postquerygamequerynameresponsebody.md @@ -1,4 +1,4 @@ -# PostQueryQueryGroupQueryNameResponseBody +# PostQueryGameQueryNameResponseBody Results of the executed query diff --git a/cardinal/sdk/typescript/docs/models/operations/postqueryquerygroupquerynamerequest.md b/cardinal/sdk/typescript/docs/models/operations/postqueryquerygroupquerynamerequest.md deleted file mode 100644 index b46b7f729..000000000 --- a/cardinal/sdk/typescript/docs/models/operations/postqueryquerygroupquerynamerequest.md +++ /dev/null @@ -1,10 +0,0 @@ -# PostQueryQueryGroupQueryNameRequest - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | -| `queryGroup` | *string* | :heavy_check_mark: | Query group | -| `queryName` | *string* | :heavy_check_mark: | Name of a registered query | -| `requestBody` | [operations.PostQueryQueryGroupQueryNameRequestBody](../../models/operations/postqueryquerygroupquerynamerequestbody.md) | :heavy_check_mark: | Query to be executed | \ No newline at end of file diff --git a/cardinal/sdk/typescript/docs/models/operations/posttxtxgrouptxnamerequest.md b/cardinal/sdk/typescript/docs/models/operations/posttxtxgrouptxnamerequest.md deleted file mode 100644 index 93c4cc49c..000000000 --- a/cardinal/sdk/typescript/docs/models/operations/posttxtxgrouptxnamerequest.md +++ /dev/null @@ -1,10 +0,0 @@ -# PostTxTxGroupTxNameRequest - - -## Fields - -| Field | Type | Required | Description | -| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | -| `txGroup` | *string* | :heavy_check_mark: | Message group | -| `txName` | *string* | :heavy_check_mark: | Name of a registered message | -| `cardinalServerHandlerTransaction` | [components.CardinalServerHandlerTransaction](../../models/components/cardinalserverhandlertransaction.md) | :heavy_check_mark: | Transaction details & message to be submitted | \ No newline at end of file diff --git a/cardinal/sdk/typescript/docs/sdks/cardinal/README.md b/cardinal/sdk/typescript/docs/sdks/cardinal/README.md index 8af99f971..e9f1798f2 100644 --- a/cardinal/sdk/typescript/docs/sdks/cardinal/README.md +++ b/cardinal/sdk/typescript/docs/sdks/cardinal/README.md @@ -7,18 +7,16 @@ Cardinal: Backend server for World Engine ### Available Operations -* [postCql](#postcql) - Executes a CQL (Cardinal Query Language) query -* [postDebugState](#postdebugstate) - Retrieves a list of all entities in the game state -* [getEvents](#getevents) - Establishes a new websocket connection to retrieve system events +* [queryCql](#querycql) - Executes a CQL (Cardinal Query Language) query +* [getDebugState](#getdebugstate) - Retrieves a list of all entities in the game state * [getHealth](#gethealth) - Retrieves the status of the server and game loop -* [postQueryReceiptsList](#postqueryreceiptslist) - Retrieves all transaction receipts -* [postQueryQueryGroupQueryName](#postqueryquerygroupqueryname) - Executes a query -* [postTxGameTxName](#posttxgametxname) - Submits a transaction -* [postTxPersonaCreatePersona](#posttxpersonacreatepersona) - Creates a persona -* [postTxTxGroupTxName](#posttxtxgrouptxname) - Submits a transaction +* [query](#query) - Executes a query +* [getReceipts](#getreceipts) - Retrieves all transaction receipts +* [transact](#transact) - Submits a transaction +* [createPersona](#createpersona) - Creates a persona * [getWorld](#getworld) - Retrieves details of the game world -## postCql +## queryCql Executes a CQL (Cardinal Query Language) query @@ -30,7 +28,7 @@ import { Cardinal } from "cardinal"; const cardinal = new Cardinal(); async function run() { - const result = await cardinal.postCql({}); + const result = await cardinal.queryCql({}); // Handle the result console.log(result) @@ -58,7 +56,7 @@ run(); | --------------- | --------------- | --------------- | | errors.SDKError | 4xx-5xx | */* | -## postDebugState +## getDebugState Retrieves a list of all entities in the game state @@ -70,7 +68,7 @@ import { Cardinal } from "cardinal"; const cardinal = new Cardinal(); async function run() { - const result = await cardinal.postDebugState(); + const result = await cardinal.getDebugState(); // Handle the result console.log(result) @@ -97,45 +95,6 @@ run(); | --------------- | --------------- | --------------- | | errors.SDKError | 4xx-5xx | */* | -## getEvents - -Establishes a new websocket connection to retrieve system events - -### Example Usage - -```typescript -import { Cardinal } from "cardinal"; - -const cardinal = new Cardinal(); - -async function run() { - const result = await cardinal.getEvents(); - - // Handle the result - console.log(result) -} - -run(); -``` - -### Parameters - -| Parameter | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | -| `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\<[string](../../models/.md)\>** -### Errors - -| Error Object | Status Code | Content Type | -| --------------- | --------------- | --------------- | -| errors.SDKError | 4xx-5xx | */* | - ## getHealth Retrieves the status of the server and game loop @@ -175,9 +134,9 @@ run(); | --------------- | --------------- | --------------- | | errors.SDKError | 4xx-5xx | */* | -## postQueryReceiptsList +## query -Retrieves all transaction receipts +Executes a query ### Example Usage @@ -187,7 +146,10 @@ import { Cardinal } from "cardinal"; const cardinal = new Cardinal(); async function run() { - const result = await cardinal.postQueryReceiptsList({}); + const result = await cardinal.query({ + queryName: "", + requestBody: {}, + }); // Handle the result console.log(result) @@ -200,7 +162,7 @@ run(); | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `request` | [components.CardinalServerHandlerListTxReceiptsRequest](../../models/components/cardinalserverhandlerlisttxreceiptsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `request` | [operations.PostQueryGameQueryNameRequest](../../models/operations/postquerygamequerynamerequest.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `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. | @@ -208,16 +170,16 @@ run(); ### Response -**Promise\<[components.CardinalServerHandlerListTxReceiptsResponse](../../models/components/cardinalserverhandlerlisttxreceiptsresponse.md)\>** +**Promise\<[operations.PostQueryGameQueryNameResponseBody](../../models/operations/postquerygamequerynameresponsebody.md)\>** ### Errors | Error Object | Status Code | Content Type | | --------------- | --------------- | --------------- | | errors.SDKError | 4xx-5xx | */* | -## postQueryQueryGroupQueryName +## getReceipts -Executes a query +Retrieves all transaction receipts ### Example Usage @@ -227,11 +189,7 @@ import { Cardinal } from "cardinal"; const cardinal = new Cardinal(); async function run() { - const result = await cardinal.postQueryQueryGroupQueryName({ - queryGroup: "", - queryName: "", - requestBody: {}, - }); + const result = await cardinal.getReceipts({}); // Handle the result console.log(result) @@ -244,7 +202,7 @@ run(); | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `request` | [operations.PostQueryQueryGroupQueryNameRequest](../../models/operations/postqueryquerygroupquerynamerequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `request` | [components.CardinalServerHandlerListTxReceiptsRequest](../../models/components/cardinalserverhandlerlisttxreceiptsrequest.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `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. | @@ -252,14 +210,14 @@ run(); ### Response -**Promise\<[operations.PostQueryQueryGroupQueryNameResponseBody](../../models/operations/postqueryquerygroupquerynameresponsebody.md)\>** +**Promise\<[components.CardinalServerHandlerListTxReceiptsResponse](../../models/components/cardinalserverhandlerlisttxreceiptsresponse.md)\>** ### Errors | Error Object | Status Code | Content Type | | --------------- | --------------- | --------------- | | errors.SDKError | 4xx-5xx | */* | -## postTxGameTxName +## transact Submits a transaction @@ -271,7 +229,7 @@ import { Cardinal } from "cardinal"; const cardinal = new Cardinal(); async function run() { - const result = await cardinal.postTxGameTxName({ + const result = await cardinal.transact({ txName: "", cardinalServerHandlerTransaction: {}, }); @@ -302,7 +260,7 @@ run(); | --------------- | --------------- | --------------- | | errors.SDKError | 4xx-5xx | */* | -## postTxPersonaCreatePersona +## createPersona Creates a persona @@ -314,7 +272,7 @@ import { Cardinal } from "cardinal"; const cardinal = new Cardinal(); async function run() { - const result = await cardinal.postTxPersonaCreatePersona({}); + const result = await cardinal.createPersona({}); // Handle the result console.log(result) @@ -333,50 +291,6 @@ run(); | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | -### Response - -**Promise\<[components.CardinalServerHandlerPostTransactionResponse](../../models/components/cardinalserverhandlerposttransactionresponse.md)\>** -### Errors - -| Error Object | Status Code | Content Type | -| --------------- | --------------- | --------------- | -| errors.SDKError | 4xx-5xx | */* | - -## postTxTxGroupTxName - -Submits a transaction - -### Example Usage - -```typescript -import { Cardinal } from "cardinal"; - -const cardinal = new Cardinal(); - -async function run() { - const result = await cardinal.postTxTxGroupTxName({ - txGroup: "", - txName: "", - cardinalServerHandlerTransaction: {}, - }); - - // Handle the result - console.log(result) -} - -run(); -``` - -### Parameters - -| Parameter | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `request` | [operations.PostTxTxGroupTxNameRequest](../../models/operations/posttxtxgrouptxnamerequest.md) | :heavy_check_mark: | The request object to use for the request. | -| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | -| `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\<[components.CardinalServerHandlerPostTransactionResponse](../../models/components/cardinalserverhandlerposttransactionresponse.md)\>** diff --git a/cardinal/sdk/typescript/jsr.json b/cardinal/sdk/typescript/jsr.json index b405a8dcd..b794bf820 100644 --- a/cardinal/sdk/typescript/jsr.json +++ b/cardinal/sdk/typescript/jsr.json @@ -2,7 +2,7 @@ { "name": "cardinal", - "version": "0.0.1", + "version": "0.2.2", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/cardinal/sdk/typescript/package-lock.json b/cardinal/sdk/typescript/package-lock.json index 11593da82..05c029204 100644 --- a/cardinal/sdk/typescript/package-lock.json +++ b/cardinal/sdk/typescript/package-lock.json @@ -1,12 +1,12 @@ { "name": "cardinal", - "version": "0.0.1", + "version": "0.2.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cardinal", - "version": "0.0.1", + "version": "0.2.2", "devDependencies": { "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", diff --git a/cardinal/sdk/typescript/package.json b/cardinal/sdk/typescript/package.json index e61bc99e9..b3c3bb73e 100644 --- a/cardinal/sdk/typescript/package.json +++ b/cardinal/sdk/typescript/package.json @@ -1,6 +1,6 @@ { "name": "cardinal", - "version": "0.0.1", + "version": "0.2.2", "author": "Argus Labs", "main": "./index.js", "sideEffects": false, diff --git a/cardinal/sdk/typescript/src/lib/config.ts b/cardinal/sdk/typescript/src/lib/config.ts index 5aeaab30f..7d57af46a 100644 --- a/cardinal/sdk/typescript/src/lib/config.ts +++ b/cardinal/sdk/typescript/src/lib/config.ts @@ -48,7 +48,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "0.0.1", - sdkVersion: "0.0.1", - genVersion: "2.384.1", - userAgent: "speakeasy-sdk/typescript 0.0.1 2.384.1 0.0.1 cardinal", + sdkVersion: "0.2.2", + genVersion: "2.384.4", + userAgent: "speakeasy-sdk/typescript 0.2.2 2.384.4 0.0.1 cardinal", } as const; diff --git a/cardinal/sdk/typescript/src/models/operations/index.ts b/cardinal/sdk/typescript/src/models/operations/index.ts index 4d76ed647..a931ace09 100644 --- a/cardinal/sdk/typescript/src/models/operations/index.ts +++ b/cardinal/sdk/typescript/src/models/operations/index.ts @@ -2,6 +2,5 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export * from "./postqueryquerygroupqueryname.js"; +export * from "./postquerygamequeryname.js"; export * from "./posttxgametxname.js"; -export * from "./posttxtxgrouptxname.js"; diff --git a/cardinal/sdk/typescript/src/models/operations/postquerygamequeryname.ts b/cardinal/sdk/typescript/src/models/operations/postquerygamequeryname.ts new file mode 100644 index 000000000..d73c39c47 --- /dev/null +++ b/cardinal/sdk/typescript/src/models/operations/postquerygamequeryname.ts @@ -0,0 +1,138 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { remap as remap$ } from "../../lib/primitives.js"; +import * as z from "zod"; + +/** + * Query to be executed + */ +export type PostQueryGameQueryNameRequestBody = {}; + +export type PostQueryGameQueryNameRequest = { + /** + * Name of a registered query + */ + queryName: string; + /** + * Query to be executed + */ + requestBody: PostQueryGameQueryNameRequestBody; +}; + +/** + * Results of the executed query + */ +export type PostQueryGameQueryNameResponseBody = {}; + +/** @internal */ +export const PostQueryGameQueryNameRequestBody$inboundSchema: z.ZodType< + PostQueryGameQueryNameRequestBody, + z.ZodTypeDef, + unknown +> = z.object({}); + +/** @internal */ +export type PostQueryGameQueryNameRequestBody$Outbound = {}; + +/** @internal */ +export const PostQueryGameQueryNameRequestBody$outboundSchema: z.ZodType< + PostQueryGameQueryNameRequestBody$Outbound, + z.ZodTypeDef, + PostQueryGameQueryNameRequestBody +> = z.object({}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace PostQueryGameQueryNameRequestBody$ { + /** @deprecated use `PostQueryGameQueryNameRequestBody$inboundSchema` instead. */ + export const inboundSchema = PostQueryGameQueryNameRequestBody$inboundSchema; + /** @deprecated use `PostQueryGameQueryNameRequestBody$outboundSchema` instead. */ + export const outboundSchema = PostQueryGameQueryNameRequestBody$outboundSchema; + /** @deprecated use `PostQueryGameQueryNameRequestBody$Outbound` instead. */ + export type Outbound = PostQueryGameQueryNameRequestBody$Outbound; +} + +/** @internal */ +export const PostQueryGameQueryNameRequest$inboundSchema: z.ZodType< + PostQueryGameQueryNameRequest, + z.ZodTypeDef, + unknown +> = z + .object({ + queryName: z.string(), + RequestBody: z.lazy(() => PostQueryGameQueryNameRequestBody$inboundSchema), + }) + .transform((v) => { + return remap$(v, { + RequestBody: "requestBody", + }); + }); + +/** @internal */ +export type PostQueryGameQueryNameRequest$Outbound = { + queryName: string; + RequestBody: PostQueryGameQueryNameRequestBody$Outbound; +}; + +/** @internal */ +export const PostQueryGameQueryNameRequest$outboundSchema: z.ZodType< + PostQueryGameQueryNameRequest$Outbound, + z.ZodTypeDef, + PostQueryGameQueryNameRequest +> = z + .object({ + queryName: z.string(), + requestBody: z.lazy(() => PostQueryGameQueryNameRequestBody$outboundSchema), + }) + .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 PostQueryGameQueryNameRequest$ { + /** @deprecated use `PostQueryGameQueryNameRequest$inboundSchema` instead. */ + export const inboundSchema = PostQueryGameQueryNameRequest$inboundSchema; + /** @deprecated use `PostQueryGameQueryNameRequest$outboundSchema` instead. */ + export const outboundSchema = PostQueryGameQueryNameRequest$outboundSchema; + /** @deprecated use `PostQueryGameQueryNameRequest$Outbound` instead. */ + export type Outbound = PostQueryGameQueryNameRequest$Outbound; +} + +/** @internal */ +export const PostQueryGameQueryNameResponseBody$inboundSchema: z.ZodType< + PostQueryGameQueryNameResponseBody, + z.ZodTypeDef, + unknown +> = z.object({}); + +/** @internal */ +export type PostQueryGameQueryNameResponseBody$Outbound = {}; + +/** @internal */ +export const PostQueryGameQueryNameResponseBody$outboundSchema: z.ZodType< + PostQueryGameQueryNameResponseBody$Outbound, + z.ZodTypeDef, + PostQueryGameQueryNameResponseBody +> = z.object({}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace PostQueryGameQueryNameResponseBody$ { + /** @deprecated use `PostQueryGameQueryNameResponseBody$inboundSchema` instead. */ + export const inboundSchema = PostQueryGameQueryNameResponseBody$inboundSchema; + /** @deprecated use `PostQueryGameQueryNameResponseBody$outboundSchema` instead. */ + export const outboundSchema = PostQueryGameQueryNameResponseBody$outboundSchema; + /** @deprecated use `PostQueryGameQueryNameResponseBody$Outbound` instead. */ + export type Outbound = PostQueryGameQueryNameResponseBody$Outbound; +} diff --git a/cardinal/sdk/typescript/src/models/operations/postqueryquerygroupqueryname.ts b/cardinal/sdk/typescript/src/models/operations/postqueryquerygroupqueryname.ts deleted file mode 100644 index e1674284f..000000000 --- a/cardinal/sdk/typescript/src/models/operations/postqueryquerygroupqueryname.ts +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ - -import { remap as remap$ } from "../../lib/primitives.js"; -import * as z from "zod"; - -/** - * Query to be executed - */ -export type PostQueryQueryGroupQueryNameRequestBody = {}; - -export type PostQueryQueryGroupQueryNameRequest = { - /** - * Query group - */ - queryGroup: string; - /** - * Name of a registered query - */ - queryName: string; - /** - * Query to be executed - */ - requestBody: PostQueryQueryGroupQueryNameRequestBody; -}; - -/** - * Results of the executed query - */ -export type PostQueryQueryGroupQueryNameResponseBody = {}; - -/** @internal */ -export const PostQueryQueryGroupQueryNameRequestBody$inboundSchema: z.ZodType< - PostQueryQueryGroupQueryNameRequestBody, - z.ZodTypeDef, - unknown -> = z.object({}); - -/** @internal */ -export type PostQueryQueryGroupQueryNameRequestBody$Outbound = {}; - -/** @internal */ -export const PostQueryQueryGroupQueryNameRequestBody$outboundSchema: z.ZodType< - PostQueryQueryGroupQueryNameRequestBody$Outbound, - z.ZodTypeDef, - PostQueryQueryGroupQueryNameRequestBody -> = z.object({}); - -/** - * @internal - * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. - */ -export namespace PostQueryQueryGroupQueryNameRequestBody$ { - /** @deprecated use `PostQueryQueryGroupQueryNameRequestBody$inboundSchema` instead. */ - export const inboundSchema = PostQueryQueryGroupQueryNameRequestBody$inboundSchema; - /** @deprecated use `PostQueryQueryGroupQueryNameRequestBody$outboundSchema` instead. */ - export const outboundSchema = PostQueryQueryGroupQueryNameRequestBody$outboundSchema; - /** @deprecated use `PostQueryQueryGroupQueryNameRequestBody$Outbound` instead. */ - export type Outbound = PostQueryQueryGroupQueryNameRequestBody$Outbound; -} - -/** @internal */ -export const PostQueryQueryGroupQueryNameRequest$inboundSchema: z.ZodType< - PostQueryQueryGroupQueryNameRequest, - z.ZodTypeDef, - unknown -> = z - .object({ - queryGroup: z.string(), - queryName: z.string(), - RequestBody: z.lazy(() => PostQueryQueryGroupQueryNameRequestBody$inboundSchema), - }) - .transform((v) => { - return remap$(v, { - RequestBody: "requestBody", - }); - }); - -/** @internal */ -export type PostQueryQueryGroupQueryNameRequest$Outbound = { - queryGroup: string; - queryName: string; - RequestBody: PostQueryQueryGroupQueryNameRequestBody$Outbound; -}; - -/** @internal */ -export const PostQueryQueryGroupQueryNameRequest$outboundSchema: z.ZodType< - PostQueryQueryGroupQueryNameRequest$Outbound, - z.ZodTypeDef, - PostQueryQueryGroupQueryNameRequest -> = z - .object({ - queryGroup: z.string(), - queryName: z.string(), - requestBody: z.lazy(() => PostQueryQueryGroupQueryNameRequestBody$outboundSchema), - }) - .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 PostQueryQueryGroupQueryNameRequest$ { - /** @deprecated use `PostQueryQueryGroupQueryNameRequest$inboundSchema` instead. */ - export const inboundSchema = PostQueryQueryGroupQueryNameRequest$inboundSchema; - /** @deprecated use `PostQueryQueryGroupQueryNameRequest$outboundSchema` instead. */ - export const outboundSchema = PostQueryQueryGroupQueryNameRequest$outboundSchema; - /** @deprecated use `PostQueryQueryGroupQueryNameRequest$Outbound` instead. */ - export type Outbound = PostQueryQueryGroupQueryNameRequest$Outbound; -} - -/** @internal */ -export const PostQueryQueryGroupQueryNameResponseBody$inboundSchema: z.ZodType< - PostQueryQueryGroupQueryNameResponseBody, - z.ZodTypeDef, - unknown -> = z.object({}); - -/** @internal */ -export type PostQueryQueryGroupQueryNameResponseBody$Outbound = {}; - -/** @internal */ -export const PostQueryQueryGroupQueryNameResponseBody$outboundSchema: z.ZodType< - PostQueryQueryGroupQueryNameResponseBody$Outbound, - z.ZodTypeDef, - PostQueryQueryGroupQueryNameResponseBody -> = z.object({}); - -/** - * @internal - * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. - */ -export namespace PostQueryQueryGroupQueryNameResponseBody$ { - /** @deprecated use `PostQueryQueryGroupQueryNameResponseBody$inboundSchema` instead. */ - export const inboundSchema = PostQueryQueryGroupQueryNameResponseBody$inboundSchema; - /** @deprecated use `PostQueryQueryGroupQueryNameResponseBody$outboundSchema` instead. */ - export const outboundSchema = PostQueryQueryGroupQueryNameResponseBody$outboundSchema; - /** @deprecated use `PostQueryQueryGroupQueryNameResponseBody$Outbound` instead. */ - export type Outbound = PostQueryQueryGroupQueryNameResponseBody$Outbound; -} diff --git a/cardinal/sdk/typescript/src/models/operations/posttxtxgrouptxname.ts b/cardinal/sdk/typescript/src/models/operations/posttxtxgrouptxname.ts deleted file mode 100644 index e351b84aa..000000000 --- a/cardinal/sdk/typescript/src/models/operations/posttxtxgrouptxname.ts +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ - -import { remap as remap$ } from "../../lib/primitives.js"; -import * as components from "../components/index.js"; -import * as z from "zod"; - -export type PostTxTxGroupTxNameRequest = { - /** - * Message group - */ - txGroup: string; - /** - * Name of a registered message - */ - txName: string; - /** - * Transaction details & message to be submitted - */ - cardinalServerHandlerTransaction: components.CardinalServerHandlerTransaction; -}; - -/** @internal */ -export const PostTxTxGroupTxNameRequest$inboundSchema: z.ZodType< - PostTxTxGroupTxNameRequest, - z.ZodTypeDef, - unknown -> = z - .object({ - txGroup: z.string(), - txName: z.string(), - "cardinal_server_handler.Transaction": - components.CardinalServerHandlerTransaction$inboundSchema, - }) - .transform((v) => { - return remap$(v, { - "cardinal_server_handler.Transaction": "cardinalServerHandlerTransaction", - }); - }); - -/** @internal */ -export type PostTxTxGroupTxNameRequest$Outbound = { - txGroup: string; - txName: string; - "cardinal_server_handler.Transaction": components.CardinalServerHandlerTransaction$Outbound; -}; - -/** @internal */ -export const PostTxTxGroupTxNameRequest$outboundSchema: z.ZodType< - PostTxTxGroupTxNameRequest$Outbound, - z.ZodTypeDef, - PostTxTxGroupTxNameRequest -> = z - .object({ - txGroup: z.string(), - txName: z.string(), - cardinalServerHandlerTransaction: - components.CardinalServerHandlerTransaction$outboundSchema, - }) - .transform((v) => { - return remap$(v, { - cardinalServerHandlerTransaction: "cardinal_server_handler.Transaction", - }); - }); - -/** - * @internal - * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. - */ -export namespace PostTxTxGroupTxNameRequest$ { - /** @deprecated use `PostTxTxGroupTxNameRequest$inboundSchema` instead. */ - export const inboundSchema = PostTxTxGroupTxNameRequest$inboundSchema; - /** @deprecated use `PostTxTxGroupTxNameRequest$outboundSchema` instead. */ - export const outboundSchema = PostTxTxGroupTxNameRequest$outboundSchema; - /** @deprecated use `PostTxTxGroupTxNameRequest$Outbound` instead. */ - export type Outbound = PostTxTxGroupTxNameRequest$Outbound; -} diff --git a/cardinal/sdk/typescript/src/sdk/sdk.ts b/cardinal/sdk/typescript/src/sdk/sdk.ts index 510f04296..dfeef63c8 100644 --- a/cardinal/sdk/typescript/src/sdk/sdk.ts +++ b/cardinal/sdk/typescript/src/sdk/sdk.ts @@ -45,7 +45,7 @@ export class Cardinal extends ClientSDK { * @remarks * Executes a CQL (Cardinal Query Language) query */ - async postCql( + async queryCql( request: components.CardinalServerHandlerCQLQueryRequest, options?: RequestOptions ): Promise { @@ -104,7 +104,7 @@ export class Cardinal extends ClientSDK { * @remarks * Retrieves a list of all entities in the game state */ - async postDebugState( + async getDebugState( options?: RequestOptions ): Promise> { const path$ = this.templateURLComponent("/debug/state")(); @@ -155,51 +155,6 @@ export class Cardinal extends ClientSDK { return result$; } - /** - * Establishes a new websocket connection to retrieve system events - * - * @remarks - * Establishes a new websocket connection to retrieve system events - */ - async getEvents(options?: RequestOptions): Promise { - const path$ = this.templateURLComponent("/events")(); - - const query$ = ""; - - const headers$ = new Headers({ - Accept: "application/json", - }); - - const context = { operationID: "get_/events", oAuth2Scopes: [], securitySource: null }; - - const request$ = this.createRequest$( - context, - { - method: "GET", - path: path$, - headers: headers$, - query: query$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const [result$] = await this.matcher() - .json(101, z.string().optional()) - .void("2XX", z.string().optional()) - .fail(["4XX", "5XX"]) - .match(response); - - return result$; - } - /** * Retrieves the status of the server and game loop * @@ -247,26 +202,31 @@ export class Cardinal extends ClientSDK { } /** - * Retrieves all transaction receipts + * Executes a query * * @remarks - * Retrieves all transaction receipts + * Executes a query */ - async postQueryReceiptsList( - request: components.CardinalServerHandlerListTxReceiptsRequest, + async query( + request: operations.PostQueryGameQueryNameRequest, options?: RequestOptions - ): Promise { + ): Promise { const input$ = request; const payload$ = schemas$.parse( input$, - (value$) => - components.CardinalServerHandlerListTxReceiptsRequest$outboundSchema.parse(value$), + (value$) => operations.PostQueryGameQueryNameRequest$outboundSchema.parse(value$), "Input validation failed" ); - const body$ = encodeJSON$("body", payload$, { explode: true }); + const body$ = encodeJSON$("body", payload$.RequestBody, { explode: true }); - const path$ = this.templateURLComponent("/query/receipts/list")(); + const pathParams$ = { + queryName: encodeSimple$("queryName", payload$.queryName, { + explode: false, + charEncoding: "percent", + }), + }; + const path$ = this.templateURLComponent("/query/game/{queryName}")(pathParams$); const query$ = ""; @@ -276,7 +236,7 @@ export class Cardinal extends ClientSDK { }); const context = { - operationID: "post_/query/receipts/list", + operationID: "post_/query/game/{queryName}", oAuth2Scopes: [], securitySource: null, }; @@ -301,45 +261,35 @@ export class Cardinal extends ClientSDK { retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }); - const [result$] = - await this.matcher() - .json(200, components.CardinalServerHandlerListTxReceiptsResponse$inboundSchema) - .fail([400, "4XX", "5XX"]) - .match(response); + const [result$] = await this.matcher() + .json(200, operations.PostQueryGameQueryNameResponseBody$inboundSchema) + .fail([400, "4XX", "5XX"]) + .match(response); return result$; } /** - * Executes a query + * Retrieves all transaction receipts * * @remarks - * Executes a query + * Retrieves all transaction receipts */ - async postQueryQueryGroupQueryName( - request: operations.PostQueryQueryGroupQueryNameRequest, + async getReceipts( + request: components.CardinalServerHandlerListTxReceiptsRequest, options?: RequestOptions - ): Promise { + ): Promise { const input$ = request; const payload$ = schemas$.parse( input$, - (value$) => operations.PostQueryQueryGroupQueryNameRequest$outboundSchema.parse(value$), + (value$) => + components.CardinalServerHandlerListTxReceiptsRequest$outboundSchema.parse(value$), "Input validation failed" ); - const body$ = encodeJSON$("body", payload$.RequestBody, { explode: true }); + const body$ = encodeJSON$("body", payload$, { explode: true }); - const pathParams$ = { - queryGroup: encodeSimple$("queryGroup", payload$.queryGroup, { - explode: false, - charEncoding: "percent", - }), - queryName: encodeSimple$("queryName", payload$.queryName, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent("/query/{queryGroup}/{queryName}")(pathParams$); + const path$ = this.templateURLComponent("/query/receipts/list")(); const query$ = ""; @@ -349,7 +299,7 @@ export class Cardinal extends ClientSDK { }); const context = { - operationID: "post_/query/{queryGroup}/{queryName}", + operationID: "post_/query/receipts/list", oAuth2Scopes: [], securitySource: null, }; @@ -374,10 +324,11 @@ export class Cardinal extends ClientSDK { retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }); - const [result$] = await this.matcher() - .json(200, operations.PostQueryQueryGroupQueryNameResponseBody$inboundSchema) - .fail([400, "4XX", "5XX"]) - .match(response); + const [result$] = + await this.matcher() + .json(200, components.CardinalServerHandlerListTxReceiptsResponse$inboundSchema) + .fail([400, "4XX", "5XX"]) + .match(response); return result$; } @@ -388,7 +339,7 @@ export class Cardinal extends ClientSDK { * @remarks * Submits a transaction */ - async postTxGameTxName( + async transact( request: operations.PostTxGameTxNameRequest, options?: RequestOptions ): Promise { @@ -459,7 +410,7 @@ export class Cardinal extends ClientSDK { * @remarks * Creates a persona */ - async postTxPersonaCreatePersona( + async createPersona( request: components.CardinalServerHandlerTransaction, options?: RequestOptions ): Promise { @@ -516,81 +467,6 @@ export class Cardinal extends ClientSDK { return result$; } - /** - * Submits a transaction - * - * @remarks - * Submits a transaction - */ - async postTxTxGroupTxName( - request: operations.PostTxTxGroupTxNameRequest, - options?: RequestOptions - ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.PostTxTxGroupTxNameRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = encodeJSON$("body", payload$["cardinal_server_handler.Transaction"], { - explode: true, - }); - - const pathParams$ = { - txGroup: encodeSimple$("txGroup", payload$.txGroup, { - explode: false, - charEncoding: "percent", - }), - txName: encodeSimple$("txName", payload$.txName, { - explode: false, - charEncoding: "percent", - }), - }; - const path$ = this.templateURLComponent("/tx/{txGroup}/{txName}")(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - }); - - const context = { - operationID: "post_/tx/{txGroup}/{txName}", - oAuth2Scopes: [], - securitySource: null, - }; - - const request$ = this.createRequest$( - context, - { - 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", "4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const [result$] = - await this.matcher() - .json(200, components.CardinalServerHandlerPostTransactionResponse$inboundSchema) - .fail([400, "4XX", "5XX"]) - .match(response); - - return result$; - } - /** * Retrieves details of the game world * diff --git a/cardinal/server/docs/docs.go b/cardinal/server/docs/docs.go index 3b0d038a6..9e2dcdd36 100644 --- a/cardinal/server/docs/docs.go +++ b/cardinal/server/docs/docs.go @@ -106,6 +106,50 @@ const docTemplate = `{ } } }, + "/query/game/{queryName}": { + "post": { + "description": "Executes a query", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Executes a query", + "parameters": [ + { + "type": "string", + "description": "Name of a registered query", + "name": "queryName", + "in": "path", + "required": true + }, + { + "description": "Query to be executed", + "name": "queryBody", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "Results of the executed query", + "schema": { + "type": "object" + } + }, + "400": { + "description": "Invalid request parameters", + "schema": { + "type": "string" + } + } + } + } + }, "/query/receipts/list": { "post": { "description": "Retrieves all transaction receipts", @@ -490,10 +534,10 @@ const docTemplate = `{ } } }, - "pkg_world_dev_world-engine_cardinal_types.EntityStateElement": { + "pkg_world_dev_world-engine_cardinal_types.DebugStateElement": { "type": "object", "properties": { - "data": { + "components": { "type": "object" }, "id": { @@ -501,10 +545,10 @@ const docTemplate = `{ } } }, - "pkg_world_dev_world-engine_cardinal_types.DebugStateElement": { + "pkg_world_dev_world-engine_cardinal_types.EntityStateElement": { "type": "object", "properties": { - "components": { + "data": { "type": "object" }, "id": { diff --git a/cardinal/server/docs/openapi.json b/cardinal/server/docs/openapi.json index d56c99574..bb2f385bd 100644 --- a/cardinal/server/docs/openapi.json +++ b/cardinal/server/docs/openapi.json @@ -1,579 +1,653 @@ { - "openapi" : "3.0.1", - "info" : { - "title" : "Cardinal", - "description" : "Backend server for World Engine", - "contact" : { }, - "version" : "0.0.1" + "openapi": "3.0.1", + "info": { + "title": "Cardinal", + "description": "Backend server for World Engine", + "contact": {}, + "version": "0.0.1" }, - "servers" : [ { - "url" : "/" - } ], - "paths" : { - "/cql" : { - "post" : { - "summary" : "Executes a CQL (Cardinal Query Language) query", - "description" : "Executes a CQL (Cardinal Query Language) query", - "requestBody" : { - "description" : "CQL query to be executed", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/cardinal_server_handler.CQLQueryRequest" + "servers": [ + { + "url": "/" + } + ], + "paths": { + "/cql": { + "post": { + "summary": "Executes a CQL (Cardinal Query Language) query", + "description": "Executes a CQL (Cardinal Query Language) query", + "requestBody": { + "description": "CQL query to be executed", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/cardinal_server_handler.CQLQueryRequest" } } }, - "required" : true + "required": true }, - "responses" : { - "200" : { - "description" : "Results of the executed CQL query", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/cardinal_server_handler.CQLQueryResponse" + "responses": { + "200": { + "description": "Results of the executed CQL query", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/cardinal_server_handler.CQLQueryResponse" } } } }, - "400" : { - "description" : "Invalid request parameters", - "content" : { - "application/json" : { - "schema" : { - "type" : "string" + "400": { + "description": "Invalid request parameters", + "content": { + "application/json": { + "schema": { + "type": "string" } } } } }, - "x-codegen-request-body-name" : "cql" + "x-codegen-request-body-name": "cql", + "x-speakeasy-name-override": "queryCql" } }, - "/debug/state" : { - "post" : { - "summary" : "Retrieves a list of all entities in the game state", - "description" : "Retrieves a list of all entities in the game state", - "responses" : { - "200" : { - "description" : "List of all entities", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/pkg_world_dev_world-engine_cardinal_types.DebugStateElement" + "/debug/state": { + "post": { + "summary": "Retrieves a list of all entities in the game state", + "description": "Retrieves a list of all entities in the game state", + "responses": { + "200": { + "description": "List of all entities", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pkg_world_dev_world-engine_cardinal_types.DebugStateElement" } } } } } - } + }, + "x-speakeasy-name-override": "getDebugState" } }, - "/events" : { - "get" : { - "summary" : "Establishes a new websocket connection to retrieve system events", - "description" : "Establishes a new websocket connection to retrieve system events", - "responses" : { - "101" : { - "description" : "Switch protocol to ws", - "content" : { - "application/json" : { - "schema" : { - "type" : "string" + "/events": { + "get": { + "summary": "Establishes a new websocket connection to retrieve system events", + "description": "Establishes a new websocket connection to retrieve system events", + "responses": { + "101": { + "description": "Switch protocol to ws", + "content": { + "application/json": { + "schema": { + "type": "string" } } } } - } + }, + "x-speakeasy-ignore": true } }, - "/health" : { - "get" : { - "summary" : "Retrieves the status of the server and game loop", - "description" : "Retrieves the status of the server and game loop", - "responses" : { - "200" : { - "description" : "Server and game loop status", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/cardinal_server_handler.GetHealthResponse" + "/health": { + "get": { + "summary": "Retrieves the status of the server and game loop", + "description": "Retrieves the status of the server and game loop", + "responses": { + "200": { + "description": "Server and game loop status", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/cardinal_server_handler.GetHealthResponse" } } } } - } + }, + "x-speakeasy-name-override": "getHealth" } }, - "/query/receipts/list" : { - "post" : { - "summary" : "Retrieves all transaction receipts", - "description" : "Retrieves all transaction receipts", - "requestBody" : { - "description" : "Query body", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/cardinal_server_handler.ListTxReceiptsRequest" + "/query/game/{queryName}": { + "post": { + "summary": "Executes a query", + "description": "Executes a query", + "parameters": [ + { + "name": "queryName", + "in": "path", + "description": "Name of a registered query", + "required": true, + "style": "simple", + "explode": false, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "Query to be executed", + "content": { + "application/json": { + "schema": { + "type": "object" } } }, - "required" : true + "required": true }, - "responses" : { - "200" : { - "description" : "List of receipts", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/cardinal_server_handler.ListTxReceiptsResponse" + "responses": { + "200": { + "description": "Results of the executed query", + "content": { + "application/json": { + "schema": { + "type": "object" } } } }, - "400" : { - "description" : "Invalid request body", - "content" : { - "application/json" : { - "schema" : { - "type" : "string" + "400": { + "description": "Invalid request parameters", + "content": { + "application/json": { + "schema": { + "type": "string" } } } } }, - "x-codegen-request-body-name" : "ListTxReceiptsRequest" + "x-codegen-request-body-name": "queryBody", + "x-speakeasy-name-override": "query" } }, - "/query/{queryGroup}/{queryName}" : { - "post" : { - "summary" : "Executes a query", - "description" : "Executes a query", - "parameters" : [ { - "name" : "queryGroup", - "in" : "path", - "description" : "Query group", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" + "/query/receipts/list": { + "post": { + "summary": "Retrieves all transaction receipts", + "description": "Retrieves all transaction receipts", + "requestBody": { + "description": "Query body", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/cardinal_server_handler.ListTxReceiptsRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "List of receipts", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/cardinal_server_handler.ListTxReceiptsResponse" + } + } + } + }, + "400": { + "description": "Invalid request body", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } } - }, { - "name" : "queryName", - "in" : "path", - "description" : "Name of a registered query", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" + }, + "x-codegen-request-body-name": "ListTxReceiptsRequest", + "x-speakeasy-name-override": "getReceipts" + } + }, + "/query/{queryGroup}/{queryName}": { + "post": { + "summary": "Executes a query", + "description": "Executes a query", + "parameters": [ + { + "name": "queryGroup", + "in": "path", + "description": "Query group", + "required": true, + "style": "simple", + "explode": false, + "schema": { + "type": "string" + } + }, + { + "name": "queryName", + "in": "path", + "description": "Name of a registered query", + "required": true, + "style": "simple", + "explode": false, + "schema": { + "type": "string" + } } - } ], - "requestBody" : { - "description" : "Query to be executed", - "content" : { - "application/json" : { - "schema" : { - "type" : "object" + ], + "requestBody": { + "description": "Query to be executed", + "content": { + "application/json": { + "schema": { + "type": "object" } } }, - "required" : true + "required": true }, - "responses" : { - "200" : { - "description" : "Results of the executed query", - "content" : { - "application/json" : { - "schema" : { - "type" : "object" + "responses": { + "200": { + "description": "Results of the executed query", + "content": { + "application/json": { + "schema": { + "type": "object" } } } }, - "400" : { - "description" : "Invalid request parameters", - "content" : { - "application/json" : { - "schema" : { - "type" : "string" + "400": { + "description": "Invalid request parameters", + "content": { + "application/json": { + "schema": { + "type": "string" } } } } }, - "x-codegen-request-body-name" : "queryBody" + "x-codegen-request-body-name": "queryBody", + "x-speakeasy-ignore": true } }, - "/tx/game/{txName}" : { - "post" : { - "summary" : "Submits a transaction", - "description" : "Submits a transaction", - "parameters" : [ { - "name" : "txName", - "in" : "path", - "description" : "Name of a registered message", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" + "/tx/game/{txName}": { + "post": { + "summary": "Submits a transaction", + "description": "Submits a transaction", + "parameters": [ + { + "name": "txName", + "in": "path", + "description": "Name of a registered message", + "required": true, + "style": "simple", + "explode": false, + "schema": { + "type": "string" + } } - } ], - "requestBody" : { - "description" : "Transaction details & message to be submitted", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/cardinal_server_handler.Transaction" + ], + "requestBody": { + "description": "Transaction details & message to be submitted", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/cardinal_server_handler.Transaction" } } }, - "required" : true + "required": true }, - "responses" : { - "200" : { - "description" : "Transaction hash and tick", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/cardinal_server_handler.PostTransactionResponse" + "responses": { + "200": { + "description": "Transaction hash and tick", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/cardinal_server_handler.PostTransactionResponse" } } } }, - "400" : { - "description" : "Invalid request parameter", - "content" : { - "application/json" : { - "schema" : { - "type" : "string" + "400": { + "description": "Invalid request parameter", + "content": { + "application/json": { + "schema": { + "type": "string" } } } } }, - "x-codegen-request-body-name" : "txBody" + "x-codegen-request-body-name": "txBody", + "x-speakeasy-name-override": "transact" } }, - "/tx/persona/create-persona" : { - "post" : { - "summary" : "Creates a persona", - "description" : "Creates a persona", - "requestBody" : { - "description" : "Transaction details & message to be submitted", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/cardinal_server_handler.Transaction" + "/tx/persona/create-persona": { + "post": { + "summary": "Creates a persona", + "description": "Creates a persona", + "requestBody": { + "description": "Transaction details & message to be submitted", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/cardinal_server_handler.Transaction" } } }, - "required" : true + "required": true }, - "responses" : { - "200" : { - "description" : "Transaction hash and tick", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/cardinal_server_handler.PostTransactionResponse" + "responses": { + "200": { + "description": "Transaction hash and tick", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/cardinal_server_handler.PostTransactionResponse" } } } }, - "400" : { - "description" : "Invalid request parameter", - "content" : { - "application/json" : { - "schema" : { - "type" : "string" + "400": { + "description": "Invalid request parameter", + "content": { + "application/json": { + "schema": { + "type": "string" } } } } }, - "x-codegen-request-body-name" : "txBody" + "x-codegen-request-body-name": "txBody", + "x-speakeasy-name-override": "createPersona" } }, - "/tx/{txGroup}/{txName}" : { - "post" : { - "summary" : "Submits a transaction", - "description" : "Submits a transaction", - "parameters" : [ { - "name" : "txGroup", - "in" : "path", - "description" : "Message group", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - }, { - "name" : "txName", - "in" : "path", - "description" : "Name of a registered message", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" + "/tx/{txGroup}/{txName}": { + "post": { + "summary": "Submits a transaction", + "description": "Submits a transaction", + "parameters": [ + { + "name": "txGroup", + "in": "path", + "description": "Message group", + "required": true, + "style": "simple", + "explode": false, + "schema": { + "type": "string" + } + }, + { + "name": "txName", + "in": "path", + "description": "Name of a registered message", + "required": true, + "style": "simple", + "explode": false, + "schema": { + "type": "string" + } } - } ], - "requestBody" : { - "description" : "Transaction details & message to be submitted", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/cardinal_server_handler.Transaction" + ], + "requestBody": { + "description": "Transaction details & message to be submitted", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/cardinal_server_handler.Transaction" } } }, - "required" : true + "required": true }, - "responses" : { - "200" : { - "description" : "Transaction hash and tick", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/cardinal_server_handler.PostTransactionResponse" + "responses": { + "200": { + "description": "Transaction hash and tick", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/cardinal_server_handler.PostTransactionResponse" } } } }, - "400" : { - "description" : "Invalid request parameter", - "content" : { - "application/json" : { - "schema" : { - "type" : "string" + "400": { + "description": "Invalid request parameter", + "content": { + "application/json": { + "schema": { + "type": "string" } } } } }, - "x-codegen-request-body-name" : "txBody" + "x-codegen-request-body-name": "txBody", + "x-speakeasy-ignore": true } }, - "/world" : { - "get" : { - "summary" : "Retrieves details of the game world", - "description" : "Contains the registered components, messages, queries, and namespace", - "responses" : { - "200" : { - "description" : "Details of the game world", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/cardinal_server_handler.GetWorldResponse" + "/world": { + "get": { + "summary": "Retrieves details of the game world", + "description": "Contains the registered components, messages, queries, and namespace", + "responses": { + "200": { + "description": "Details of the game world", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/cardinal_server_handler.GetWorldResponse" } } } }, - "400" : { - "description" : "Invalid request parameters", - "content" : { - "application/json" : { - "schema" : { - "type" : "string" + "400": { + "description": "Invalid request parameters", + "content": { + "application/json": { + "schema": { + "type": "string" } } } } - } + }, + "x-speakeasy-name-override": "getWorld" } } }, - "components" : { - "schemas" : { - "cardinal_server_handler.CQLQueryRequest" : { - "type" : "object", - "properties" : { - "cql" : { - "type" : "string" + "components": { + "schemas": { + "cardinal_server_handler.CQLQueryRequest": { + "type": "object", + "properties": { + "cql": { + "type": "string" } } }, - "cardinal_server_handler.CQLQueryResponse" : { - "type" : "object", - "properties" : { - "results" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/pkg_world_dev_world-engine_cardinal_types.EntityStateElement" + "cardinal_server_handler.CQLQueryResponse": { + "type": "object", + "properties": { + "results": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pkg_world_dev_world-engine_cardinal_types.EntityStateElement" } } } }, - "cardinal_server_handler.GetHealthResponse" : { - "type" : "object", - "properties" : { - "isGameLoopRunning" : { - "type" : "boolean" - }, - "isServerRunning" : { - "type" : "boolean" + "cardinal_server_handler.GetHealthResponse": { + "type": "object", + "properties": { + "isGameLoopRunning": { + "type": "boolean" + }, + "isServerRunning": { + "type": "boolean" } } }, - "cardinal_server_handler.GetWorldResponse" : { - "type" : "object", - "properties" : { - "components" : { - "type" : "array", - "description" : "list of component names", - "items" : { - "$ref" : "#/components/schemas/pkg_world_dev_world-engine_cardinal_types.FieldDetail" + "cardinal_server_handler.GetWorldResponse": { + "type": "object", + "properties": { + "components": { + "type": "array", + "description": "list of component names", + "items": { + "$ref": "#/components/schemas/pkg_world_dev_world-engine_cardinal_types.FieldDetail" } }, - "messages" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/pkg_world_dev_world-engine_cardinal_types.FieldDetail" + "messages": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pkg_world_dev_world-engine_cardinal_types.FieldDetail" } }, - "namespace" : { - "type" : "string" + "namespace": { + "type": "string" }, - "queries" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/pkg_world_dev_world-engine_cardinal_types.FieldDetail" + "queries": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pkg_world_dev_world-engine_cardinal_types.FieldDetail" } } } }, - "cardinal_server_handler.ListTxReceiptsRequest" : { - "type" : "object", - "properties" : { - "startTick" : { - "type" : "integer" + "cardinal_server_handler.ListTxReceiptsRequest": { + "type": "object", + "properties": { + "startTick": { + "type": "integer" } } }, - "cardinal_server_handler.ListTxReceiptsResponse" : { - "type" : "object", - "properties" : { - "endTick" : { - "type" : "integer" - }, - "receipts" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/cardinal_server_handler.ReceiptEntry" + "cardinal_server_handler.ListTxReceiptsResponse": { + "type": "object", + "properties": { + "endTick": { + "type": "integer" + }, + "receipts": { + "type": "array", + "items": { + "$ref": "#/components/schemas/cardinal_server_handler.ReceiptEntry" } }, - "startTick" : { - "type" : "integer" + "startTick": { + "type": "integer" } } }, - "cardinal_server_handler.PostTransactionResponse" : { - "type" : "object", - "properties" : { - "tick" : { - "type" : "integer" - }, - "txHash" : { - "type" : "string" + "cardinal_server_handler.PostTransactionResponse": { + "type": "object", + "properties": { + "tick": { + "type": "integer" + }, + "txHash": { + "type": "string" } } }, - "cardinal_server_handler.ReceiptEntry" : { - "type" : "object", - "properties" : { - "errors" : { - "type" : "array", - "items" : { - "type" : "string" + "cardinal_server_handler.ReceiptEntry": { + "type": "object", + "properties": { + "errors": { + "type": "array", + "items": { + "type": "string" } }, - "result" : { - "type" : "object" + "result": { + "type": "object" }, - "tick" : { - "type" : "integer" + "tick": { + "type": "integer" }, - "txHash" : { - "type" : "string" + "txHash": { + "type": "string" } } }, - "cardinal_server_handler.Transaction" : { - "type" : "object", - "properties" : { - "body" : { - "type" : "object", - "properties" : { }, - "description" : "json string" + "cardinal_server_handler.Transaction": { + "type": "object", + "properties": { + "body": { + "type": "object", + "properties": {}, + "description": "json string" }, - "hash" : { - "type" : "string" + "hash": { + "type": "string" }, - "namespace" : { - "type" : "string" + "namespace": { + "type": "string" }, - "nonce" : { - "type" : "integer" + "nonce": { + "type": "integer" }, - "personaTag" : { - "type" : "string" + "personaTag": { + "type": "string" }, - "signature" : { - "type" : "string", - "description" : "hex encoded string" + "signature": { + "type": "string", + "description": "hex encoded string" } } }, - "pkg_world_dev_world-engine_cardinal_types.EntityStateElement" : { - "type" : "object", - "properties" : { - "data" : { - "type" : "object", - "properties" : { } - }, - "id" : { - "type" : "integer" + "pkg_world_dev_world-engine_cardinal_types.DebugStateElement": { + "type": "object", + "properties": { + "components": { + "type": "object", + "properties": {} + }, + "id": { + "type": "integer" } } }, - "pkg_world_dev_world-engine_cardinal_types.DebugStateElement" : { - "type" : "object", - "properties" : { - "components" : { - "type" : "object", - "properties" : { } - }, - "id" : { - "type" : "integer" + "pkg_world_dev_world-engine_cardinal_types.EntityStateElement": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": {} + }, + "id": { + "type": "integer" } } }, - "pkg_world_dev_world-engine_cardinal_types.FieldDetail" : { - "type" : "object", - "properties" : { - "fields" : { - "type" : "object", - "additionalProperties" : { - "type" : "object" + "pkg_world_dev_world-engine_cardinal_types.FieldDetail": { + "type": "object", + "properties": { + "fields": { + "type": "object", + "additionalProperties": { + "type": "object" }, - "description" : "variable name and type" + "description": "variable name and type" }, - "name" : { - "type" : "string", - "description" : "name of the message or query" + "name": { + "type": "string", + "description": "name of the message or query" }, - "url" : { - "type" : "string" + "url": { + "type": "string" } } } } }, - "x-original-swagger-version" : "2.0" + "x-original-swagger-version": "2.0" } \ No newline at end of file diff --git a/cardinal/server/docs/swagger.json b/cardinal/server/docs/swagger.json index c84c12ad8..f564710e4 100644 --- a/cardinal/server/docs/swagger.json +++ b/cardinal/server/docs/swagger.json @@ -103,6 +103,50 @@ } } }, + "/query/game/{queryName}": { + "post": { + "description": "Executes a query", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Executes a query", + "parameters": [ + { + "type": "string", + "description": "Name of a registered query", + "name": "queryName", + "in": "path", + "required": true + }, + { + "description": "Query to be executed", + "name": "queryBody", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "Results of the executed query", + "schema": { + "type": "object" + } + }, + "400": { + "description": "Invalid request parameters", + "schema": { + "type": "string" + } + } + } + } + }, "/query/receipts/list": { "post": { "description": "Retrieves all transaction receipts", @@ -487,10 +531,10 @@ } } }, - "pkg_world_dev_world-engine_cardinal_types.EntityStateElement": { + "pkg_world_dev_world-engine_cardinal_types.DebugStateElement": { "type": "object", "properties": { - "data": { + "components": { "type": "object" }, "id": { @@ -498,10 +542,10 @@ } } }, - "pkg_world_dev_world-engine_cardinal_types.DebugStateElement": { + "pkg_world_dev_world-engine_cardinal_types.EntityStateElement": { "type": "object", "properties": { - "components": { + "data": { "type": "object" }, "id": { diff --git a/cardinal/server/docs/swagger.yaml b/cardinal/server/docs/swagger.yaml index 05670b7a8..a011e92d3 100644 --- a/cardinal/server/docs/swagger.yaml +++ b/cardinal/server/docs/swagger.yaml @@ -89,16 +89,16 @@ definitions: description: hex encoded string type: string type: object - pkg_world_dev_world-engine_cardinal_types.EntityStateElement: + pkg_world_dev_world-engine_cardinal_types.DebugStateElement: properties: - data: + components: type: object id: type: integer type: object - pkg_world_dev_world-engine_cardinal_types.DebugStateElement: + pkg_world_dev_world-engine_cardinal_types.EntityStateElement: properties: - components: + data: type: object id: type: integer @@ -214,6 +214,35 @@ paths: schema: type: string summary: Executes a query + /query/game/{queryName}: + post: + consumes: + - application/json + description: Executes a query + parameters: + - description: Name of a registered query + in: path + name: queryName + required: true + type: string + - description: Query to be executed + in: body + name: queryBody + required: true + schema: + type: object + produces: + - application/json + responses: + "200": + description: Results of the executed query + schema: + type: object + "400": + description: Invalid request parameters + schema: + type: string + summary: Executes a query /query/receipts/list: post: consumes: diff --git a/cardinal/server/handler/query.go b/cardinal/server/handler/query.go index 67920e441..ac6961cf0 100644 --- a/cardinal/server/handler/query.go +++ b/cardinal/server/handler/query.go @@ -32,3 +32,19 @@ func PostQuery(world servertypes.ProviderWorld) func(*fiber.Ctx) error { return ctx.Send(resBz) } } + +// NOTE: duplication for cleaner swagger docs +// PostGameQuery godoc +// +// @Summary Executes a query +// @Description Executes a query +// @Accept application/json +// @Produce application/json +// @Param queryName path string true "Name of a registered query" +// @Param queryBody body object true "Query to be executed" +// @Success 200 {object} object "Results of the executed query" +// @Failure 400 {string} string "Invalid request parameters" +// @Router /query/game/{queryName} [post] +func PostGameQuery(world servertypes.ProviderWorld) func(*fiber.Ctx) error { + return PostQuery(world) +} diff --git a/makefiles/test.mk b/makefiles/test.mk index 03549bbff..727a06852 100644 --- a/makefiles/test.mk +++ b/makefiles/test.mk @@ -130,6 +130,7 @@ swagger-check: .PHONY: swagger-codegen SWAGGER_DIR = cardinal/server/docs +GEN_DIR = .tmp/swagger-codegen swagger-codegen-install: @echo "--> Installing swagger-codegen" @@ -142,7 +143,8 @@ swagger-codegen-install: swagger-codegen: @echo "--> Generating OpenAPI v3.0 document from $(SWAGGER_DIR)" - swagger-codegen generate -l openapi -i "$(SWAGGER_DIR)/swagger.json" -o .tmp/swagger-codegen - mv .tmp/swagger-codegen/openapi.json $(SWAGGER_DIR) + swagger-codegen generate -l openapi -i "$(SWAGGER_DIR)/swagger.json" -o $(GEN_DIR) + node ./scripts/customize-openapi.js "$(GEN_DIR)/openapi.json" + mv "$(GEN_DIR)/openapi.json" $(SWAGGER_DIR) @echo "--> Cleanup" - rm -rf .tmp/swagger-codegen + rm -rf $(TMP_DIR) diff --git a/scripts/customize-openapi.js b/scripts/customize-openapi.js new file mode 100644 index 000000000..400869c89 --- /dev/null +++ b/scripts/customize-openapi.js @@ -0,0 +1,28 @@ +const fs = require('fs') + +const openapiPath = process.argv[2] + +const file = fs.readFileSync(openapiPath) +const data = JSON.parse(file) + +// Rename methods +data.paths['/cql'].post['x-speakeasy-name-override'] = 'queryCql' +data.paths['/debug/state'].post['x-speakeasy-name-override'] = 'getDebugState' +data.paths['/health'].get['x-speakeasy-name-override'] = 'getHealth' +data.paths['/query/game/{queryName}'].post['x-speakeasy-name-override'] = 'query' +data.paths['/query/receipts/list'].post['x-speakeasy-name-override'] = 'getReceipts' +data.paths['/tx/game/{txName}'].post['x-speakeasy-name-override'] = 'transact' +data.paths['/tx/persona/create-persona'].post['x-speakeasy-name-override'] = 'createPersona' +data.paths['/world'].get['x-speakeasy-name-override'] = 'getWorld' + +// hide methods +data.paths['/events'].get['x-speakeasy-ignore'] = true +data.paths['/query/{queryGroup}/{queryName}'].post['x-speakeasy-ignore'] = true +data.paths['/tx/{txGroup}/{txName}'].post['x-speakeasy-ignore'] = true + +try { + fs.writeFileSync(openapiPath, JSON.stringify(data, null, 2)) + console.log('Updated openapi.json with speakeasy attributes') +} catch (error) { + console.log('Error updating openapi.json:', error) +}