generated from antfu/starter-ts
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffadf28
commit ecf3be6
Showing
15 changed files
with
2,131 additions
and
685 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,7 +1,7 @@ | ||
{ | ||
"name": "spapi-listing-builder", | ||
"type": "module", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"packageManager": "[email protected]", | ||
"description": "_description_", | ||
"author": "wangjue666 <[email protected]>", | ||
|
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 |
---|---|---|
@@ -1,35 +1,38 @@ | ||
import { ListingProduct } from '@/listing/product' | ||
import type { ProductData } from '@/help/state' | ||
import { FeedHeader } from '../FeedHeader' | ||
|
||
export class FeedProduct { | ||
sellerId: string | ||
list: ProductData[] | ||
marketplace_id: string | ||
constructor(sellerId: string, marketplace_id: string, list: ProductData[]) { | ||
this.sellerId = sellerId | ||
this.marketplace_id = marketplace_id | ||
this.list = list | ||
} | ||
|
||
main() { | ||
return { | ||
header: new FeedHeader(this.sellerId).main(), | ||
messages: this.genMessage(), | ||
} | ||
} | ||
|
||
genMessage() { | ||
return this.list.map((item, idx) => { | ||
return { | ||
messageId: idx + 1, | ||
sku: item.sku, | ||
operationType: 'UPDATE', | ||
...new ListingProduct({ | ||
marketplace_id: this.marketplace_id, | ||
data: item, | ||
}).main(), | ||
} | ||
}) | ||
} | ||
} | ||
import { ListingProduct } from '@/listing/product' | ||
import type { ProductData, RenderOtherAttributesFn } from '@/help/state' | ||
import { FeedHeader } from '../FeedHeader' | ||
|
||
export class FeedProduct { | ||
sellerId: string | ||
list: ProductData[] | ||
marketplace_id: string | ||
renderOtherAttributesFn?: RenderOtherAttributesFn | ||
constructor(sellerId: string, marketplace_id: string, list: ProductData[], renderOtherAttributesFn?: RenderOtherAttributesFn) { | ||
this.sellerId = sellerId | ||
this.marketplace_id = marketplace_id | ||
this.list = list | ||
this.renderOtherAttributesFn = renderOtherAttributesFn | ||
} | ||
|
||
main() { | ||
return { | ||
header: new FeedHeader(this.sellerId).main(), | ||
messages: this.genMessage(), | ||
} | ||
} | ||
|
||
genMessage() { | ||
return this.list.map((item, idx) => { | ||
return { | ||
messageId: idx + 1, | ||
sku: item.sku, | ||
operationType: 'UPDATE', | ||
...new ListingProduct({ | ||
marketplace_id: this.marketplace_id, | ||
data: item, | ||
renderOtherAttributesFn: this.renderOtherAttributesFn, | ||
}).main(), | ||
} | ||
}) | ||
} | ||
} |
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,62 +1,66 @@ | ||
export const imageTypeJsonMap = { | ||
Main: 'main_product_image_locator', | ||
Swatch: 'swatch_product_image_locator', | ||
PT1: 'other_product_image_locator_1', | ||
PT2: 'other_product_image_locator_2', | ||
PT3: 'other_product_image_locator_3', | ||
PT4: 'other_product_image_locator_4', | ||
PT5: 'other_product_image_locator_5', | ||
PT6: 'other_product_image_locator_6', | ||
PT7: 'other_product_image_locator_7', | ||
PT8: 'other_product_image_locator_8', | ||
MainOfferImage: 'main_offer_image_locator', | ||
OfferImage1: 'other_offer_image_locator_1', | ||
OfferImage2: 'other_offer_image_locator_2', | ||
OfferImage3: 'other_offer_image_locator_3', | ||
OfferImage4: 'other_offer_image_locator_4', | ||
OfferImage5: 'other_offer_image_locator_5', | ||
EEGL: 'image_locator_eegl', | ||
} | ||
|
||
export function getImageType(key: string): string | undefined { | ||
return (imageTypeJsonMap as any)[key] | ||
} | ||
|
||
export type Recordable<T = any> = Record<string, T> | ||
|
||
export type ListingType = 'FOLLOW_ASIN' | 'LISTING' | ||
|
||
export interface ListingImgData { | ||
type: keyof typeof imageTypeJsonMap | ||
url: string | ||
} | ||
|
||
export type ProductData = Partial<{ | ||
sku: string | ||
product_type: string | ||
title: string | ||
product_description: string | ||
bullet_points: string[] | ||
brand_name: string | ||
product_identifier_type: 'UPC' | 'EAN' | 'ISBN' | 'GTIN' | '' | ||
product_identifier_id: string | ||
condition: string | ||
manufacturer: string | ||
weight: number | ||
height: number | ||
length: number | ||
width: number | ||
recommendedBrowseNodes: string[] | ||
batteries_required: number // 是否需要电池 | ||
manufactuer_id: string | ||
search_terms: string | ||
quantity: number | ||
deal_time: number | ||
sell_price: number | ||
list_price: number | ||
country_of_origin: string | ||
item_type_keyword: string | ||
parent_sku: string | ||
imgs: ListingImgData[] | ||
[key: string]: any | ||
}> | ||
import type { renderListingArrValue as renderListingArrValueHelp } from './index' | ||
|
||
export const imageTypeJsonMap = { | ||
Main: 'main_product_image_locator', | ||
Swatch: 'swatch_product_image_locator', | ||
PT1: 'other_product_image_locator_1', | ||
PT2: 'other_product_image_locator_2', | ||
PT3: 'other_product_image_locator_3', | ||
PT4: 'other_product_image_locator_4', | ||
PT5: 'other_product_image_locator_5', | ||
PT6: 'other_product_image_locator_6', | ||
PT7: 'other_product_image_locator_7', | ||
PT8: 'other_product_image_locator_8', | ||
MainOfferImage: 'main_offer_image_locator', | ||
OfferImage1: 'other_offer_image_locator_1', | ||
OfferImage2: 'other_offer_image_locator_2', | ||
OfferImage3: 'other_offer_image_locator_3', | ||
OfferImage4: 'other_offer_image_locator_4', | ||
OfferImage5: 'other_offer_image_locator_5', | ||
EEGL: 'image_locator_eegl', | ||
} | ||
|
||
export function getImageType(key: string): string | undefined { | ||
return (imageTypeJsonMap as any)[key] | ||
} | ||
|
||
export type Recordable<T = any> = Record<string, T> | ||
|
||
export type ListingType = 'FOLLOW_ASIN' | 'LISTING' | ||
|
||
export interface ListingImgData { | ||
type: keyof typeof imageTypeJsonMap | ||
url: string | ||
} | ||
|
||
export type ProductData = Partial<{ | ||
sku: string | ||
product_type: string | ||
title: string | ||
product_description: string | ||
bullet_points: string[] | ||
brand_name: string | ||
product_identifier_type: 'UPC' | 'EAN' | 'ISBN' | 'GTIN' | '' | ||
product_identifier_id: string | ||
condition: string | ||
manufacturer: string | ||
weight: number | ||
height: number | ||
length: number | ||
width: number | ||
recommendedBrowseNodes: string[] | ||
batteries_required: number // 是否需要电池 | ||
manufactuer_id: string | ||
search_terms: string | ||
quantity: number | ||
deal_time: number | ||
sell_price: number | ||
list_price: number | ||
country_of_origin: string | ||
item_type_keyword: string | ||
parent_sku: string | ||
imgs: ListingImgData[] | ||
[key: string]: any | ||
}> | ||
|
||
export type RenderOtherAttributesFn = (params: { attributes: Recordable, data: ProductData, renderListingArrValue: typeof renderListingArrValueHelp }) => Recordable |
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,14 +1,15 @@ | ||
export * from './feed/img' | ||
export * from './feed/price' | ||
export * from './feed/product' | ||
export * from './feed/quantity' | ||
export * from './feed/relation' | ||
|
||
export * from './help/state' | ||
export * from './listing/img' | ||
export * from './listing/price' | ||
export * from './listing/product' | ||
export * from './listing/quantity' | ||
export * from './listing/relation' | ||
|
||
export * from './SchemaCheck/index' | ||
export * from './feed/img' | ||
export * from './feed/price' | ||
export * from './feed/product' | ||
export * from './feed/quantity' | ||
export * from './feed/relation' | ||
|
||
export * from './help/index' | ||
export * from './help/state' | ||
export * from './listing/img' | ||
export * from './listing/price' | ||
export * from './listing/product' | ||
export * from './listing/quantity' | ||
export * from './listing/relation' | ||
|
||
export * from './SchemaCheck/index' |
Oops, something went wrong.