Skip to content

Comments

Add CarAssets zod schema#5

Open
dan-gamble wants to merge 1 commit intoAllyMurray:mainfrom
dan-gamble:patch-1
Open

Add CarAssets zod schema#5
dan-gamble wants to merge 1 commit intoAllyMurray:mainfrom
dan-gamble:patch-1

Conversation

@dan-gamble
Copy link

When running this:

    const data = await step.do("get car asset data", async () => {
      const tokenResult = await getAdminAccessToken();
      if (tokenResult.error != null) {
        throw new NonRetryableError(tokenResult.error)
      }

      try {
        const client = createIracingApiClient(tokenResult.accessToken, tokenResult.refreshToken, tokenResult.expiresAt)

        return await client.car.assets()
      } catch (error: any) {
        if (error instanceof IRacingError) {
          console.error("iRacing API Error", error.message);
          console.error("Status:", error.status);

          throw error;
        } else {
          console.error("Unexpected error", error);

          throw error;
        }
      }
    });

The type I'm getting is () => Promise<Record<string, unknown>>

If I then go and look at the iracing-data-client/lib/index.d.ts I'm seeing the below for CarAssets

declare const CarAssets: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;

As opposed to something like this for series:

declare const SeriesAssets: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
    largeImage: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniString<string>>>;
    logo: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniString<string>>>;
    seriesCopy: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniString<string>>>;
    seriesId: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniNumber<number>>>;
    smallImage: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniString<string>>>;
}, z.core.$strip>>;

The documentation has it

I need to double check the types as I've just made them all nullable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant