chore: import upstream snapshot with attribution
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,214 @@
|
||||
import type {
|
||||
ShopifyCreateFulfillmentParams,
|
||||
ShopifyFulfillmentResponse,
|
||||
} from '@/tools/shopify/types'
|
||||
import { FULFILLMENT_OUTPUT_PROPERTIES } from '@/tools/shopify/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const shopifyCreateFulfillmentTool: ToolConfig<
|
||||
ShopifyCreateFulfillmentParams,
|
||||
ShopifyFulfillmentResponse
|
||||
> = {
|
||||
id: 'shopify_create_fulfillment',
|
||||
name: 'Shopify Create Fulfillment',
|
||||
description:
|
||||
'Create a fulfillment to mark order items as shipped. Requires a fulfillment order ID (get this from the order details).',
|
||||
version: '1.0.0',
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'shopify',
|
||||
},
|
||||
|
||||
params: {
|
||||
shopDomain: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Your Shopify store domain (e.g., mystore.myshopify.com)',
|
||||
},
|
||||
fulfillmentOrderId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The fulfillment order ID (e.g., gid://shopify/FulfillmentOrder/123456789)',
|
||||
},
|
||||
trackingNumber: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Tracking number for the shipment',
|
||||
},
|
||||
trackingCompany: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Shipping carrier name (e.g., UPS, FedEx, USPS, DHL)',
|
||||
},
|
||||
trackingUrl: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'URL to track the shipment',
|
||||
},
|
||||
notifyCustomer: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Whether to send a shipping confirmation email to the customer (default: true)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
`https://${params.shopDomain || params.idToken}/admin/api/2024-10/graphql.json`,
|
||||
method: 'POST',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Missing access token for Shopify API request')
|
||||
}
|
||||
return {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Shopify-Access-Token': params.accessToken,
|
||||
}
|
||||
},
|
||||
body: (params) => {
|
||||
// Build tracking info if any tracking details provided
|
||||
const trackingInfo: {
|
||||
number?: string
|
||||
company?: string
|
||||
url?: string
|
||||
} = {}
|
||||
|
||||
if (params.trackingNumber) {
|
||||
trackingInfo.number = params.trackingNumber
|
||||
}
|
||||
if (params.trackingCompany) {
|
||||
trackingInfo.company = params.trackingCompany
|
||||
}
|
||||
if (params.trackingUrl) {
|
||||
trackingInfo.url = params.trackingUrl
|
||||
}
|
||||
|
||||
const fulfillmentInput: {
|
||||
lineItemsByFulfillmentOrder: Array<{ fulfillmentOrderId: string }>
|
||||
notifyCustomer?: boolean
|
||||
trackingInfo?: typeof trackingInfo
|
||||
} = {
|
||||
lineItemsByFulfillmentOrder: [
|
||||
{
|
||||
fulfillmentOrderId: params.fulfillmentOrderId.trim(),
|
||||
},
|
||||
],
|
||||
notifyCustomer: params.notifyCustomer !== false, // Default to true
|
||||
}
|
||||
|
||||
// Only include trackingInfo if we have at least one tracking field
|
||||
if (Object.keys(trackingInfo).length > 0) {
|
||||
fulfillmentInput.trackingInfo = trackingInfo
|
||||
}
|
||||
|
||||
return {
|
||||
query: `
|
||||
mutation fulfillmentCreate($fulfillment: FulfillmentInput!) {
|
||||
fulfillmentCreate(fulfillment: $fulfillment) {
|
||||
fulfillment {
|
||||
id
|
||||
status
|
||||
createdAt
|
||||
updatedAt
|
||||
trackingInfo {
|
||||
company
|
||||
number
|
||||
url
|
||||
}
|
||||
fulfillmentLineItems(first: 50) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
quantity
|
||||
lineItem {
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userErrors {
|
||||
field
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
fulfillment: fulfillmentInput,
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response) => {
|
||||
const data = await response.json()
|
||||
|
||||
if (data.errors) {
|
||||
return {
|
||||
success: false,
|
||||
error: data.errors[0]?.message || 'Failed to create fulfillment',
|
||||
output: {},
|
||||
}
|
||||
}
|
||||
|
||||
const result = data.data?.fulfillmentCreate
|
||||
if (!result) {
|
||||
return {
|
||||
success: false,
|
||||
error: 'Failed to create fulfillment',
|
||||
output: {},
|
||||
}
|
||||
}
|
||||
|
||||
if (result.userErrors && result.userErrors.length > 0) {
|
||||
return {
|
||||
success: false,
|
||||
error: result.userErrors.map((e: { message: string }) => e.message).join(', '),
|
||||
output: {},
|
||||
}
|
||||
}
|
||||
|
||||
const fulfillment = result.fulfillment
|
||||
if (!fulfillment) {
|
||||
return {
|
||||
success: false,
|
||||
error: 'No fulfillment returned',
|
||||
output: {},
|
||||
}
|
||||
}
|
||||
|
||||
// Transform fulfillment line items from edges format
|
||||
const fulfillmentLineItems =
|
||||
fulfillment.fulfillmentLineItems?.edges?.map((edge: { node: unknown }) => edge.node) || []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
fulfillment: {
|
||||
id: fulfillment.id,
|
||||
status: fulfillment.status,
|
||||
createdAt: fulfillment.createdAt,
|
||||
updatedAt: fulfillment.updatedAt,
|
||||
trackingInfo: fulfillment.trackingInfo || [],
|
||||
fulfillmentLineItems,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
fulfillment: {
|
||||
type: 'object',
|
||||
description: 'The created fulfillment with tracking info and fulfilled items',
|
||||
properties: FULFILLMENT_OUTPUT_PROPERTIES,
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user