Skip to content

Commit de55f07

Browse files
committed
Merge branch 'main' into bc/turborepo
2 parents aa44435 + 57938b0 commit de55f07

File tree

9 files changed

+377
-345
lines changed

9 files changed

+377
-345
lines changed

.changeset/angry-badgers-retire.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@turnkey/sdk-browser": patch
3+
"@turnkey/sdk-server": patch
4+
---
5+
6+
refactor stamper out of config object and move it directly onto the client to match @turnkey/http

.github/actions/js-setup/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ runs:
2323
- name: Get pnpm store directory (for caching)
2424
id: pnpm-cache-dir
2525
run: |
26-
echo "::set-output name=dir::$(pnpm store path)"
26+
echo "dir=$(pnpm store path)" >> $GITHUB_OUTPUT
2727
shell: bash
2828

2929
# https://github.com/actions/cache

packages/sdk-browser/scripts/codegen.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ function extractLatestVersions(definitions) {
8686
const match = key.match(keyVersionRegex);
8787
if (match) {
8888
const fullName = match[0];
89-
const _defaultPrefix = match[1]; // This is simply the namespace prefix; every field has this "v1"
9089
const baseName = match[2]; // Field without any version-related prefixes or suffixes
9190
const versionSuffix = match[3]; // Version (optional)
9291
const formattedKeyName =
@@ -253,7 +252,7 @@ const generateSDKClientFromSwagger = async (swaggerSpec, targetPath) => {
253252
);
254253

255254
imports.push(
256-
'import { GrpcStatus, TurnkeyRequestError, TurnkeySDKClientConfig } from "../__types__/base";',
255+
'import { GrpcStatus, TStamper, TurnkeyRequestError, TurnkeySDKClientConfig } from "../__types__/base";',
257256
);
258257

259258
imports.push('import { VERSION } from "../__generated__/version";');
@@ -266,8 +265,13 @@ const generateSDKClientFromSwagger = async (swaggerSpec, targetPath) => {
266265
export class TurnkeySDKClientBase {
267266
config: TurnkeySDKClientConfig;
268267
268+
stamper?: TStamper | undefined;
269+
269270
constructor(config: TurnkeySDKClientConfig) {
270271
this.config = config;
272+
if (config.stamper) {
273+
this.stamper = config.stamper;
274+
}
271275
}
272276
273277
async request<TBodyType, TResponseType>(
@@ -279,8 +283,8 @@ export class TurnkeySDKClientBase {
279283
var headers: Record<string, string> = {
280284
"X-Client-Version": VERSION
281285
}
282-
if (this.config.stamper) {
283-
const stamp = await this.config.stamper.stamp(stringifiedBody);
286+
if (this.stamper) {
287+
const stamp = await this.stamper.stamp(stringifiedBody);
284288
headers[stamp.stampHeaderName] = stamp.stampHeaderValue
285289
}
286290
@@ -454,12 +458,12 @@ export class TurnkeySDKClientBase {
454458
// generate a stamping method for each method
455459
codeBuffer.push(
456460
`\n\tstamp${operationNameWithoutNamespace} = async (input: SdkApiTypes.${inputType}): Promise<TSignedRequest | undefined> => {
457-
if (!this.config.stamper) {
461+
if (!this.stamper) {
458462
return undefined;
459463
}
460464
const fullUrl = this.config.apiBaseUrl + "${endpointPath}";
461465
const body = JSON.stringify(input);
462-
const stamp = await this.config.stamper.stamp(body);
466+
const stamp = await this.stamper.stamp(body);
463467
return {
464468
body: body,
465469
stamp: stamp,

0 commit comments

Comments
 (0)