-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make platform more agnostic by defining standard response t…
…ypes
- Loading branch information
1 parent
c2c0229
commit cabca3a
Showing
11 changed files
with
25,397 additions
and
25,911 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { SingleProductQuery } from "./types/storefront.generated" | ||
import { PlatformProduct } from "../types" | ||
|
||
export function normalizeProduct(product: SingleProductQuery["product"]): PlatformProduct | null { | ||
if (!product) return null | ||
const { id, handle, title, description, descriptionHtml, options, priceRange, variants, featuredImage, images, tags, updatedAt, collections, seo } = product | ||
|
||
return { | ||
id, | ||
handle, | ||
title, | ||
description, | ||
descriptionHtml, | ||
options, | ||
priceRange, | ||
tags, | ||
updatedAt, | ||
featuredImage, | ||
seo, | ||
variants: variants?.edges?.map(({ node }) => node) || [], | ||
images: images?.edges?.map(({ node }) => node) || [], | ||
collections: collections?.nodes || [], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 41 additions & 23 deletions
64
packages/core/platform/shopify/types/admin/admin.generated.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,62 @@ | ||
/* eslint-disable eslint-comments/disable-enable-pair */ | ||
/* eslint-disable eslint-comments/no-unlimited-disable */ | ||
/* eslint-disable */ | ||
import * as AdminTypes from './admin.types.d.ts'; | ||
import * as AdminTypes from "./admin.types.d.ts" | ||
|
||
export type ProductFeedCreateMutationVariables = AdminTypes.Exact<{ [key: string]: never; }>; | ||
export type ProductFeedCreateMutationVariables = AdminTypes.Exact<{ [key: string]: never }> | ||
|
||
|
||
export type ProductFeedCreateMutation = { productFeedCreate?: AdminTypes.Maybe<{ productFeed?: AdminTypes.Maybe<Pick<AdminTypes.ProductFeed, 'status' | 'id'>>, userErrors: Array<Pick<AdminTypes.ProductFeedCreateUserError, 'field' | 'message'>> }> }; | ||
export type ProductFeedCreateMutation = { | ||
productFeedCreate?: AdminTypes.Maybe<{ | ||
productFeed?: AdminTypes.Maybe<Pick<AdminTypes.ProductFeed, "status" | "id">> | ||
userErrors: Array<Pick<AdminTypes.ProductFeedCreateUserError, "field" | "message">> | ||
}> | ||
} | ||
|
||
export type ProductFullSyncMutationVariables = AdminTypes.Exact<{ | ||
id: AdminTypes.Scalars['ID']['input']; | ||
}>; | ||
id: AdminTypes.Scalars["ID"]["input"] | ||
}> | ||
|
||
|
||
export type ProductFullSyncMutation = { productFullSync?: AdminTypes.Maybe<{ userErrors: Array<Pick<AdminTypes.ProductFullSyncUserError, 'field' | 'message'>> }> }; | ||
export type ProductFullSyncMutation = { productFullSync?: AdminTypes.Maybe<{ userErrors: Array<Pick<AdminTypes.ProductFullSyncUserError, "field" | "message">> }> } | ||
|
||
export type WebhookSubscriptionCreateMutationVariables = AdminTypes.Exact<{ | ||
topic: AdminTypes.WebhookSubscriptionTopic; | ||
webhookSubscription: AdminTypes.WebhookSubscriptionInput; | ||
}>; | ||
|
||
|
||
export type WebhookSubscriptionCreateMutation = { webhookSubscriptionCreate?: AdminTypes.Maybe<{ userErrors: Array<Pick<AdminTypes.UserError, 'field' | 'message'>>, webhookSubscription?: AdminTypes.Maybe<Pick<AdminTypes.WebhookSubscription, 'id'>> }> }; | ||
|
||
export type LatestProductFeedsQueryVariables = AdminTypes.Exact<{ [key: string]: never; }>; | ||
topic: AdminTypes.WebhookSubscriptionTopic | ||
webhookSubscription: AdminTypes.WebhookSubscriptionInput | ||
}> | ||
|
||
export type WebhookSubscriptionCreateMutation = { | ||
webhookSubscriptionCreate?: AdminTypes.Maybe<{ | ||
userErrors: Array<Pick<AdminTypes.UserError, "field" | "message">> | ||
webhookSubscription?: AdminTypes.Maybe<Pick<AdminTypes.WebhookSubscription, "id">> | ||
}> | ||
} | ||
|
||
export type LatestProductFeedsQueryVariables = AdminTypes.Exact<{ [key: string]: never }> | ||
|
||
export type LatestProductFeedsQuery = { productFeeds: { nodes: Array<Pick<AdminTypes.ProductFeed, 'id' | 'country' | 'status'>> } }; | ||
export type LatestProductFeedsQuery = { productFeeds: { nodes: Array<Pick<AdminTypes.ProductFeed, "id" | "country" | "status">> } } | ||
|
||
interface GeneratedQueryTypes { | ||
"#graphql\n query LatestProductFeeds {\n productFeeds(reverse: true, first: 1) {\n nodes {\n id\n country\n status\n }\n }\n }\n": {return: LatestProductFeedsQuery, variables: LatestProductFeedsQueryVariables}, | ||
"#graphql\n query LatestProductFeeds {\n productFeeds(reverse: true, first: 1) {\n nodes {\n id\n country\n status\n }\n }\n }\n": { | ||
return: LatestProductFeedsQuery | ||
variables: LatestProductFeedsQueryVariables | ||
} | ||
} | ||
|
||
interface GeneratedMutationTypes { | ||
"#graphql\n mutation ProductFeedCreate {\n productFeedCreate {\n productFeed {\n status\n id\n }\n userErrors {\n field\n message\n }\n }\n }\n": {return: ProductFeedCreateMutation, variables: ProductFeedCreateMutationVariables}, | ||
"#graphql\n mutation productFullSync($id: ID!) {\n productFullSync(id: $id) {\n userErrors {\n field\n message\n }\n }\n }\n": {return: ProductFullSyncMutation, variables: ProductFullSyncMutationVariables}, | ||
"#graphql\n mutation webhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: WebhookSubscriptionInput!) {\n webhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n userErrors {\n field\n message\n }\n webhookSubscription {\n id\n }\n }\n }\n": {return: WebhookSubscriptionCreateMutation, variables: WebhookSubscriptionCreateMutationVariables}, | ||
"#graphql\n mutation ProductFeedCreate {\n productFeedCreate {\n productFeed {\n status\n id\n }\n userErrors {\n field\n message\n }\n }\n }\n": { | ||
return: ProductFeedCreateMutation | ||
variables: ProductFeedCreateMutationVariables | ||
} | ||
"#graphql\n mutation productFullSync($id: ID!) {\n productFullSync(id: $id) {\n userErrors {\n field\n message\n }\n }\n }\n": { | ||
return: ProductFullSyncMutation | ||
variables: ProductFullSyncMutationVariables | ||
} | ||
"#graphql\n mutation webhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: WebhookSubscriptionInput!) {\n webhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n userErrors {\n field\n message\n }\n webhookSubscription {\n id\n }\n }\n }\n": { | ||
return: WebhookSubscriptionCreateMutation | ||
variables: WebhookSubscriptionCreateMutationVariables | ||
} | ||
} | ||
declare module '@shopify/admin-api-client' { | ||
type InputMaybe<T> = AdminTypes.InputMaybe<T>; | ||
declare module "@shopify/admin-api-client" { | ||
type InputMaybe<T> = AdminTypes.InputMaybe<T> | ||
interface AdminQueries extends GeneratedQueryTypes {} | ||
interface AdminMutations extends GeneratedMutationTypes {} | ||
} |
Oops, something went wrong.