This commit is contained in:
Martin McKeaveney 2024-09-09 16:52:56 +01:00
parent 57698170a8
commit b4a4f81308
10 changed files with 56 additions and 3 deletions

@ -1 +1 @@
Subproject commit c24374879d2b61516fabc24d7404e7da235be05e
Subproject commit ce60bf923115855a9cd0bb991297cccd308eae13

View File

@ -0,0 +1,21 @@
import { publishEvent } from "../events"
import {
Event,
AIConfigCreatedEvent,
AIConfigUpdatedEvent,
} from "@budibase/types"
async function AIConfigCreated(timestamp?: string | number) {
const properties: AIConfigCreatedEvent = {}
await publishEvent(Event.AI_CONFIG_CREATED, properties, timestamp)
}
async function AIConfigUpdated() {
const properties: AIConfigUpdatedEvent = {}
await publishEvent(Event.AI_CONFIG_UPDATED, properties)
}
export default {
AIConfigCreated,
AIConfigUpdated,
}

View File

@ -4,6 +4,7 @@ export { default as auth } from "./auth"
export { default as automation } from "./automation"
export { default as datasource } from "./datasource"
export { default as email } from "./email"
export { default as ai } from "./ai"
export { default as license } from "./license"
export { default as layout } from "./layout"
export { default as org } from "./org"

View File

@ -54,7 +54,11 @@
</div>
<div class="form-row">
<Label size="M">Name</Label>
<Input placeholder={"Enter a name"} bind:value={config.name} />
<Input
error={config.name === "Budibase AI" ? "Cannot use this name" : null}
placeholder={"Enter a name"}
bind:value={config.name}
/>
</div>
<div class="form-row">
<Label size="M">Default Model</Label>

@ -1 +1 @@
Subproject commit a4d1d15d9ce6ac3deedb2e42625c90ba32756758
Subproject commit 62586bc47bf2af507356b0e1e64df8b0ae9fad43

View File

@ -35,6 +35,7 @@ export interface StaticUsage {
[StaticQuotaName.CREATORS]: number
[StaticQuotaName.USER_GROUPS]: number
[StaticQuotaName.ROWS]: number
[StaticQuotaName.AI_CUSTOM_CONFIGS]: number
triggers: {
[key in StaticQuotaName]?: QuotaTriggers
}
@ -44,6 +45,7 @@ export interface MonthlyUsage {
[MonthlyQuotaName.QUERIES]: number
[MonthlyQuotaName.AUTOMATIONS]: number
[MonthlyQuotaName.DAY_PASSES]: number
[MonthlyQuotaName.BUDIBASE_AI_CREDITS]: number
triggers: {
[key in MonthlyQuotaName]?: QuotaTriggers
}

View File

@ -0,0 +1,5 @@
import { BaseEvent } from "./event"
export interface AIConfigCreatedEvent extends BaseEvent {}
export interface AIConfigUpdatedEvent extends BaseEvent {}

View File

@ -33,6 +33,10 @@ export enum Event {
EMAIL_SMTP_CREATED = "email:smtp:created",
EMAIL_SMTP_UPDATED = "email:smtp:updated",
// AI
AI_CONFIG_CREATED = "ai:config:created",
AI_CONFIG_UPDATED = "ai:config:updated",
// AUTH
AUTH_SSO_CREATED = "auth:sso:created",
AUTH_SSO_UPDATED = "auth:sso:updated",
@ -243,6 +247,10 @@ export const AuditedEventFriendlyName: Record<Event, string | undefined> = {
[Event.EMAIL_SMTP_CREATED]: `Email configuration created`,
[Event.EMAIL_SMTP_UPDATED]: `Email configuration updated`,
// AI
[Event.AI_CONFIG_CREATED]: `AI configuration created`,
[Event.AI_CONFIG_UPDATED]: `AI configuration updated`,
// AUTH
[Event.AUTH_SSO_CREATED]: `SSO configuration created`,
[Event.AUTH_SSO_UPDATED]: `SSO configuration updated`,

View File

@ -2,6 +2,7 @@ export * from "./app"
export * from "./auth"
export * from "./automation"
export * from "./email"
export * from "./ai"
export * from "./datasource"
export * from "./event"
export * from "./layout"

View File

@ -31,6 +31,7 @@ import {
OIDCLogosConfig,
AIConfig,
PASSWORD_REPLACEMENT,
isAIConfig,
} from "@budibase/types"
import * as pro from "@budibase/pro"
@ -40,6 +41,11 @@ const getEventFns = async (config: Config, existing?: Config) => {
if (!existing) {
if (isSMTPConfig(config)) {
fns.push(events.email.SMTPCreated)
} else if (isAIConfig(config)) {
fns.push(() => events.ai.AIConfigCreated)
fns.push(() =>
pro.quotas.updateCustomAIConfigCount(Object.keys(config.config).length)
)
} else if (isGoogleConfig(config)) {
fns.push(() => events.auth.SSOCreated(ConfigType.GOOGLE))
if (config.config.activated) {
@ -76,6 +82,11 @@ const getEventFns = async (config: Config, existing?: Config) => {
} else {
if (isSMTPConfig(config)) {
fns.push(events.email.SMTPUpdated)
} else if (isAIConfig(config)) {
fns.push(() => events.ai.AIConfigUpdated)
fns.push(() =>
pro.quotas.updateCustomAIConfigCount(Object.keys(config.config).length)
)
} else if (isGoogleConfig(config)) {
fns.push(() => events.auth.SSOUpdated(ConfigType.GOOGLE))
if (!existing.config.activated && config.config.activated) {