radicalplatforms / shafa

A wardrobe logging, composition, and organization app
https://shafa.app
Mozilla Public License 2.0
1 stars 0 forks source link

Hardcoded authorUsername injection is causing types on creation to break #45

Closed rak3rman closed 7 months ago

rak3rman commented 7 months ago

In both the src/service/items.ts and src/service/outfits.ts, a critical error is thrown on object creation (POST) where .values(body) has a typing mismatch. This is being thrown because we instruct Zod in the insertItemSchema variable to be a string and optional. Then in the function call, we strictly set authorUsername apart of the body to a hardcoded string "rak3rman". These types do not match.

The problem description is as follows:

TS2769: No overload matches this call.
  Overload 1 of 2, '(value: { type: number | SQL<unknown> | Placeholder<string, any>; authorUsername: string | SQL<unknown> | Placeholder<string, any>; id?: number | SQL<unknown> | Placeholder<...> | undefined; ... 5 more ...; quality?: number | ... 3 more ... | undefined; }): SQLiteInsert<...>', gave the following error.
    Argument of type '{ type: itemTypeEnum; name?: string | null | undefined; brand?: string | null | undefined; photo?: string | null | undefined; rating?: number | null | undefined; quality?: number | ... 1 more ... | undefined; authorUsername?: string | undefined; }' is not assignable to parameter of type '{ type: number | SQL<unknown> | Placeholder<string, any>; authorUsername: string | SQL<unknown> | Placeholder<string, any>; id?: number | SQL<unknown> | Placeholder<...> | undefined; ... 5 more ...; quality?: number | ... 3 more ... | undefined; }'.
      Types of property 'authorUsername' are incompatible.
        Type 'string | undefined' is not assignable to type 'string | SQL<unknown> | Placeholder<string, any>'.
          Type 'undefined' is not assignable to type 'string | SQL<unknown> | Placeholder<string, any>'.
  Overload 2 of 2, '(values: { type: number | SQL<unknown> | Placeholder<string, any>; authorUsername: string | SQL<unknown> | Placeholder<string, any>; id?: number | SQL<unknown> | Placeholder<...> | undefined; ... 5 more ...; quality?: number | ... 3 more ... | undefined; }[]): SQLiteInsert<...>', gave the following error.
    Argument of type '{ type: itemTypeEnum; name?: string | null | undefined; brand?: string | null | undefined; photo?: string | null | undefined; rating?: number | null | undefined; quality?: number | ... 1 more ... | undefined; authorUsername?: string | undefined; }' is not assignable to parameter of type '{ type: number | SQL<unknown> | Placeholder<string, any>; authorUsername: string | SQL<unknown> | Placeholder<string, any>; id?: number | SQL<unknown> | Placeholder<...> | undefined; ... 5 more ...; quality?: number | ... 3 more ... | undefined; }[]'.
      Type '{ type: itemTypeEnum; name?: string | null | undefined; brand?: string | null | undefined; photo?: string | null | undefined; rating?: number | null | undefined; quality?: number | ... 1 more ... | undefined; authorUsername?: string | undefined; }' is missing the following properties from type '{ type: number | SQL<unknown> | Placeholder<string, any>; authorUsername: string | SQL<unknown> | Placeholder<string, any>; id?: number | SQL<unknown> | Placeholder<...> | undefined; ... 5 more ...; quality?: number | ... 3 more ... | undefined; }[]': length, pop, push, concat, and 35 more.