chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,214 @@
|
||||
import * as sdk from '@botpress/sdk'
|
||||
import { File, Folder } from './entities'
|
||||
const { z } = sdk
|
||||
|
||||
export const actions = {
|
||||
listItemsInFolder: {
|
||||
title: 'List items in a folder',
|
||||
description: 'List files and folders in dropbox within a directory',
|
||||
input: {
|
||||
schema: z.object({
|
||||
path: z
|
||||
.string()
|
||||
.optional()
|
||||
.title('Path')
|
||||
.describe("The folder's path. Leave empty to list the contents of the root folder"),
|
||||
recursive: z
|
||||
.boolean()
|
||||
.title('List recursively?')
|
||||
.optional()
|
||||
.default(false)
|
||||
.describe('Whether to recursively visit subfolders'),
|
||||
nextToken: z
|
||||
.string()
|
||||
.title('Pagination token')
|
||||
.min(1)
|
||||
.optional()
|
||||
.describe('The cursor to continue the pagination'),
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
schema: z.object({
|
||||
items: z
|
||||
.array(z.union([File.schema, Folder.schema]))
|
||||
.title('Items')
|
||||
.describe('The list of files and folders in the folder'),
|
||||
nextToken: z
|
||||
.string()
|
||||
.title('Pagination token')
|
||||
.optional()
|
||||
.describe(
|
||||
"The cursor to use for pagination. If the cursor is present, you may use it to fetch the next page of results. If it's not present, it means there are no more results"
|
||||
),
|
||||
}),
|
||||
},
|
||||
},
|
||||
createFile: {
|
||||
title: 'Upload File',
|
||||
description: 'Upload a file to dropbox',
|
||||
input: {
|
||||
schema: z.object({
|
||||
contents: z.string().min(1).title('Contents').describe("The file's contents"),
|
||||
path: z.string().min(1).title('Path').describe("The file's path, including the file name and extension"),
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
schema: z.object({ newFile: File.schema.title('New File').describe('The newly-uploaded file') }),
|
||||
},
|
||||
},
|
||||
createFolder: {
|
||||
title: 'Create Folder',
|
||||
description: 'Create a folder in dropbox',
|
||||
input: {
|
||||
schema: z.object({
|
||||
path: z.string().min(1).title('Path').describe("The folder's path"),
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
schema: z.object({ newFolder: Folder.schema.title('New Folder').describe('The newly-created folder') }),
|
||||
},
|
||||
},
|
||||
deleteItem: {
|
||||
title: 'Delete Item',
|
||||
description: 'Deletes a file or folder from dropbox',
|
||||
input: {
|
||||
schema: z.object({
|
||||
path: z.string().title('Path').min(1).describe('The path of the item to delete'),
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
schema: z.object({}),
|
||||
},
|
||||
},
|
||||
downloadFile: {
|
||||
title: 'Download File',
|
||||
description: 'Download a file from dropbox',
|
||||
input: {
|
||||
schema: z.object({ path: z.string().title('Path').min(1).describe("The file's path on Dropbox") }),
|
||||
},
|
||||
output: {
|
||||
schema: z.object({
|
||||
fileUrl: z.string().title('Download URL').describe('The url to download the file from'),
|
||||
}),
|
||||
},
|
||||
},
|
||||
downloadFolder: {
|
||||
title: 'Download Folder',
|
||||
description: 'Download a folder from dropbox',
|
||||
input: {
|
||||
schema: z.object({ path: z.string().title('Path').min(1).describe("The folder's path on Dropbox") }),
|
||||
},
|
||||
output: {
|
||||
schema: z.object({
|
||||
zipUrl: z
|
||||
.string()
|
||||
.title('Download URL')
|
||||
.describe('The url to download the folder from, compressed as a zip archive.'),
|
||||
}),
|
||||
},
|
||||
},
|
||||
copyItem: {
|
||||
title: 'Copy Item',
|
||||
description: 'Copy a file or folder to a new location in dropbox',
|
||||
input: {
|
||||
schema: z.object({
|
||||
fromPath: z.string().title('Source Path').min(1).describe("The item's source path"),
|
||||
toPath: z.string().title('Destination Path').min(1).describe("The item's destination path"),
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
schema: z.object({
|
||||
newItem: z.union([File.schema, Folder.schema]).title('New item').describe('The newly-created item'),
|
||||
}),
|
||||
},
|
||||
},
|
||||
moveItem: {
|
||||
title: 'Move Item',
|
||||
description: 'Move a file or folder in dropbox',
|
||||
input: {
|
||||
schema: z.object({
|
||||
fromPath: z.string().title('Source Path').min(1).describe("The item's source path"),
|
||||
toPath: z.string().title('Destination Path').min(1).describe("The item's destination path"),
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
schema: z.object({
|
||||
newItem: z.union([File.schema, Folder.schema]).title('Moved item').describe('The item that was moved'),
|
||||
}),
|
||||
},
|
||||
},
|
||||
searchItems: {
|
||||
title: 'Search Items',
|
||||
description: 'Search for files and folders in dropbox',
|
||||
input: {
|
||||
schema: z.object({
|
||||
query: z.string().title('Search query').min(1).describe('Keywords to search for'),
|
||||
path: z.string().title('Path').optional().describe('The path to search in'),
|
||||
orderBy: z
|
||||
.enum(['relevance', 'last_modified_time'])
|
||||
.title('Order By')
|
||||
.optional()
|
||||
.describe('How to sort the results'),
|
||||
fileNameOnly: z
|
||||
.boolean()
|
||||
.title('Search only within names?')
|
||||
.optional()
|
||||
.default(false)
|
||||
.describe('Whether to search only in file names'),
|
||||
fileExtensions: z
|
||||
.array(z.string().title('File extension').describe('The file extension to search for'))
|
||||
.optional()
|
||||
.title('Filter by extension')
|
||||
.describe('The file extensions to search for'),
|
||||
fileCategories: z
|
||||
.array(
|
||||
z.enum([
|
||||
'image',
|
||||
'document',
|
||||
'pdf',
|
||||
'spreadsheet',
|
||||
'presentation',
|
||||
'audio',
|
||||
'video',
|
||||
'folder',
|
||||
'paper',
|
||||
'others',
|
||||
])
|
||||
)
|
||||
.optional()
|
||||
.title('Filter by categories')
|
||||
.describe('The file categories to search for'),
|
||||
nextToken: z
|
||||
.string()
|
||||
.title('Pagination Token')
|
||||
.min(1)
|
||||
.optional()
|
||||
.describe('The cursor to continue the pagination'),
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
schema: z.object({
|
||||
results: z
|
||||
.array(
|
||||
z.object({
|
||||
item: z.union([File.schema, Folder.schema]).title('Item').describe('The matched item'),
|
||||
matchType: z
|
||||
.enum(['filename', 'file_content', 'filename_and_content', 'image_content', 'metadata', 'other'])
|
||||
.title('Match type')
|
||||
.describe('The type of match')
|
||||
.optional(),
|
||||
})
|
||||
)
|
||||
.title('Matches')
|
||||
.describe('A list of matches for the query'),
|
||||
nextToken: z
|
||||
.string()
|
||||
.title('Pagination Token')
|
||||
.optional()
|
||||
.describe(
|
||||
"The cursor to use for pagination. If the cursor is present, you may use it to fetch the next page of results. If it's not present, it means there are no more results"
|
||||
),
|
||||
}),
|
||||
},
|
||||
},
|
||||
} as const satisfies sdk.IntegrationDefinitionProps['actions']
|
||||
@@ -0,0 +1,23 @@
|
||||
import { z } from '@botpress/sdk'
|
||||
import * as sdk from '@botpress/sdk'
|
||||
|
||||
export const configuration = {
|
||||
identifier: { linkTemplateScript: 'linkTemplate.vrl', required: false },
|
||||
schema: z.object({}),
|
||||
} satisfies sdk.IntegrationDefinitionProps['configuration']
|
||||
|
||||
export const configurations = {
|
||||
manual: {
|
||||
title: 'Manual Configuration',
|
||||
description: 'Configure the Dropbox integration manually using your own app.',
|
||||
schema: z.object({
|
||||
clientId: z.string().title('App Key').describe('Available in the App Console on Dropbox'),
|
||||
clientSecret: z.string().title('App Secret').describe('Available in the App Console on Dropbox').secret(),
|
||||
authorizationCode: z
|
||||
.string()
|
||||
.title('Access Code')
|
||||
.describe('Obtained by navigating to the authorization URL')
|
||||
.secret(),
|
||||
}),
|
||||
},
|
||||
} satisfies sdk.IntegrationDefinitionProps['configurations']
|
||||
@@ -0,0 +1,17 @@
|
||||
import * as sdk from '@botpress/sdk'
|
||||
const { z } = sdk
|
||||
|
||||
export namespace BaseItem {
|
||||
const _fields = {
|
||||
id: z.string().title('ID').describe('Unique identifier of the item.'),
|
||||
itemType: z.string().title('Item Type').describe('The type of the item.'),
|
||||
name: z.string().title('Name').describe('The name of the item, including extension.'),
|
||||
path: z.string().title('Path').describe("The path to the item in the user's Dropbox."),
|
||||
webUrl: z.string().optional().title('Web URL').describe('The URL to view the item on the Dropbox website.'),
|
||||
isDeleted: z.boolean().title('Is Deleted?').describe('Whether the item has been deleted.'),
|
||||
isShared: z.boolean().title('Is Shared?').describe('Whether the item is shared with other users.'),
|
||||
} as const
|
||||
|
||||
export const schema = z.object(_fields)
|
||||
export type InferredType = sdk.z.infer<typeof schema>
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import * as sdk from '@botpress/sdk'
|
||||
const { z } = sdk
|
||||
|
||||
export namespace Deleted {
|
||||
const _fields = {
|
||||
itemType: z.literal('deleted').title('Item Type').describe('The type of the item.'),
|
||||
name: z.string().title('Name').describe('The name of the item.'),
|
||||
path: z.string().title('Path').describe("The path to the item in the user's Dropbox."),
|
||||
isDeleted: z.literal(true).title('Is Deleted?').describe('Whether the item has been deleted.'),
|
||||
} as const
|
||||
|
||||
export const schema = z.object(_fields)
|
||||
export type InferredType = sdk.z.infer<typeof schema>
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import * as sdk from '@botpress/sdk'
|
||||
import { BaseItem } from './abstract/base-item'
|
||||
const { z } = sdk
|
||||
|
||||
export namespace File {
|
||||
const _fields = {
|
||||
...BaseItem.schema.shape,
|
||||
itemType: z.literal('file').title('Item Type').describe('The type of the item.'),
|
||||
revision: z.string().min(1).title('Revision').describe("The file's revision"),
|
||||
size: z.number().title('Size').describe("The file's size in bytes"),
|
||||
fileHash: z.string().min(1).title('Checksum').describe("The file's validation hash"),
|
||||
isDownloadable: z.boolean().title('Is Downloadable?').describe('Whether the file is downloadable'),
|
||||
symlinkTarget: z
|
||||
.string()
|
||||
.optional()
|
||||
.title('Symlink Target')
|
||||
.describe('The target of the symlink, if the file is a symlink'),
|
||||
modifiedAt: z
|
||||
.string()
|
||||
.title('Modified At')
|
||||
.describe('The date and time the file was last modified, formatted as an ISO 8601 timestamp.'),
|
||||
} as const
|
||||
|
||||
export const schema = z.object(_fields)
|
||||
export type InferredType = sdk.z.infer<typeof schema>
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import * as sdk from '@botpress/sdk'
|
||||
import { BaseItem } from './abstract/base-item'
|
||||
const { z } = sdk
|
||||
|
||||
export namespace Folder {
|
||||
const _fields = {
|
||||
...BaseItem.schema.shape,
|
||||
itemType: z.literal('folder').title('Item Type').describe('The type of the item.'),
|
||||
} as const
|
||||
|
||||
export const schema = z.object(_fields)
|
||||
export type InferredType = sdk.z.infer<typeof schema>
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import * as sdk from '@botpress/sdk'
|
||||
|
||||
import { Deleted } from './deleted'
|
||||
import { File } from './file'
|
||||
import { Folder } from './folder'
|
||||
|
||||
export { File, Folder, Deleted }
|
||||
|
||||
export const entities = {
|
||||
file: {
|
||||
title: 'File',
|
||||
description: "A file in a user's Dropbox",
|
||||
schema: File.schema,
|
||||
},
|
||||
folder: {
|
||||
title: 'Folder',
|
||||
description: "A folder in a user's Dropbox",
|
||||
schema: Folder.schema,
|
||||
},
|
||||
} as const satisfies sdk.IntegrationDefinitionProps['entities']
|
||||
@@ -0,0 +1,5 @@
|
||||
export * from './configuration'
|
||||
export * from './actions'
|
||||
export * from './entities'
|
||||
export * from './secrets'
|
||||
export * from './states'
|
||||
@@ -0,0 +1,6 @@
|
||||
import sdk from '@botpress/sdk'
|
||||
|
||||
export const secrets = {
|
||||
APP_KEY: { description: 'Dropbox App Key' },
|
||||
APP_SECRET: { description: 'Dropbox App Secret' },
|
||||
} as const satisfies sdk.IntegrationDefinitionProps['secrets']
|
||||
@@ -0,0 +1,41 @@
|
||||
import * as sdk from '@botpress/sdk'
|
||||
|
||||
export const states = {
|
||||
authorization: {
|
||||
type: 'integration',
|
||||
schema: sdk.z.object({
|
||||
refreshToken: sdk.z
|
||||
.string()
|
||||
.title('Refresh Token')
|
||||
.describe('Refresh token used to generate a new access token')
|
||||
.secret(),
|
||||
grantedScopes: sdk.z.array(sdk.z.string()).title('Granted Scopes').describe('Scopes granted by the user'),
|
||||
accountId: sdk.z.string().title('Account ID').describe('User ID of the authenticated user'),
|
||||
authorizationCode: sdk.z
|
||||
.string()
|
||||
.title('Access Code')
|
||||
.describe('The Access Code that was exchanged for the refresh token')
|
||||
.secret(),
|
||||
}),
|
||||
},
|
||||
realTimeSync: {
|
||||
type: 'integration',
|
||||
schema: sdk.z.object({
|
||||
syncCursor: sdk.z
|
||||
.string()
|
||||
.title('Sync Cursor')
|
||||
.describe('The cursor used to track the sync state of the tracked Dropbox account.'),
|
||||
fileTreeJson: sdk.z.string().title('File Tree JSON').describe('The JSON representation of the file tree.'),
|
||||
}),
|
||||
},
|
||||
setupMeta: {
|
||||
type: 'integration',
|
||||
schema: sdk.z.object({
|
||||
integrationRegisteredAt: sdk.z
|
||||
.string()
|
||||
.datetime()
|
||||
.title('Registered At')
|
||||
.describe('Date and time when the user configured the integration'),
|
||||
}),
|
||||
},
|
||||
} as const satisfies sdk.IntegrationDefinitionProps['states']
|
||||
Reference in New Issue
Block a user