Clean up product typings (#7663)

There are a lot of issues in the admin after applying the correct typings, but fixing those should be done gradually, it's better to keep it out of this PR
This commit is contained in:
Stevche Radevski authored and GitHub committed 2024-06-11 09:28:40 +00:00
1 parent f3bf8c73a3
commit 8e2a42b786
88 files changed
+1205 -990

No files matched your search

+217 -1
View File
@@ -8,12 +8,27 @@ export class Product {
this.client = client
}
async batch(
body: HttpTypes.AdminBatchProductRequest,
query?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminBatchProductResponse>(
`/admin/products/batch`,
{
method: "POST",
headers,
body,
query,
}
)
}
async create(
body: HttpTypes.AdminCreateProduct,
query?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<{ product: HttpTypes.AdminProduct }>(
return await this.client.fetch<HttpTypes.AdminProductResponse>(
`/admin/products`,
{
method: "POST",
@@ -23,4 +38,205 @@ export class Product {
}
)
}
async update(
id: string,
body: HttpTypes.AdminUpdateProduct,
query?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminProductResponse>(
`/admin/products/${id}`,
{
method: "POST",
headers,
body,
query,
}
)
}
async list(
queryParams?: HttpTypes.AdminProductParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminProductListResponse>(
`/admin/products`,
{
headers,
query: queryParams,
}
)
}
async retrieve(id: string, query?: SelectParams, headers?: ClientHeaders) {
return await this.client.fetch<HttpTypes.AdminProductResponse>(
`/admin/products/${id}`,
{
query,
headers,
}
)
}
async delete(id: string, headers?: ClientHeaders) {
return await this.client.fetch<HttpTypes.AdminProductDeleteResponse>(
`/admin/products/${id}`,
{
method: "DELETE",
headers,
}
)
}
async batchVariants(
productId: string,
body: HttpTypes.AdminBatchProductVariantRequest,
query?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminBatchProductVariantResponse>(
`/admin/products/${productId}/variants/batch`,
{
method: "POST",
headers,
body,
query,
}
)
}
async createVariant(
productId: string,
body: HttpTypes.AdminCreateProductVariant,
query?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminProductResponse>(
`/admin/products/${productId}/variants`,
{
method: "POST",
headers,
body,
query,
}
)
}
async updateVariant(
productId: string,
id: string,
body: HttpTypes.AdminUpdateProductVariant,
query?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminProductResponse>(
`/admin/products/${productId}/variants/${id}`,
{
method: "POST",
headers,
body,
query,
}
)
}
async listVariants(
productId: string,
queryParams?: HttpTypes.AdminProductVariantParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminProductVariantListResponse>(
`/admin/products/${productId}/variants`,
{
headers,
query: queryParams,
}
)
}
async retrieveVariant(
productId: string,
id: string,
query?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminProductVariantResponse>(
`/admin/products/${productId}/variants/${id}`,
{
query,
headers,
}
)
}
async deleteVariant(productId: string, id: string, headers?: ClientHeaders) {
return await this.client.fetch<HttpTypes.AdminProductVariantDeleteResponse>(
`/admin/products/${productId}/variants/${id}`,
{
method: "DELETE",
headers,
}
)
}
async createOption(
productId: string,
body: HttpTypes.AdminCreateProductOption,
query?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminProductResponse>(
`/admin/products/${productId}/options`,
{
method: "POST",
headers,
body,
query,
}
)
}
async updateOption(
productId: string,
id: string,
body: HttpTypes.AdminUpdateProductOption,
query?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminProductResponse>(
`/admin/products/${productId}/variants/${id}`,
{
method: "POST",
headers,
body,
query,
}
)
}
async listOptions(
productId: string,
queryParams?: HttpTypes.AdminProductOptionParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminProductOptionListResponse>(
`/admin/products/${productId}/options`,
{
headers,
query: queryParams,
}
)
}
async retrieveOption(
productId: string,
id: string,
query?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminProductOptionResponse>(
`/admin/products/${productId}/options/${id}`,
{
query,
headers,
}
)
}
async deleteOption(productId: string, id: string, headers?: ClientHeaders) {
return await this.client.fetch<HttpTypes.AdminProductOptionDeleteResponse>(
`/admin/products/${productId}/options/${id}`,
{
method: "DELETE",
headers,
}
)
}
}
+10 -9
View File
@@ -71,7 +71,7 @@ export class Store {
public category = {
list: async (
query?: FindParams & HttpTypes.StoreProductCategoryFilters,
query?: HttpTypes.StoreProductCategoryParams,
headers?: ClientHeaders
) => {
return this.client.fetch<
@@ -99,22 +99,23 @@ export class Store {
public product = {
list: async (
query?: FindParams & HttpTypes.StoreProductFilters,
query?: HttpTypes.StoreProductParams,
headers?: ClientHeaders
) => {
return this.client.fetch<
PaginatedResponse<{ products: HttpTypes.StoreProduct[] }>
>(`/store/products`, {
query,
headers,
})
return this.client.fetch<HttpTypes.StoreProductListResponse>(
`/store/products`,
{
query,
headers,
}
)
},
retrieve: async (
id: string,
query?: SelectParams,
headers?: ClientHeaders
) => {
return this.client.fetch<{ product: HttpTypes.StoreProduct }>(
return this.client.fetch<HttpTypes.StoreProductResponse>(
`/store/products/${id}`,
{
query,