chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import * as sdk from '@botpress/sdk'
|
||||
|
||||
const makeApiRequest = {
|
||||
title: 'Make API Request',
|
||||
description: 'Make a request to Salesforce API',
|
||||
input: {
|
||||
schema: sdk.z.object({
|
||||
method: sdk.z.string().title('Method').describe('HTTP method (GET, POST, PATCH, DELETE)'),
|
||||
path: sdk.z.string().title('Path').describe('yourinstance.salesforce.com/services/data/v54.0/PATH'),
|
||||
headers: sdk.z.string().optional().title('Headers').describe('Headers in JSON format'),
|
||||
params: sdk.z.string().optional().title('Params').describe('Params in JSON format'),
|
||||
requestBody: sdk.z
|
||||
.string()
|
||||
.displayAs<any>({
|
||||
id: 'text',
|
||||
params: {
|
||||
allowDynamicVariable: true,
|
||||
growVertically: true,
|
||||
multiLine: true,
|
||||
resizable: true,
|
||||
},
|
||||
})
|
||||
.optional()
|
||||
.title('Request Body')
|
||||
.describe('Request body in JSON format'),
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
schema: sdk.z.object({
|
||||
success: sdk.z.boolean().title('Success').describe('Whether the request was successful'),
|
||||
status: sdk.z.number().optional().title('Status').describe('HTTP status code of the response'),
|
||||
body: sdk.z.any().optional().title('Body').describe('Response body from the API'),
|
||||
error: sdk.z.string().optional().title('Error').describe('Error message if the request failed'),
|
||||
}),
|
||||
},
|
||||
} satisfies sdk.ActionDefinition
|
||||
|
||||
export const apiActionDefinitions = {
|
||||
makeApiRequest,
|
||||
} satisfies sdk.IntegrationDefinitionProps['actions']
|
||||
@@ -0,0 +1,69 @@
|
||||
import * as sdk from '@botpress/sdk'
|
||||
import { recordResultSchema, searchOutputSchema } from './common-schemas'
|
||||
|
||||
const createCaseInputSchema = sdk.z.object({
|
||||
Subject: sdk.z.string().title('Subject').describe('The subject of the case'),
|
||||
Description: sdk.z.string().title('Description').describe('The description of the case'),
|
||||
Status: sdk.z.string().optional().title('Status').describe('The status of the case'),
|
||||
customFields: sdk.z
|
||||
.string()
|
||||
.displayAs<any>({
|
||||
id: 'text',
|
||||
params: {
|
||||
allowDynamicVariable: true,
|
||||
growVertically: true,
|
||||
multiLine: true,
|
||||
resizable: true,
|
||||
},
|
||||
})
|
||||
.optional()
|
||||
.title('Custom Fields')
|
||||
.describe('Additional fields in JSON format'),
|
||||
})
|
||||
|
||||
const createCase = {
|
||||
title: 'Create Case',
|
||||
description: 'Create a Salesforce Case',
|
||||
input: {
|
||||
schema: createCaseInputSchema,
|
||||
},
|
||||
output: {
|
||||
schema: recordResultSchema,
|
||||
},
|
||||
} satisfies sdk.ActionDefinition
|
||||
|
||||
const updateCase = {
|
||||
title: 'Update Case',
|
||||
description: 'Update a Salesforce Case',
|
||||
input: {
|
||||
schema: sdk.z.object({
|
||||
Id: sdk.z.string().title('ID').describe('The ID of the case'),
|
||||
...createCaseInputSchema.partial().shape,
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
schema: recordResultSchema,
|
||||
},
|
||||
} satisfies sdk.ActionDefinition
|
||||
|
||||
const searchCases = {
|
||||
title: 'Search Cases',
|
||||
description: 'Search Salesforce Cases',
|
||||
input: {
|
||||
schema: sdk.z.object({
|
||||
Id: sdk.z.string().optional().title('ID').describe('The ID of the case'),
|
||||
Subject: sdk.z.string().optional().title('Subject').describe('The subject of the case'),
|
||||
Description: sdk.z.string().optional().title('Description').describe('The description of the case'),
|
||||
Status: sdk.z.string().optional().title('Status').describe('The status of the case'),
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
schema: searchOutputSchema,
|
||||
},
|
||||
} satisfies sdk.ActionDefinition
|
||||
|
||||
export const caseActionDefinitions = {
|
||||
createCase,
|
||||
searchCases,
|
||||
updateCase,
|
||||
} satisfies sdk.IntegrationDefinitionProps['actions']
|
||||
@@ -0,0 +1,21 @@
|
||||
import { z } from '@botpress/sdk'
|
||||
|
||||
export const recordResultSchema = z.object({
|
||||
id: z.string().optional().title('ID').describe('The ID of the created or updated record'),
|
||||
success: z.boolean().title('Success').describe('Whether the operation was successful'),
|
||||
error: z.string().optional().title('Error').describe('Error message if the operation failed'),
|
||||
})
|
||||
|
||||
export type RecordResult = z.infer<typeof recordResultSchema>
|
||||
|
||||
export const searchOutputSchema = z.object({
|
||||
success: z.boolean().title('Success').describe('Whether the search was successful'),
|
||||
records: z
|
||||
.array(z.object({}).passthrough())
|
||||
.optional()
|
||||
.title('Records')
|
||||
.describe('The records returned by the search'),
|
||||
error: z.string().optional().title('Error').describe('Error message if the search failed'),
|
||||
})
|
||||
|
||||
export type SearchOutput = z.infer<typeof searchOutputSchema>
|
||||
@@ -0,0 +1,78 @@
|
||||
import * as sdk from '@botpress/sdk'
|
||||
import { recordResultSchema, searchOutputSchema } from './common-schemas'
|
||||
|
||||
const createContactInputSchema = sdk.z.object({
|
||||
FirstName: sdk.z.string().title('First Name').describe('The first name of the contact (e.g. John)'),
|
||||
LastName: sdk.z.string().title('Last Name').describe('The last name of the contact (e.g. Doe)'),
|
||||
Email: sdk.z.string().email().title('Email').describe('The email address of the contact (e.g. john.doe@example.com)'),
|
||||
Phone: sdk.z
|
||||
.string()
|
||||
.optional()
|
||||
.title('Phone')
|
||||
.describe('The phone number of the contact (Optional) (e.g. +1-555-1234)'),
|
||||
customFields: sdk.z
|
||||
.string()
|
||||
.displayAs<any>({
|
||||
id: 'text',
|
||||
params: {
|
||||
allowDynamicVariable: true,
|
||||
growVertically: true,
|
||||
multiLine: true,
|
||||
resizable: true,
|
||||
},
|
||||
})
|
||||
.optional()
|
||||
.title('Custom Fields')
|
||||
.describe('Custom fields (JSON)'),
|
||||
})
|
||||
|
||||
const createContact = {
|
||||
title: 'Create Contact',
|
||||
description: 'Create a Salesforce Contact',
|
||||
input: {
|
||||
schema: createContactInputSchema,
|
||||
},
|
||||
output: {
|
||||
schema: recordResultSchema,
|
||||
},
|
||||
} satisfies sdk.ActionDefinition
|
||||
|
||||
const updateContact = {
|
||||
title: 'Update Contact',
|
||||
description: 'Update a Salesforce Contact',
|
||||
input: {
|
||||
schema: sdk.z.object({
|
||||
Id: sdk.z.string().title('ID').describe('The ID of the contact'),
|
||||
...createContactInputSchema.partial().shape,
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
schema: recordResultSchema,
|
||||
},
|
||||
} satisfies sdk.ActionDefinition
|
||||
|
||||
const searchContacts = {
|
||||
title: 'Search Contacts',
|
||||
description: 'Search Salesforce Contacts',
|
||||
input: {
|
||||
schema: sdk.z.object({
|
||||
Id: sdk.z.string().optional().title('ID').describe('The ID of the contact'),
|
||||
Name: sdk.z.string().optional().title('Name').describe('The first name of the contact (e.g. John)'),
|
||||
Email: sdk.z
|
||||
.string()
|
||||
.email()
|
||||
.optional()
|
||||
.title('Email')
|
||||
.describe('The email address of the contact (e.g. john.doe@example.com)'),
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
schema: searchOutputSchema,
|
||||
},
|
||||
} satisfies sdk.ActionDefinition
|
||||
|
||||
export const contactActionDefinitions = {
|
||||
createContact,
|
||||
searchContacts,
|
||||
updateContact,
|
||||
} satisfies sdk.IntegrationDefinitionProps['actions']
|
||||
@@ -0,0 +1,12 @@
|
||||
import * as sdk from '@botpress/sdk'
|
||||
import { apiActionDefinitions } from './api-actions'
|
||||
import { caseActionDefinitions } from './case-actions'
|
||||
import { contactActionDefinitions } from './contact-actions'
|
||||
import { leadActionDefinitions } from './lead-actions'
|
||||
|
||||
export const actionDefinitions = {
|
||||
...contactActionDefinitions,
|
||||
...leadActionDefinitions,
|
||||
...apiActionDefinitions,
|
||||
...caseActionDefinitions,
|
||||
} satisfies sdk.IntegrationDefinitionProps['actions']
|
||||
@@ -0,0 +1,77 @@
|
||||
import * as sdk from '@botpress/sdk'
|
||||
import { recordResultSchema, searchOutputSchema } from './common-schemas'
|
||||
|
||||
export const createLeadInputSchema = sdk.z.object({
|
||||
FirstName: sdk.z.string().title('First Name').describe('The first name of the lead (e.g. John)'),
|
||||
LastName: sdk.z.string().title('Last Name').describe('The last name of the lead (e.g. Doe)'),
|
||||
Email: sdk.z.string().email().title('Email').describe('The email address of the lead'),
|
||||
Company: sdk.z.string().title('Company').describe('The company of the lead (e.g. Acme Inc.)'),
|
||||
Phone: sdk.z.string().optional().title('Phone').describe('The phone number of the lead'),
|
||||
Title: sdk.z.string().optional().title('Title').describe('The title of the lead'),
|
||||
Description: sdk.z.string().optional().title('Description').describe('The description of the lead'),
|
||||
customFields: sdk.z
|
||||
.string()
|
||||
.displayAs<any>({
|
||||
id: 'text',
|
||||
params: {
|
||||
allowDynamicVariable: true,
|
||||
growVertically: true,
|
||||
multiLine: true,
|
||||
resizable: true,
|
||||
},
|
||||
})
|
||||
.optional()
|
||||
.title('Custom Fields')
|
||||
.describe('Additional fields in JSON format'),
|
||||
})
|
||||
|
||||
const createLead = {
|
||||
title: 'Create Lead',
|
||||
description: 'Create a Salesforce Lead',
|
||||
input: {
|
||||
schema: createLeadInputSchema,
|
||||
},
|
||||
output: {
|
||||
schema: recordResultSchema,
|
||||
},
|
||||
} satisfies sdk.ActionDefinition
|
||||
|
||||
const updateLead = {
|
||||
title: 'Update Lead',
|
||||
description: 'Update a Salesforce Lead',
|
||||
input: {
|
||||
schema: sdk.z.object({
|
||||
Id: sdk.z.string().title('ID').describe('The ID of the lead'),
|
||||
...createLeadInputSchema.partial().shape,
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
schema: recordResultSchema,
|
||||
},
|
||||
} satisfies sdk.ActionDefinition
|
||||
|
||||
const searchLeads = {
|
||||
title: 'Search Leads',
|
||||
description: 'Search Salesforce Leads',
|
||||
input: {
|
||||
schema: sdk.z.object({
|
||||
Id: sdk.z.string().optional().title('ID').describe('The ID of the lead (e.g., leadId1)'),
|
||||
Name: sdk.z.string().optional().title('Name').describe('The name of the lead (e.g., John Doe)'),
|
||||
Email: sdk.z
|
||||
.string()
|
||||
.email()
|
||||
.optional()
|
||||
.title('Email')
|
||||
.describe('The email address of the lead (e.g., john.doe@example.com)'),
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
schema: searchOutputSchema,
|
||||
},
|
||||
} satisfies sdk.ActionDefinition
|
||||
|
||||
export const leadActionDefinitions = {
|
||||
createLead,
|
||||
updateLead,
|
||||
searchLeads,
|
||||
} satisfies sdk.IntegrationDefinitionProps['actions']
|
||||
Reference in New Issue
Block a user