feat(media): implement integrated media manager with sidebar and picker

- Implement DriveService and ShopifyMediaService for backend operations
- Create MediaSidebar.html with premium UI and auto-polling
- Integrate Google Picker API for robust file selection
- Orchestrate sync logic via MediaService (Drive -> Staged Upload -> Shopify)
- Add secure config handling for API keys and tokens
- Update ppsscript.json with required OAuth scopes
- Update MEMORY.md and README.md with architecture details
This commit is contained in:
Ben Miller
2025-12-25 15:10:17 -07:00
parent 2417359595
commit 95094b1674
21 changed files with 973 additions and 16 deletions

View File

@ -0,0 +1,71 @@
import { IShopifyMediaService } from "../interfaces/IShopifyMediaService"
import { IShop } from "../interfaces/IShop"
import { formatGqlForJSON } from "../shopifyApi"
export class ShopifyMediaService implements IShopifyMediaService {
private shop: IShop
constructor(shop: IShop) {
this.shop = shop
}
stagedUploadsCreate(input: any[]): any {
const query = /* GraphQL */ `
mutation stagedUploadsCreate($input: [StagedUploadInput!]!) {
stagedUploadsCreate(input: $input) {
stagedTargets {
url
resourceUrl
parameters {
name
value
}
}
userErrors {
field
message
}
}
}
`
const variables = { input }
const payload = {
query: formatGqlForJSON(query),
variables: variables
}
const response = this.shop.shopifyGraphQLAPI(payload)
return response.content.data.stagedUploadsCreate
}
productCreateMedia(productId: string, media: any[]): any {
const query = /* GraphQL */ `
mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {
productCreateMedia(media: $media, productId: $productId) {
media {
alt
mediaContentType
status
}
mediaUserErrors {
field
message
}
product {
id
title
}
}
}
`
const variables = {
productId,
media
}
const payload = {
query: formatGqlForJSON(query),
variables: variables
}
const response = this.shop.shopifyGraphQLAPI(payload)
return response.content.data.productCreateMedia
}
}