diff --git a/src/types/core.d.ts b/src/types/core.d.ts index 98549a6..2db1d74 100644 --- a/src/types/core.d.ts +++ b/src/types/core.d.ts @@ -115,3 +115,11 @@ export interface CrudQueryableResource Link(url: string): Promise> } + +export interface SimpleResourcePageResponse extends ResourceList { + meta: { + results: { + total: number + } + } +} diff --git a/src/types/pcm-custom-relationship.ts b/src/types/pcm-custom-relationship.ts index 7c9a16b..0b742b1 100644 --- a/src/types/pcm-custom-relationship.ts +++ b/src/types/pcm-custom-relationship.ts @@ -1,7 +1,7 @@ /** * Product Custom Relationships */ -import { Identifiable, Resource, ResourceList } from './core' +import { Identifiable, SimpleResourcePageResponse } from './core' import { CustomRelationship, CustomRelationshipsListResponse @@ -17,22 +17,14 @@ export interface CustomRelationshipEntry { slug: string } -export interface PcmRelatedProductResponse extends ResourceList { - meta: { - results: { - total: number - } - } -} - export interface NonAssociatedProductEntry extends Identifiable { details: string } export interface ProductAssociationResponse { meta: { - associated_products: string[] - products_not_associated: NonAssociatedProductEntry[] + associated_products?: string[] + products_not_associated?: NonAssociatedProductEntry[] owner: 'organization' | 'store' timestamps: { created_at: string @@ -61,8 +53,8 @@ export interface PcmCustomRelationshipEndpoint { */ AttachCustomRelationship( productId: string, - body: CustomRelationshipEntry - ): Promise> + body: CustomRelationshipEntry[] + ): Promise> /** * Detach one or multiple custom relationships from a product @@ -107,7 +99,7 @@ export interface PcmCustomRelationshipEndpoint { GetProductsForCustomRelationship( productId: string, customRelationshipSlug: string - ): Promise> + ): Promise> /** * Get all IDs of a product's related products under a custom relationship @@ -118,5 +110,5 @@ export interface PcmCustomRelationshipEndpoint { GetProductIdsForCustomRelationship( productId: string, customRelationshipSlug: string - ): Promise> + ): Promise> } diff --git a/src/types/pcm.d.ts b/src/types/pcm.d.ts index 23b5809..b073d2e 100644 --- a/src/types/pcm.d.ts +++ b/src/types/pcm.d.ts @@ -99,9 +99,12 @@ type productType = 'standard' | 'parent' | 'child'| 'bundle' export interface PcmProduct extends Identifiable, PcmProductBase { meta: { + created_at: string + updated_at: string variation_matrix: { [key: string]: string } | {} owner?: 'organization' | 'store' product_types?: productType[] + custom_relationships?: string[] } } @@ -120,6 +123,13 @@ export interface PcmProductRelationships { id: string } } + custom_relationships?: { + data?: Array | null + links?: { + [key: string]: string + self: string + } + } } }