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
111 lines
3.2 KiB
TypeScript
111 lines
3.2 KiB
TypeScript
import { z } from 'zod'
|
|
import {
|
|
credentialIdQuerySchema,
|
|
defineGetSelector,
|
|
optionalString,
|
|
} from '@/lib/api/contracts/selectors/shared'
|
|
import type { ContractJsonResponse, ContractQueryInput } from '@/lib/api/contracts/types'
|
|
|
|
const hubspotPropertySchema = z
|
|
.object({
|
|
id: z.string(),
|
|
name: z.string(),
|
|
type: z.string().optional(),
|
|
fieldType: z.string().optional(),
|
|
groupName: z.string().optional(),
|
|
})
|
|
.passthrough()
|
|
|
|
const hubspotListSchema = z
|
|
.object({
|
|
id: z.string(),
|
|
name: z.string(),
|
|
objectType: z.string().optional(),
|
|
processingType: z.string().optional(),
|
|
})
|
|
.passthrough()
|
|
|
|
const hubspotPipelineSchema = z
|
|
.object({
|
|
id: z.string(),
|
|
name: z.string(),
|
|
stages: z.array(z.object({ id: z.string(), label: z.string() }).passthrough()).optional(),
|
|
})
|
|
.passthrough()
|
|
|
|
const hubspotOwnerSchema = z
|
|
.object({
|
|
id: z.string(),
|
|
name: z.string(),
|
|
email: z.string().optional(),
|
|
})
|
|
.passthrough()
|
|
|
|
const hubspotPropertiesQuerySchema = credentialIdQuerySchema.extend({
|
|
objectType: z
|
|
.string()
|
|
.min(1, 'objectType is required')
|
|
.describe('Built-in slug or custom object type id'),
|
|
query: optionalString,
|
|
})
|
|
|
|
const hubspotListsQuerySchema = credentialIdQuerySchema.extend({
|
|
objectTypeId: optionalString.describe('Limit to lists targeting this object type'),
|
|
query: optionalString,
|
|
})
|
|
|
|
const hubspotPipelinesQuerySchema = credentialIdQuerySchema.extend({
|
|
objectType: z
|
|
.string()
|
|
.min(1, 'objectType is required')
|
|
.describe("Object type for which to fetch pipelines (e.g., 'deal' or 'ticket')"),
|
|
})
|
|
|
|
const hubspotOwnersQuerySchema = credentialIdQuerySchema.extend({
|
|
query: optionalString,
|
|
})
|
|
|
|
export const hubspotPropertiesSelectorContract = defineGetSelector(
|
|
'/api/tools/hubspot/properties',
|
|
hubspotPropertiesQuerySchema,
|
|
z.object({ properties: z.array(hubspotPropertySchema) })
|
|
)
|
|
|
|
export const hubspotListsSelectorContract = defineGetSelector(
|
|
'/api/tools/hubspot/lists',
|
|
hubspotListsQuerySchema,
|
|
z.object({ lists: z.array(hubspotListSchema) })
|
|
)
|
|
|
|
export const hubspotPipelinesSelectorContract = defineGetSelector(
|
|
'/api/tools/hubspot/pipelines',
|
|
hubspotPipelinesQuerySchema,
|
|
z.object({ pipelines: z.array(hubspotPipelineSchema) })
|
|
)
|
|
|
|
export const hubspotOwnersSelectorContract = defineGetSelector(
|
|
'/api/tools/hubspot/owners',
|
|
hubspotOwnersQuerySchema,
|
|
z.object({ owners: z.array(hubspotOwnerSchema) })
|
|
)
|
|
|
|
export type HubspotPropertiesSelectorQuery = ContractQueryInput<
|
|
typeof hubspotPropertiesSelectorContract
|
|
>
|
|
export type HubspotListsSelectorQuery = ContractQueryInput<typeof hubspotListsSelectorContract>
|
|
export type HubspotPipelinesSelectorQuery = ContractQueryInput<
|
|
typeof hubspotPipelinesSelectorContract
|
|
>
|
|
export type HubspotOwnersSelectorQuery = ContractQueryInput<typeof hubspotOwnersSelectorContract>
|
|
|
|
export type HubspotPropertiesSelectorResponse = ContractJsonResponse<
|
|
typeof hubspotPropertiesSelectorContract
|
|
>
|
|
export type HubspotListsSelectorResponse = ContractJsonResponse<typeof hubspotListsSelectorContract>
|
|
export type HubspotPipelinesSelectorResponse = ContractJsonResponse<
|
|
typeof hubspotPipelinesSelectorContract
|
|
>
|
|
export type HubspotOwnersSelectorResponse = ContractJsonResponse<
|
|
typeof hubspotOwnersSelectorContract
|
|
>
|