import * as sdk from '@botpress/sdk'

const { z } = sdk

export const states = {
  oauthCredentials: {
    type: 'integration',
    schema: z.object({
      accessToken: z
        .object({
          token: z.string().secret(),
          issuedAt: z.number(),
          expiresAt: z.number(),
        })
        .title('Access Token')
        .describe('The access token generated by LinkedIn'),
      refreshToken: z
        .object({
          token: z.string().secret(),
          issuedAt: z.number(),
          expiresAt: z.number().optional(),
        })
        .optional()
        .title('Refresh Token')
        .describe('The refresh token generated by LinkedIn'),
      grantedScopes: z.array(z.string()).title('Granted Scopes').describe('The scopes granted by the user'),
      linkedInUserId: z.string().title('LinkedIn User ID').describe('The user ID of the authenticated user'),
    }),
  },
  processedNotifications: {
    type: 'integration',
    schema: z.object({
      notificationIds: z
        .array(z.string())
        .title('Notification IDs')
        .describe('Rolling list of recently processed notification IDs to prevent duplicate processing'),
    }),
  },
} as const satisfies sdk.IntegrationDefinitionProps['states']
