From 54ba15b5b2a81c1a23ad584dc7514d7b31593ac1 Mon Sep 17 00:00:00 2001 From: nikita Date: Wed, 18 Mar 2026 17:06:12 -0500 Subject: [PATCH 1/2] update auth openapi spec add makefile docker utils, clean up old openapi generated files --- .gitignore | 2 + Makefile | 42 ++++ python/sdk/src/.openapi-generator-ignore | 6 + resources/auth-api.yaml | 41 +--- resources/auth-common.yaml | 34 +++ rust/gen/bluefin_api/.openapi-generator/FILES | 1 + .../bluefin_api/docs/AffiliateMetadataFees.md | 16 -- rust/gen/bluefin_api/docs/CampaignRewards.md | 11 - .../docs/CreateOrderRequestTwapConfig.md | 12 - ...ewardsIntervalMetadataIntervalParameter.md | 12 - rust/gen/bluefin_api/docs/PingRequest.md | 11 - rust/gen/bluefin_api/docs/PingResponse.md | 11 - .../docs/PostCreateOrder202Response.md | 11 - .../src/models/affiliate_metadata_fees.rs | 50 ---- .../src/models/campaign_rewards.rs | 27 --- .../create_order_request_twap_config.rs | 34 --- ...ds_interval_metadata_interval_parameter.rs | 26 --- .../bluefin_api/src/models/ping_request.rs | 28 --- .../bluefin_api/src/models/ping_response.rs | 39 ---- .../models/post_create_order_202_response.rs | 28 --- scripts/version_bump.py | 218 ++++++++++++++++++ ts/sdk/src/.openapi-generator-ignore | 6 +- 22 files changed, 315 insertions(+), 351 deletions(-) create mode 100644 Makefile create mode 100644 resources/auth-common.yaml delete mode 100644 rust/gen/bluefin_api/docs/AffiliateMetadataFees.md delete mode 100644 rust/gen/bluefin_api/docs/CampaignRewards.md delete mode 100644 rust/gen/bluefin_api/docs/CreateOrderRequestTwapConfig.md delete mode 100644 rust/gen/bluefin_api/docs/GetRewardsIntervalMetadataIntervalParameter.md delete mode 100644 rust/gen/bluefin_api/docs/PingRequest.md delete mode 100644 rust/gen/bluefin_api/docs/PingResponse.md delete mode 100644 rust/gen/bluefin_api/docs/PostCreateOrder202Response.md delete mode 100644 rust/gen/bluefin_api/src/models/affiliate_metadata_fees.rs delete mode 100644 rust/gen/bluefin_api/src/models/campaign_rewards.rs delete mode 100644 rust/gen/bluefin_api/src/models/create_order_request_twap_config.rs delete mode 100644 rust/gen/bluefin_api/src/models/get_rewards_interval_metadata_interval_parameter.rs delete mode 100644 rust/gen/bluefin_api/src/models/ping_request.rs delete mode 100644 rust/gen/bluefin_api/src/models/ping_response.rs delete mode 100644 rust/gen/bluefin_api/src/models/post_create_order_202_response.rs create mode 100644 scripts/version_bump.py diff --git a/.gitignore b/.gitignore index 547ca4fd..8781a73f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /target/ .idea/ .vscode/ +.zed .venv /ts/dist /ts/sdk/node_modules @@ -9,3 +10,4 @@ **/openapitools.json out tools/**/target +.DS_Store diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..cc2fce8a --- /dev/null +++ b/Makefile @@ -0,0 +1,42 @@ +OPENAPI_GEN_VERSION := 7.13.0 +OPENAPI_GEN_IMAGE := openapitools/openapi-generator-cli:v$(OPENAPI_GEN_VERSION) + +SPEC := resources/bluefin-api.yaml + +DOCKER_RUN := docker run --rm -v $(CURDIR):/work -w /work $(OPENAPI_GEN_IMAGE) generate \ + --input-spec /work/$(SPEC) + +.PHONY: generate generate-ts generate-py generate-rs version-bump help + +# --- Code Generation --- + +version-bump: ## Detect spec changes and bump SDK versions + python3 scripts/version_bump.py + +generate: generate-ts generate-py generate-rs ## Generate all SDK clients + +generate-ts: ## Generate TypeScript client + $(DOCKER_RUN) \ + --config /work/ts/sdk/openapitools.json \ + --generator-name typescript-axios \ + --output /work/ts/sdk/src + +generate-py: ## Generate Python client + $(DOCKER_RUN) \ + --config /work/python/sdk/config.yaml \ + --generator-name python \ + --output /work/python/sdk/src + +generate-rs: ## Generate Rust client + rm -rf rust/gen/bluefin_api + $(DOCKER_RUN) \ + --config /work/rust/gen/config.yaml \ + --generator-name rust \ + --output /work/rust/gen/bluefin_api + +generate-all: version-bump generate ## Generate all SDK clients with version bump + +# --- Help --- + +help: ## Show this help + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' diff --git a/python/sdk/src/.openapi-generator-ignore b/python/sdk/src/.openapi-generator-ignore index 7484ee59..86a31eb3 100644 --- a/python/sdk/src/.openapi-generator-ignore +++ b/python/sdk/src/.openapi-generator-ignore @@ -21,3 +21,9 @@ #docs/*.md # Then explicitly reverse the ignore rule for a single file: #!docs/README.md + +# Hand-written SDK files +__init__.py +bluefin_pro_sdk.py +crypto_helpers/** +websocket/** diff --git a/resources/auth-api.yaml b/resources/auth-api.yaml index 343361e4..d481ae86 100644 --- a/resources/auth-api.yaml +++ b/resources/auth-api.yaml @@ -16,13 +16,6 @@ servers: - sui-prod components: - responses: - DefaultError: - description: Unexpected error - content: - application/json: - schema: - $ref: './common.yaml#/components/schemas/Error' schemas: JwksResponse: type: object @@ -82,26 +75,6 @@ components: - accountAddress - signedAtMillis - audience - LoginResponse: - type: object - required: - - accessToken - - accessTokenValidForSeconds - - refreshToken - - refreshTokenValidForSeconds - properties: - accessToken: - type: string - accessTokenValidForSeconds: - type: integer - format: int64 - x-go-type: int64 - refreshToken: - type: string - refreshTokenValidForSeconds: - type: integer - format: int64 - x-go-type: int64 RefreshTokenRequest: type: object required: @@ -272,7 +245,7 @@ paths: schema: $ref: '#/components/schemas/OpenIDConfigurationResponse' default: - $ref: '#/components/responses/DefaultError' + $ref: './auth-common.yaml#/components/responses/DefaultError' /auth/zklogin: get: tags: @@ -359,7 +332,7 @@ paths: schema: $ref: '#/components/schemas/JwksResponse' default: - $ref: '#/components/responses/DefaultError' + $ref: './auth-common.yaml#/components/responses/DefaultError' /auth/token: post: tags: @@ -405,7 +378,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/LoginResponse' + $ref: './auth-common.yaml#/components/schemas/LoginResponse' '400': description: "bad signature" content: @@ -431,7 +404,7 @@ paths: schema: $ref: "./common.yaml#/components/schemas/Error" default: - $ref: '#/components/responses/DefaultError' + $ref: './auth-common.yaml#/components/responses/DefaultError' /auth/v2/token: post: tags: @@ -477,7 +450,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/LoginResponse' + $ref: './auth-common.yaml#/components/schemas/LoginResponse' '400': description: "bad signature" content: @@ -503,7 +476,7 @@ paths: schema: $ref: "./common.yaml#/components/schemas/Error" default: - $ref: '#/components/responses/DefaultError' + $ref: './auth-common.yaml#/components/responses/DefaultError' /auth/token/refresh: put: tags: @@ -541,7 +514,7 @@ paths: schema: $ref: "./common.yaml#/components/schemas/Error" default: - $ref: '#/components/responses/DefaultError' + $ref: './auth-common.yaml#/components/responses/DefaultError' /auth/client-credentials: post: diff --git a/resources/auth-common.yaml b/resources/auth-common.yaml new file mode 100644 index 00000000..c2284cda --- /dev/null +++ b/resources/auth-common.yaml @@ -0,0 +1,34 @@ +openapi: 3.0.3 +info: + title: Auth Common Schemas + version: v1 + description: Shared authentication schemas. +components: + responses: + DefaultError: + description: Unexpected error + content: + application/json: + schema: + $ref: "./common.yaml#/components/schemas/Error" + schemas: + LoginResponse: + type: object + required: + - accessToken + - accessTokenValidForSeconds + - refreshToken + - refreshTokenValidForSeconds + properties: + accessToken: + type: string + accessTokenValidForSeconds: + type: integer + format: int64 + x-go-type: int64 + refreshToken: + type: string + refreshTokenValidForSeconds: + type: integer + format: int64 + x-go-type: int64 diff --git a/rust/gen/bluefin_api/.openapi-generator/FILES b/rust/gen/bluefin_api/.openapi-generator/FILES index 9f5fda1d..d05adada 100644 --- a/rust/gen/bluefin_api/.openapi-generator/FILES +++ b/rust/gen/bluefin_api/.openapi-generator/FILES @@ -1,4 +1,5 @@ .gitignore +.openapi-generator-ignore .travis.yml Cargo.toml README.md diff --git a/rust/gen/bluefin_api/docs/AffiliateMetadataFees.md b/rust/gen/bluefin_api/docs/AffiliateMetadataFees.md deleted file mode 100644 index 8a6ecfec..00000000 --- a/rust/gen/bluefin_api/docs/AffiliateMetadataFees.md +++ /dev/null @@ -1,16 +0,0 @@ -# AffiliateMetadataFees - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**referral_perps_fee** | Option<**String**> | Earnings from referral perps fees (e9 format) | [optional] -**subaffiliate_perps_earnings** | Option<**String**> | Earnings from subaffiliate perps (e9 format) | [optional] -**spot_lp_fee** | Option<**String**> | Earnings from spot LP fees (e9 format) | [optional] -**referral_spot_lp_fee** | Option<**String**> | Earnings from referral spot LP fees (e9 format) | [optional] -**referral_lending_rewards** | Option<**String**> | Earnings from referral lending rewards (e9 format) | [optional] -**perps_fee_cashback** | Option<**String**> | Cashback from perps fees (e9 format) | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/rust/gen/bluefin_api/docs/CampaignRewards.md b/rust/gen/bluefin_api/docs/CampaignRewards.md deleted file mode 100644 index 061f1e30..00000000 --- a/rust/gen/bluefin_api/docs/CampaignRewards.md +++ /dev/null @@ -1,11 +0,0 @@ -# CampaignRewards - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**rewards** | Option<[**models::UserCampaignRewards**](UserCampaignRewards.md)> | | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/rust/gen/bluefin_api/docs/CreateOrderRequestTwapConfig.md b/rust/gen/bluefin_api/docs/CreateOrderRequestTwapConfig.md deleted file mode 100644 index c67fefb4..00000000 --- a/rust/gen/bluefin_api/docs/CreateOrderRequestTwapConfig.md +++ /dev/null @@ -1,12 +0,0 @@ -# CreateOrderRequestTwapConfig - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**sub_orders_count** | Option<**String**> | Number of sub-orders to split the total quantity into | [optional] -**running_time_in_minutes** | Option<**String**> | Total time in minutes over which to execute the TWAP order | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/rust/gen/bluefin_api/docs/GetRewardsIntervalMetadataIntervalParameter.md b/rust/gen/bluefin_api/docs/GetRewardsIntervalMetadataIntervalParameter.md deleted file mode 100644 index 581b7609..00000000 --- a/rust/gen/bluefin_api/docs/GetRewardsIntervalMetadataIntervalParameter.md +++ /dev/null @@ -1,12 +0,0 @@ -# GetRewardsIntervalMetadataIntervalParameter - -## Enum Variants - -| Name | Description | -|---- | -----| -| String | | -| i32 | | - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/rust/gen/bluefin_api/docs/PingRequest.md b/rust/gen/bluefin_api/docs/PingRequest.md deleted file mode 100644 index c4140658..00000000 --- a/rust/gen/bluefin_api/docs/PingRequest.md +++ /dev/null @@ -1,11 +0,0 @@ -# PingRequest - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**client** | Option<**String**> | Optional client identifier (e.g. mobile, web). | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/rust/gen/bluefin_api/docs/PingResponse.md b/rust/gen/bluefin_api/docs/PingResponse.md deleted file mode 100644 index d0439fee..00000000 --- a/rust/gen/bluefin_api/docs/PingResponse.md +++ /dev/null @@ -1,11 +0,0 @@ -# PingResponse - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**status** | **String** | | - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/rust/gen/bluefin_api/docs/PostCreateOrder202Response.md b/rust/gen/bluefin_api/docs/PostCreateOrder202Response.md deleted file mode 100644 index 426cf989..00000000 --- a/rust/gen/bluefin_api/docs/PostCreateOrder202Response.md +++ /dev/null @@ -1,11 +0,0 @@ -# PostCreateOrder202Response - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**order_hash** | **String** | The unique identifier of this order, to be used as a lookup key | - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/rust/gen/bluefin_api/src/models/affiliate_metadata_fees.rs b/rust/gen/bluefin_api/src/models/affiliate_metadata_fees.rs deleted file mode 100644 index dd1414d1..00000000 --- a/rust/gen/bluefin_api/src/models/affiliate_metadata_fees.rs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Bluefin API - * - * Bluefin API - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; -use serde::{Deserialize, Serialize}; - -/// AffiliateMetadataFees : Map of various fee-related configurations -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct AffiliateMetadataFees { - /// Earnings from referral perps fees (e9 format) - #[serde(rename = "referralPerpsFee", skip_serializing_if = "Option::is_none")] - pub referral_perps_fee: Option, - /// Earnings from subaffiliate perps (e9 format) - #[serde(rename = "subaffiliatePerpsEarnings", skip_serializing_if = "Option::is_none")] - pub subaffiliate_perps_earnings: Option, - /// Earnings from spot LP fees (e9 format) - #[serde(rename = "spotLPFee", skip_serializing_if = "Option::is_none")] - pub spot_lp_fee: Option, - /// Earnings from referral spot LP fees (e9 format) - #[serde(rename = "referralSpotLPFee", skip_serializing_if = "Option::is_none")] - pub referral_spot_lp_fee: Option, - /// Earnings from referral lending rewards (e9 format) - #[serde(rename = "referralLendingRewards", skip_serializing_if = "Option::is_none")] - pub referral_lending_rewards: Option, - /// Cashback from perps fees (e9 format) - #[serde(rename = "perpsFeeCashback", skip_serializing_if = "Option::is_none")] - pub perps_fee_cashback: Option, -} - -impl AffiliateMetadataFees { - /// Map of various fee-related configurations - pub fn new() -> AffiliateMetadataFees { - AffiliateMetadataFees { - referral_perps_fee: None, - subaffiliate_perps_earnings: None, - spot_lp_fee: None, - referral_spot_lp_fee: None, - referral_lending_rewards: None, - perps_fee_cashback: None, - } - } -} - diff --git a/rust/gen/bluefin_api/src/models/campaign_rewards.rs b/rust/gen/bluefin_api/src/models/campaign_rewards.rs deleted file mode 100644 index bf1c154a..00000000 --- a/rust/gen/bluefin_api/src/models/campaign_rewards.rs +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Bluefin API - * - * Bluefin API - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CampaignRewards { - #[serde(rename = "rewards", skip_serializing_if = "Option::is_none")] - pub rewards: Option, -} - -impl CampaignRewards { - pub fn new() -> CampaignRewards { - CampaignRewards { - rewards: None, - } - } -} - diff --git a/rust/gen/bluefin_api/src/models/create_order_request_twap_config.rs b/rust/gen/bluefin_api/src/models/create_order_request_twap_config.rs deleted file mode 100644 index 4e9ceb4a..00000000 --- a/rust/gen/bluefin_api/src/models/create_order_request_twap_config.rs +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Bluefin API - * - * Bluefin API - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; -use serde::{Deserialize, Serialize}; - -/// CreateOrderRequestTwapConfig : Configuration for Time-Weighted Average Price orders -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct CreateOrderRequestTwapConfig { - /// Number of sub-orders to split the total quantity into - #[serde(rename = "subOrdersCount", skip_serializing_if = "Option::is_none")] - pub sub_orders_count: Option, - /// Total time in minutes over which to execute the TWAP order - #[serde(rename = "runningTimeInMinutes", skip_serializing_if = "Option::is_none")] - pub running_time_in_minutes: Option, -} - -impl CreateOrderRequestTwapConfig { - /// Configuration for Time-Weighted Average Price orders - pub fn new() -> CreateOrderRequestTwapConfig { - CreateOrderRequestTwapConfig { - sub_orders_count: None, - running_time_in_minutes: None, - } - } -} - diff --git a/rust/gen/bluefin_api/src/models/get_rewards_interval_metadata_interval_parameter.rs b/rust/gen/bluefin_api/src/models/get_rewards_interval_metadata_interval_parameter.rs deleted file mode 100644 index 61b88f57..00000000 --- a/rust/gen/bluefin_api/src/models/get_rewards_interval_metadata_interval_parameter.rs +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Bluefin API - * - * Bluefin API - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetRewardsIntervalMetadataIntervalParameter { - Integer(i32), - String(String), -} - -impl Default for GetRewardsIntervalMetadataIntervalParameter { - fn default() -> Self { - Self::Integer(Default::default()) - } -} - diff --git a/rust/gen/bluefin_api/src/models/ping_request.rs b/rust/gen/bluefin_api/src/models/ping_request.rs deleted file mode 100644 index d7e58fe1..00000000 --- a/rust/gen/bluefin_api/src/models/ping_request.rs +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Bluefin API - * - * Bluefin API - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct PingRequest { - /// Optional client identifier (e.g. mobile, web). - #[serde(rename = "client", skip_serializing_if = "Option::is_none")] - pub client: Option, -} - -impl PingRequest { - pub fn new() -> PingRequest { - PingRequest { - client: None, - } - } -} - diff --git a/rust/gen/bluefin_api/src/models/ping_response.rs b/rust/gen/bluefin_api/src/models/ping_response.rs deleted file mode 100644 index f726271f..00000000 --- a/rust/gen/bluefin_api/src/models/ping_response.rs +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Bluefin API - * - * Bluefin API - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct PingResponse { - #[serde(rename = "status")] - pub status: Status, -} - -impl PingResponse { - pub fn new(status: Status) -> PingResponse { - PingResponse { - status, - } - } -} -/// -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] -pub enum Status { - #[serde(rename = "ok")] - Ok, -} - -impl Default for Status { - fn default() -> Status { - Self::Ok - } -} - diff --git a/rust/gen/bluefin_api/src/models/post_create_order_202_response.rs b/rust/gen/bluefin_api/src/models/post_create_order_202_response.rs deleted file mode 100644 index 9f9a8323..00000000 --- a/rust/gen/bluefin_api/src/models/post_create_order_202_response.rs +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Bluefin API - * - * Bluefin API - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct PostCreateOrder202Response { - /// The unique identifier of this order, to be used as a lookup key - #[serde(rename = "orderHash")] - pub order_hash: String, -} - -impl PostCreateOrder202Response { - pub fn new(order_hash: String) -> PostCreateOrder202Response { - PostCreateOrder202Response { - order_hash, - } - } -} - diff --git a/scripts/version_bump.py b/scripts/version_bump.py new file mode 100644 index 00000000..368a05d2 --- /dev/null +++ b/scripts/version_bump.py @@ -0,0 +1,218 @@ +#!/usr/bin/env python3 +""" +Version bump script for pro-sdk. + +Detects OpenAPI spec changes via SHA-256 hashing and bumps SDK versions +in the generator config files. + +Usage: + python3 scripts/version_bump.py [--no-bump] [--major] +""" + +from __future__ import annotations + +import hashlib +import json +import os +import re +import sys +from datetime import datetime, timezone +from pathlib import Path +from typing import Any + +STATE_FILE = ".apigen-state" +RESOURCES_DIR = "resources" + +# --- Hashing --- + + +def hash_file(path: Path) -> str: + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def hash_spec_bundle(resources_dir: Path) -> tuple[dict[str, str], str]: + spec_files = sorted(resources_dir.glob("*.yaml")) + if not spec_files: + return {}, "" + + file_hashes: dict[str, str] = {} + for f in spec_files: + file_hashes[str(f)] = hash_file(f) + + combined = "".join(file_hashes[k] for k in sorted(file_hashes)) + combined_hash = hashlib.sha256(combined.encode()).hexdigest() + return file_hashes, combined_hash + + +# --- State --- + + +def load_state(path: Path) -> dict[str, Any] | None: + if not path.exists(): + return None + state: dict[str, Any] = json.loads(path.read_text()) + return state + + +def save_state(path: Path, file_hashes: dict[str, str], combined_hash: str) -> None: + state: dict[str, Any] = { + "version": "1", + "algorithm": "sha256", + "generated_at": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"), + "spec_files": file_hashes, + "combined_hash": combined_hash, + } + path.write_text(json.dumps(state, indent=2) + "\n") + + +# --- Version bumping --- + + +def bump_major(version: str) -> str: + major, _minor, _patch = version.split(".") + return f"{int(major) + 1}.0.0" + + +def bump_minor(version: str) -> str: + major, minor, _patch = version.split(".") + return f"{major}.{int(minor) + 1}.0" + + +def read_yaml_version(path: Path) -> str: + """Read packageVersion from a YAML config.""" + for line in path.read_text().splitlines(): + m = re.match(r"\s*packageVersion:\s*['\"]?([0-9.]+)['\"]?", line) + if m: + return m.group(1) + raise ValueError(f"packageVersion not found in {path}") + + +def write_yaml_version(path: Path, new_version: str) -> None: + """Write packageVersion in a YAML config.""" + text = path.read_text() + text = re.sub( + r"(packageVersion:\s*)['\"]?[0-9.]+['\"]?", + rf"\g<1>{new_version}", + text, + ) + path.write_text(text) + + +def write_json_version(path: Path, new_version: str) -> None: + """Write version fields in a JSON generator config.""" + data: dict[str, Any] = json.loads(path.read_text()) + props = data.get("additionalProperties") + if isinstance(props, dict): + props["npmVersion"] = new_version + if "packageVersion" in props: + props["packageVersion"] = new_version + path.write_text(json.dumps(data, indent=2) + "\n") + + +def write_toml_version(path: Path, new_version: str) -> None: + """Write version in a TOML file (pyproject.toml or Cargo.toml).""" + text = path.read_text() + text = re.sub( + r'(version\s*=\s*")[0-9.]+"', + rf'\g<1>{new_version}"', + text, + count=1, + ) + path.write_text(text) + + +def write_package_json_version(path: Path, new_version: str) -> None: + """Write version in a package.json file.""" + data: dict[str, Any] = json.loads(path.read_text()) + data["version"] = new_version + path.write_text(json.dumps(data, indent=2) + "\n") + + +def print_changes(file_hashes: dict[str, str], previous: dict[str, Any]) -> None: + prev_files: dict[str, str] = previous.get("spec_files", {}) + print("Changed files:") + for path, current_hash in file_hashes.items(): + prev_hash = prev_files.get(path) + if prev_hash is None: + print(f" {path} (new)") + elif current_hash != prev_hash: + print(f" {path} (modified)") + for path in prev_files: + if path not in file_hashes: + print(f" {path} (deleted)") + + +# --- Main --- + + +def main() -> None: + skip_bump = "--no-bump" in sys.argv + major_bump = "--major" in sys.argv + + # cd to repo root + repo_root = Path(__file__).resolve().parent.parent + os.chdir(repo_root) + + resources = Path(RESOURCES_DIR) + if not resources.is_dir(): + print(f"Error: {RESOURCES_DIR}/ not found") + sys.exit(1) + + file_hashes, combined_hash = hash_spec_bundle(resources) + if not file_hashes: + print(f"No spec files found in {RESOURCES_DIR}/") + sys.exit(0) + + state_path = Path(STATE_FILE) + previous = load_state(state_path) + + if previous is None: + print("First run — establishing baseline (no version bump)") + for path, h in file_hashes.items(): + print(f" {path}: {h[:16]}...") + save_state(state_path, file_hashes, combined_hash) + print(f"State saved to {STATE_FILE}") + sys.exit(0) + + if combined_hash == previous.get("combined_hash"): + print("No spec changes detected") + sys.exit(0) + + print_changes(file_hashes, previous) + + if skip_bump: + print("Version bump skipped (--no-bump)") + else: + current_version = read_yaml_version(Path("python/sdk/config.yaml")) + new_version = bump_major(current_version) if major_bump else bump_minor(current_version) + bump_type = "major (breaking)" if major_bump else "minor" + print(f"Bumping versions ({bump_type}): {current_version} -> {new_version}") + + # Generator configs + write_yaml_version(Path("python/sdk/config.yaml"), new_version) + print(f" python/sdk/config.yaml -> {new_version}") + + write_yaml_version(Path("rust/gen/config.yaml"), new_version) + print(f" rust/gen/config.yaml -> {new_version}") + + write_json_version(Path("ts/sdk/openapitools.json"), new_version) + print(f" ts/sdk/openapitools.json -> {new_version}") + + # Package manifests + manifests: list[tuple[str, Any]] = [ + ("python/sdk/pyproject.toml", write_toml_version), + ("rust/Cargo.toml", write_toml_version), + ("ts/sdk/package.json", write_package_json_version), + ] + for rel_path, writer in manifests: + p = Path(rel_path) + if p.exists(): + writer(p, new_version) + print(f" {rel_path} -> {new_version}") + + save_state(state_path, file_hashes, combined_hash) + print(f"State saved to {STATE_FILE}") + + +if __name__ == "__main__": + main() diff --git a/ts/sdk/src/.openapi-generator-ignore b/ts/sdk/src/.openapi-generator-ignore index ea56ba32..da485663 100644 --- a/ts/sdk/src/.openapi-generator-ignore +++ b/ts/sdk/src/.openapi-generator-ignore @@ -25,4 +25,8 @@ index.ts package.json README.md -tsconfig.json \ No newline at end of file +tsconfig.json +request-signer.ts +sdk.ts +utils.ts +websocket.ts \ No newline at end of file From 8b3da65cf4846747c7e20d6ac97a29cbd7c41923 Mon Sep 17 00:00:00 2001 From: nikita Date: Wed, 18 Mar 2026 17:55:06 -0500 Subject: [PATCH 2/2] update client code version and update makefile --- .apigen-state | 9 +++++---- Makefile | 4 +--- python/sdk/config.yaml | 2 +- python/sdk/pyproject.toml | 2 +- python/sdk/src/openapi_client/__init__.py | 2 +- python/sdk/src/openapi_client/api_client.py | 2 +- python/sdk/src/openapi_client/configuration.py | 2 +- python/sdk/src/openapi_client_README.md | 2 +- rust/Cargo.toml | 2 +- rust/gen/bluefin_api/Cargo.toml | 2 +- rust/gen/bluefin_api/README.md | 2 +- rust/gen/config.yaml | 2 +- ts/sdk/openapitools.json | 4 ++-- ts/sdk/package.json | 4 ++-- 14 files changed, 20 insertions(+), 21 deletions(-) diff --git a/.apigen-state b/.apigen-state index 21f0d141..9b4f8430 100644 --- a/.apigen-state +++ b/.apigen-state @@ -1,10 +1,11 @@ { "version": "1", "algorithm": "sha256", - "generated_at": "2026-03-13T22:19:43.014785Z", + "generated_at": "2026-03-18T22:53:13.035771Z", "spec_files": { "resources/account-data-api.yaml": "2d366acf63b1412c3b49583b22aea07829f297332ebd1b0680954d0d248f2998", - "resources/auth-api.yaml": "0d6fcdb4ed69131adc765b20ea0e6dc4ef735a0a579c3e44e62ed23dde4a0d84", + "resources/auth-api.yaml": "7fa07edd6586d00e8fd1e23fc81c83698800aa9cbfd3fa107072952d96bbf99a", + "resources/auth-common.yaml": "dbc5d97472a5051fe79a4fef919bc3e4c4d5d2e4751d0aab65c051be56174e1f", "resources/bluefin-api.yaml": "b81cebbb70822b4806a9c56e819d6dd1b52453f4b37d63a95a14dae7cf0edb9c", "resources/common.yaml": "71dc565fccebcc9e71b49b48448d2583903aec7e2d16ef1d69972b50f2e4250f", "resources/exchange-api.yaml": "a309b3a5c29fb71dcc26d6f8018883ec51b42db43c29fee7b7ed4f0997146f77", @@ -13,5 +14,5 @@ "resources/vera-api.yaml": "f4c51b5f6614dd4e3b9f5f1f01f945e06d9090849530ecb916ad4ae18d8f61a0", "resources/websocket-api.yaml": "c2c51ceea701bff0b7e911e9afdb0addeb4d7f173b2a25b996d13f5462cb535b" }, - "combined_hash": "84124ae2265b7acb3be586b12a4f7a848f85abb212120f7b29c9ab6989ef55fc" -} \ No newline at end of file + "combined_hash": "752605421bfad83cb0424a9a943d7430a3b34bf812412955da279ac70e7df15e" +} diff --git a/Makefile b/Makefile index cc2fce8a..5913c16f 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ DOCKER_RUN := docker run --rm -v $(CURDIR):/work -w /work $(OPENAPI_GEN_IMAGE) g version-bump: ## Detect spec changes and bump SDK versions python3 scripts/version_bump.py -generate: generate-ts generate-py generate-rs ## Generate all SDK clients +generate: generate-ts generate-py generate-rs version-bump ## Generate all SDK clients generate-ts: ## Generate TypeScript client $(DOCKER_RUN) \ @@ -34,8 +34,6 @@ generate-rs: ## Generate Rust client --generator-name rust \ --output /work/rust/gen/bluefin_api -generate-all: version-bump generate ## Generate all SDK clients with version bump - # --- Help --- help: ## Show this help diff --git a/python/sdk/config.yaml b/python/sdk/config.yaml index a09e4acc..070bb1ab 100644 --- a/python/sdk/config.yaml +++ b/python/sdk/config.yaml @@ -2,4 +2,4 @@ additionalProperties: library: asyncio generateSourceCodeOnly: true useOneOfDiscriminatorLookup: true - packageVersion: 1.15.0 + packageVersion: 1.16.0 diff --git a/python/sdk/pyproject.toml b/python/sdk/pyproject.toml index c6a5aeb5..eaa22e69 100644 --- a/python/sdk/pyproject.toml +++ b/python/sdk/pyproject.toml @@ -21,7 +21,7 @@ description = "Python Boilerplate contains all the boilerplate you need to creat name = "bluefin_pro_sdk" readme = "README.rst" requires-python = ">=3.9.2,<3.14.0" -version = "1.15.0" +version = "1.16.0" [[project.authors]] email = "audreyr@example.com" diff --git a/python/sdk/src/openapi_client/__init__.py b/python/sdk/src/openapi_client/__init__.py index df1f1a1b..d58eeb6b 100644 --- a/python/sdk/src/openapi_client/__init__.py +++ b/python/sdk/src/openapi_client/__init__.py @@ -14,7 +14,7 @@ """ # noqa: E501 -__version__ = "1.15.0" +__version__ = "1.16.0" # import apis into sdk package from openapi_client.api.account_data_api import AccountDataApi diff --git a/python/sdk/src/openapi_client/api_client.py b/python/sdk/src/openapi_client/api_client.py index a0e8e59c..d8159605 100644 --- a/python/sdk/src/openapi_client/api_client.py +++ b/python/sdk/src/openapi_client/api_client.py @@ -90,7 +90,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/1.15.0/python' + self.user_agent = 'OpenAPI-Generator/1.16.0/python' self.client_side_validation = configuration.client_side_validation async def __aenter__(self): diff --git a/python/sdk/src/openapi_client/configuration.py b/python/sdk/src/openapi_client/configuration.py index 96c9ac01..7d88564f 100644 --- a/python/sdk/src/openapi_client/configuration.py +++ b/python/sdk/src/openapi_client/configuration.py @@ -507,7 +507,7 @@ def to_debug_report(self) -> str: "OS: {env}\n"\ "Python Version: {pyversion}\n"\ "Version of the API: 1.0.0\n"\ - "SDK Package Version: 1.15.0".\ + "SDK Package Version: 1.16.0".\ format(env=sys.platform, pyversion=sys.version) def get_host_settings(self) -> List[HostSetting]: diff --git a/python/sdk/src/openapi_client_README.md b/python/sdk/src/openapi_client_README.md index 05b7d367..2b9095d6 100644 --- a/python/sdk/src/openapi_client_README.md +++ b/python/sdk/src/openapi_client_README.md @@ -4,7 +4,7 @@ Bluefin API The `openapi_client` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - API version: 1.0.0 -- Package version: 1.15.0 +- Package version: 1.16.0 - Generator version: 7.13.0 - Build package: org.openapitools.codegen.languages.PythonClientCodegen diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 457c4d81..d2eb0b71 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -9,7 +9,7 @@ sha2 = "0.10.9" [dependencies.bluefin_api] path = "gen/bluefin_api" -version = "1.15.0" +version = "1.16.0" [dependencies.ed25519-dalek] features = ["rand_core"] diff --git a/rust/gen/bluefin_api/Cargo.toml b/rust/gen/bluefin_api/Cargo.toml index 812dee9b..7ea6ff14 100644 --- a/rust/gen/bluefin_api/Cargo.toml +++ b/rust/gen/bluefin_api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bluefin_api" -version = "1.15.0" +version = "1.16.0" authors = ["OpenAPI Generator team and contributors"] description = "Bluefin API" license = "MIT OR Apache-2.0" diff --git a/rust/gen/bluefin_api/README.md b/rust/gen/bluefin_api/README.md index f7b5a752..9ee06512 100644 --- a/rust/gen/bluefin_api/README.md +++ b/rust/gen/bluefin_api/README.md @@ -8,7 +8,7 @@ Bluefin API This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. - API version: 1.0.0 -- Package version: 1.15.0 +- Package version: 1.16.0 - Generator version: 7.13.0 - Build package: `org.openapitools.codegen.languages.RustClientCodegen` diff --git a/rust/gen/config.yaml b/rust/gen/config.yaml index 3a136233..3adf8537 100644 --- a/rust/gen/config.yaml +++ b/rust/gen/config.yaml @@ -2,5 +2,5 @@ additionalProperties: hideGenerationTimestamp: 'true' avoidBoxedModels: 'true' packageName: bluefin_api - packageVersion: 1.15.0 + packageVersion: 1.16.0 preferUnsignedInt: 'true' diff --git a/ts/sdk/openapitools.json b/ts/sdk/openapitools.json index b19292a9..918d9129 100644 --- a/ts/sdk/openapitools.json +++ b/ts/sdk/openapitools.json @@ -8,7 +8,7 @@ "hideGenerationTimestamp": true, "modelPropertyNaming": "camelCase", "npmName": "@bluefin/api-client", - "npmVersion": "1.2.0", + "npmVersion": "1.16.0", "nullSafeAdditionalProps": true, "packageName": "bluefin-pro-api-client", "paramNaming": "camelCase", @@ -21,4 +21,4 @@ }, "generatorName": "typescript-axios", "spaces": 2 -} \ No newline at end of file +} diff --git a/ts/sdk/package.json b/ts/sdk/package.json index 62d55a7d..1d6fce9a 100644 --- a/ts/sdk/package.json +++ b/ts/sdk/package.json @@ -52,5 +52,5 @@ "prepare": "npm run build" }, "types": "./dist/types/index.d.ts", - "version": "1.15.0" -} \ No newline at end of file + "version": "1.16.0" +}