d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
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
161 lines
5.4 KiB
TypeScript
161 lines
5.4 KiB
TypeScript
import type { DubListLinksParams, DubListLinksResponse } from '@/tools/dub/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const listLinksTool: ToolConfig<DubListLinksParams, DubListLinksResponse> = {
|
|
id: 'dub_list_links',
|
|
name: 'Dub List Links',
|
|
description:
|
|
'Retrieve a paginated list of short links for the authenticated workspace. Supports filtering by domain, search query, tags, and sorting.',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
apiKey: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'Dub API key',
|
|
},
|
|
domain: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Filter by domain',
|
|
},
|
|
search: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Search query matched against the short link slug and destination URL',
|
|
},
|
|
tagIds: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Comma-separated tag IDs to filter by',
|
|
},
|
|
tenantId: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Filter by tenant ID',
|
|
},
|
|
folderId: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Filter by folder ID',
|
|
},
|
|
showArchived: {
|
|
type: 'boolean',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Whether to include archived links (defaults to false)',
|
|
},
|
|
page: {
|
|
type: 'number',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Page number (deprecated by Dub in favor of startingAfter/endingBefore)',
|
|
},
|
|
pageSize: {
|
|
type: 'number',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Number of links per page (default: 100, max: 100)',
|
|
},
|
|
startingAfter: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Cursor: fetch results after this link ID',
|
|
},
|
|
endingBefore: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Cursor: fetch results before this link ID',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params) => {
|
|
const url = new URL('https://api.dub.co/links')
|
|
if (params.domain) url.searchParams.set('domain', params.domain)
|
|
if (params.search) url.searchParams.set('search', params.search)
|
|
if (params.tagIds) url.searchParams.set('tagIds', params.tagIds)
|
|
if (params.tenantId) url.searchParams.set('tenantId', params.tenantId)
|
|
if (params.folderId) url.searchParams.set('folderId', params.folderId)
|
|
if (params.showArchived !== undefined)
|
|
url.searchParams.set('showArchived', String(params.showArchived))
|
|
if (params.page) url.searchParams.set('page', String(params.page))
|
|
if (params.pageSize) url.searchParams.set('pageSize', String(params.pageSize))
|
|
if (params.startingAfter) url.searchParams.set('startingAfter', params.startingAfter)
|
|
if (params.endingBefore) url.searchParams.set('endingBefore', params.endingBefore)
|
|
return url.toString()
|
|
},
|
|
method: 'GET',
|
|
headers: (params) => ({
|
|
Accept: 'application/json',
|
|
Authorization: `Bearer ${params.apiKey}`,
|
|
}),
|
|
},
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const data = await response.json()
|
|
|
|
if (!response.ok) {
|
|
throw new Error(data.error?.message || data.error || 'Failed to list links')
|
|
}
|
|
|
|
const links = Array.isArray(data) ? data : []
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
links: links.map((link: Record<string, unknown>) => ({
|
|
id: (link.id as string) ?? '',
|
|
domain: (link.domain as string) ?? '',
|
|
key: (link.key as string) ?? '',
|
|
url: (link.url as string) ?? '',
|
|
shortLink: (link.shortLink as string) ?? '',
|
|
qrCode: (link.qrCode as string) ?? '',
|
|
archived: (link.archived as boolean) ?? false,
|
|
externalId: (link.externalId as string) ?? null,
|
|
title: (link.title as string) ?? null,
|
|
description: (link.description as string) ?? null,
|
|
clicks: (link.clicks as number) ?? 0,
|
|
leads: (link.leads as number) ?? 0,
|
|
conversions: (link.conversions as number) ?? 0,
|
|
sales: (link.sales as number) ?? 0,
|
|
saleAmount: (link.saleAmount as number) ?? 0,
|
|
lastClicked: (link.lastClicked as string) ?? null,
|
|
createdAt: (link.createdAt as string) ?? '',
|
|
updatedAt: (link.updatedAt as string) ?? '',
|
|
tags: (link.tags as Array<{ id: string; name: string; color: string }>) ?? [],
|
|
folderId: (link.folderId as string) ?? null,
|
|
tenantId: (link.tenantId as string) ?? null,
|
|
trackConversion: (link.trackConversion as boolean) ?? false,
|
|
utm_source: (link.utm_source as string) ?? null,
|
|
utm_medium: (link.utm_medium as string) ?? null,
|
|
utm_campaign: (link.utm_campaign as string) ?? null,
|
|
utm_term: (link.utm_term as string) ?? null,
|
|
utm_content: (link.utm_content as string) ?? null,
|
|
})),
|
|
count: links.length,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
links: {
|
|
type: 'json',
|
|
description:
|
|
'Array of link objects (id, domain, key, url, shortLink, clicks, tags, createdAt)',
|
|
},
|
|
count: {
|
|
type: 'number',
|
|
description: 'Number of links returned',
|
|
},
|
|
},
|
|
}
|