@hsblabs/http-command は、TypeScript SDK提供者向けのHTTP実行ランタイムです。client factory、型付きCommand protocol、middleware、Fetch transport、共通エラー契約を提供し、API固有のendpoint・型・認証方針は各SDK側に残します。
@hsblabs/http-command
└─ Client / Command protocol / middleware / transport / error
poke-api-ts-sdkなどのサービスSDK
└─ createServiceClient / service commands / service types
SDK利用アプリケーション
└─ client.send(command)
import{createClient,defineCommand,encodePathSegment,}from'@hsblabs/http-command';constgetUser=defineCommand({build: (input: Readonly<{id: string}>)=>({method: 'GET',url: `/users/${encodePathSegment(input.id)}`,}),parseData: (response): Promise<{id: string;name: string}>=>response.json(),parseError: (response)=>response.json(),});constclient=createClient({baseUrl: 'https://api.example.com/v1',});constuser=awaitclient.send(getUser({id: 'u_1'}));サービスSDKではClient<Scope>とCommand<Scope, Output>を同じunique symbol型で束縛し、別サービスのCommandを誤ったClientへ送れないようにします。既定のURL解決はbaseUrlのpathをAPI prefixとして保持し、SDK提供者はresolveUrlで独自ポリシーへ差し替えられます。
詳しい公開契約、query・path・body replay・error decodingの仕様はpackages/http-command/README.mdを参照してください。
packages/http-command: SDK authoring runtimepackages/http-cli: 同じCommand protocolをCLIへ接続する補助パッケージexamples:http-commandの利用例
pnpm install
pnpm run check
pnpm run release:checkREADME同期チェックのみであればnpmでも実行できます。
npm run docs:check@hsblabs/http-commandと@hsblabs/http-cliはChangesetsのfixed groupとして同じversionで公開します。初回手動公開と、その後のOIDC自動公開の手順はdocs/releases/initial-release.mdを参照してください。