kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
pull/715/head
rodzic
02343674b5
commit
1c49528fb5
|
@ -0,0 +1,87 @@
|
||||||
|
import 'dotenv/config'
|
||||||
|
|
||||||
|
import { z } from '@hono/zod-openapi'
|
||||||
|
import restoreCursor from 'restore-cursor'
|
||||||
|
import { zodToJsonSchema } from 'zod-to-json-schema'
|
||||||
|
|
||||||
|
import { deploymentOriginAdapterSchema, pricingPlanListSchema } from '@/db'
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// - **service / tool definitions**
|
||||||
|
// - optional per-service config (PricingPlanServiceConfigMap)
|
||||||
|
// - optional external auth provider config (google, github, twitter, etc)
|
||||||
|
// - origin adapter openapi schema path, url, or in-place definition
|
||||||
|
// - optional stripe webhooks
|
||||||
|
// - optional response header config (custom headers, immutability for caching, etc)
|
||||||
|
|
||||||
|
const publicSchema = z.object({
|
||||||
|
name: z.string().describe('The name of the project.'),
|
||||||
|
|
||||||
|
// Metadata
|
||||||
|
description: z
|
||||||
|
.string()
|
||||||
|
.describe('A one-sentence description of the project.')
|
||||||
|
.optional(),
|
||||||
|
readme: z
|
||||||
|
.string()
|
||||||
|
.describe(
|
||||||
|
'A readme documenting the project (supports GitHub-flavored markdown).'
|
||||||
|
)
|
||||||
|
.optional(),
|
||||||
|
sourceUrl: z
|
||||||
|
.string()
|
||||||
|
.url()
|
||||||
|
.optional()
|
||||||
|
.describe('Optional URL to the source code for this project.'),
|
||||||
|
iconUrl: z
|
||||||
|
.string()
|
||||||
|
.url()
|
||||||
|
.optional()
|
||||||
|
.describe(
|
||||||
|
'Optional logo image URL to use for this project. Logos should have a square aspect ratio.'
|
||||||
|
),
|
||||||
|
|
||||||
|
// Required origin API config
|
||||||
|
originUrl: z.string().url()
|
||||||
|
.describe(`Required base URL of the externally hosted origin API server. Must be a valid \`https\` URL.
|
||||||
|
|
||||||
|
NOTE: Agentic currently only supports \`external\` API servers. If you'd like to host your API or MCP server on Agentic's infrastructure, please reach out to support@agentic.so.`),
|
||||||
|
|
||||||
|
// Optional origin API config
|
||||||
|
originAdapter: deploymentOriginAdapterSchema
|
||||||
|
.default({
|
||||||
|
location: 'external',
|
||||||
|
type: 'raw'
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
|
|
||||||
|
// Optional subscription pricing config
|
||||||
|
pricingPlans: pricingPlanListSchema
|
||||||
|
.describe(
|
||||||
|
'List of PricingPlans to enable subscriptions for this project. Defaults to a single free tier.'
|
||||||
|
)
|
||||||
|
.default([
|
||||||
|
{
|
||||||
|
name: 'Free',
|
||||||
|
slug: 'free',
|
||||||
|
lineItems: [
|
||||||
|
{
|
||||||
|
slug: 'base',
|
||||||
|
usageType: 'licensed',
|
||||||
|
amount: 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
restoreCursor()
|
||||||
|
|
||||||
|
const publicJsonSchema = zodToJsonSchema(publicSchema)
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(JSON.stringify(publicJsonSchema, null, 2))
|
||||||
|
}
|
||||||
|
|
||||||
|
await main()
|
|
@ -55,6 +55,7 @@
|
||||||
"@types/semver": "^7.7.0",
|
"@types/semver": "^7.7.0",
|
||||||
"drizzle-kit": "^0.31.1",
|
"drizzle-kit": "^0.31.1",
|
||||||
"drizzle-orm": "^0.43.1",
|
"drizzle-orm": "^0.43.1",
|
||||||
"openapi-typescript": "^7.8.0"
|
"openapi-typescript": "^7.8.0",
|
||||||
|
"zod-to-json-schema": "^3.24.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ export const deployments = pgTable(
|
||||||
description: text().default('').notNull(),
|
description: text().default('').notNull(),
|
||||||
readme: text().default('').notNull(),
|
readme: text().default('').notNull(),
|
||||||
iconUrl: text(),
|
iconUrl: text(),
|
||||||
|
sourceUrl: text(),
|
||||||
|
|
||||||
userId: userId()
|
userId: userId()
|
||||||
.notNull()
|
.notNull()
|
||||||
|
@ -164,9 +165,11 @@ export const deploymentInsertSchema = createInsertSchema(deployments, {
|
||||||
schema
|
schema
|
||||||
.url()
|
.url()
|
||||||
.describe(
|
.describe(
|
||||||
'Logo image URL to use for this delpoyment. Logos should have a square aspect ratio.'
|
'Logo image URL to use for this deployment. Logos should have a square aspect ratio.'
|
||||||
),
|
),
|
||||||
|
|
||||||
|
sourceUrl: (schema) => schema.url(),
|
||||||
|
|
||||||
originUrl: (schema) =>
|
originUrl: (schema) =>
|
||||||
schema.url().describe(`Base URL of the externally hosted origin API server.
|
schema.url().describe(`Base URL of the externally hosted origin API server.
|
||||||
|
|
||||||
|
|
|
@ -296,7 +296,7 @@ export const pricingPlanSchema = z
|
||||||
interval: pricingIntervalSchema.optional(),
|
interval: pricingIntervalSchema.optional(),
|
||||||
|
|
||||||
desc: z.string().optional(),
|
desc: z.string().optional(),
|
||||||
features: z.array(z.string()),
|
features: z.array(z.string()).optional(),
|
||||||
|
|
||||||
// TODO?
|
// TODO?
|
||||||
trialPeriodDays: z.number().nonnegative().optional(),
|
trialPeriodDays: z.number().nonnegative().optional(),
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
"@/*": ["src/*"]
|
"@/*": ["src/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["src", "*.config.ts", "../../packages/core/src/errors.ts"],
|
"include": ["src", "*.config.ts", "bin/*"],
|
||||||
"exclude": ["node_modules", "dist"]
|
"exclude": ["node_modules", "dist"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,6 +213,9 @@ importers:
|
||||||
openapi-typescript:
|
openapi-typescript:
|
||||||
specifier: ^7.8.0
|
specifier: ^7.8.0
|
||||||
version: 7.8.0(typescript@5.8.3)
|
version: 7.8.0(typescript@5.8.3)
|
||||||
|
zod-to-json-schema:
|
||||||
|
specifier: ^3.24.5
|
||||||
|
version: 3.24.5(zod@3.24.4)
|
||||||
|
|
||||||
packages/api-client:
|
packages/api-client:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
Ładowanie…
Reference in New Issue