kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: switch ids to have prefixes
rodzic
264a5455a3
commit
6b36a91aa7
|
@ -12,8 +12,8 @@ export default [
|
|||
rules: {
|
||||
...drizzle.configs.recommended.rules,
|
||||
'no-console': 'error',
|
||||
'unicorn/no-array-reduce': 'off',
|
||||
'no-restricted-imports': ['error', '@agentic/platform-db']
|
||||
'unicorn/no-array-reduce': 'off'
|
||||
// 'no-restricted-imports': ['error', '@agentic/platform-db']
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
// The only place we allow `@agentic/platform-db` imports is in this directory.
|
||||
|
||||
import {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
// The only place we allow `@agentic/platform-db` imports is in this directory.
|
||||
|
||||
export * from '@agentic/platform-db'
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
import { expect, test } from 'vitest'
|
||||
|
||||
import { getIdSchemaForModelType } from '../schemas'
|
||||
import { createId, idMaxLength, idPrefixMap, type ModelType } from './common'
|
||||
|
||||
for (const modelType of Object.keys(idPrefixMap)) {
|
||||
test(`${modelType} id`, () => {
|
||||
for (let i = 0; i < 100; ++i) {
|
||||
const id = createId(modelType as ModelType)
|
||||
expect(id.startsWith(idPrefixMap[modelType as ModelType])).toBe(true)
|
||||
expect(id.length).toBeLessThanOrEqual(idMaxLength)
|
||||
expect(getIdSchemaForModelType(modelType as ModelType).parse(id)).toBe(id)
|
||||
}
|
||||
})
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
import { assert } from '@agentic/platform-core'
|
||||
import { type Equal, sql, type Writable } from '@fisch0920/drizzle-orm'
|
||||
import {
|
||||
pgEnum,
|
||||
|
@ -11,19 +12,68 @@ import {
|
|||
} from '@fisch0920/drizzle-orm/pg-core'
|
||||
import { createSchemaFactory } from '@fisch0920/drizzle-zod'
|
||||
import { z } from '@hono/zod-openapi'
|
||||
import { createId } from '@paralleldrive/cuid2'
|
||||
import { createId as createCuid2 } from '@paralleldrive/cuid2'
|
||||
|
||||
const usernameAndTeamSlugLength = 64 as const
|
||||
|
||||
/**
|
||||
* `cuid2`
|
||||
*/
|
||||
export function cuid<U extends string, T extends Readonly<[U, ...U[]]>>(
|
||||
config?: PgVarcharConfig<T | Writable<T>, never>
|
||||
): PgVarcharBuilderInitial<'', Writable<T>, 24> {
|
||||
return varchar({ length: 24, ...config })
|
||||
// prefix is max 4 characters
|
||||
// separator is 1 character
|
||||
// cuid2 is max 24 characters
|
||||
// so use 32 characters to be safe for storing ids
|
||||
export const idMaxLength = 32 as const
|
||||
|
||||
export const idPrefixMap = {
|
||||
user: 'user',
|
||||
team: 'team',
|
||||
project: 'proj',
|
||||
deployment: 'depl',
|
||||
consumer: 'csmr',
|
||||
logEntry: 'log'
|
||||
} as const
|
||||
|
||||
export type ModelType = keyof typeof idPrefixMap
|
||||
|
||||
export function createId(modelType: ModelType): string {
|
||||
const prefix = idPrefixMap[modelType]
|
||||
assert(prefix, 500, `Invalid model type: ${modelType}`)
|
||||
|
||||
return `${prefix}_${createCuid2()}`
|
||||
}
|
||||
|
||||
/**
|
||||
* All of our model primary ids have the following format:
|
||||
*
|
||||
* `${modelPrefix}_${cuid2}`
|
||||
*/
|
||||
export function id<U extends string, T extends Readonly<[U, ...U[]]>>(
|
||||
config?: PgVarcharConfig<T | Writable<T>, never>
|
||||
): PgVarcharBuilderInitial<'', Writable<T>, typeof idMaxLength> {
|
||||
return varchar({ length: idMaxLength, ...config })
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `id` primary key to use for a given model type.
|
||||
*/
|
||||
function getPrimaryId(modelType: ModelType) {
|
||||
return id()
|
||||
.primaryKey()
|
||||
.$defaultFn(() => createId(modelType))
|
||||
}
|
||||
|
||||
export const projectPrimaryId = getPrimaryId('project')
|
||||
export const deploymentPrimaryId = getPrimaryId('deployment')
|
||||
export const consumerPrimaryId = getPrimaryId('consumer')
|
||||
export const logEntryPrimaryId = getPrimaryId('logEntry')
|
||||
export const teamPrimaryId = getPrimaryId('team')
|
||||
export const userPrimaryId = getPrimaryId('user')
|
||||
|
||||
export const projectId = id
|
||||
export const deploymentId = id
|
||||
export const consumerId = id
|
||||
export const logEntryId = id
|
||||
export const teamId = id
|
||||
export const userId = id
|
||||
|
||||
export function stripeId<U extends string, T extends Readonly<[U, ...U[]]>>(
|
||||
config?: PgVarcharConfig<T | Writable<T>, never>
|
||||
): PgVarcharBuilderInitial<'', Writable<T>, 255> {
|
||||
|
@ -66,13 +116,6 @@ export function teamSlug<U extends string, T extends Readonly<[U, ...U[]]>>(
|
|||
return varchar({ length: usernameAndTeamSlugLength, ...config })
|
||||
}
|
||||
|
||||
/**
|
||||
* Default `id` primary key as a cuid2
|
||||
*/
|
||||
export const id = varchar('id', { length: 24 })
|
||||
.primaryKey()
|
||||
.$defaultFn(createId)
|
||||
|
||||
/**
|
||||
* Timestamp with mode `string`
|
||||
*/
|
||||
|
|
|
@ -9,13 +9,21 @@ import {
|
|||
import { z } from '@hono/zod-openapi'
|
||||
|
||||
import {
|
||||
consumerIdSchema,
|
||||
deploymentIdSchema,
|
||||
projectIdSchema,
|
||||
userIdSchema
|
||||
} from '../schemas'
|
||||
import {
|
||||
consumerPrimaryId,
|
||||
createInsertSchema,
|
||||
createSelectSchema,
|
||||
createUpdateSchema,
|
||||
cuid,
|
||||
id,
|
||||
deploymentId,
|
||||
projectId,
|
||||
stripeId,
|
||||
timestamps
|
||||
timestamps,
|
||||
userId
|
||||
} from './common'
|
||||
import { deployments } from './deployment'
|
||||
import { projects } from './project'
|
||||
|
@ -42,7 +50,7 @@ import { users } from './user'
|
|||
export const consumers = pgTable(
|
||||
'consumers',
|
||||
{
|
||||
id,
|
||||
id: consumerPrimaryId,
|
||||
...timestamps,
|
||||
|
||||
// API token for this consumer
|
||||
|
@ -62,12 +70,12 @@ export const consumers = pgTable(
|
|||
// only used during initial creation
|
||||
source: text(),
|
||||
|
||||
userId: cuid()
|
||||
userId: userId()
|
||||
.notNull()
|
||||
.references(() => users.id),
|
||||
|
||||
// The project this user is subscribed to
|
||||
projectId: cuid()
|
||||
projectId: projectId()
|
||||
.notNull()
|
||||
.references(() => projects.id, {
|
||||
onDelete: 'cascade'
|
||||
|
@ -75,7 +83,7 @@ export const consumers = pgTable(
|
|||
|
||||
// The specific deployment this user is subscribed to, since pricing can
|
||||
// change across deployment versions)
|
||||
deploymentId: cuid()
|
||||
deploymentId: deploymentId()
|
||||
.notNull()
|
||||
.references(() => deployments.id, {
|
||||
onDelete: 'cascade'
|
||||
|
@ -131,6 +139,11 @@ export const consumersRelations = relations(consumers, ({ one }) => ({
|
|||
}))
|
||||
|
||||
export const consumerSelectSchema = createSelectSchema(consumers, {
|
||||
id: consumerIdSchema,
|
||||
userId: userIdSchema,
|
||||
projectId: projectIdSchema,
|
||||
deploymentId: deploymentIdSchema,
|
||||
|
||||
_stripeSubscriptionItemIdMap: stripeSubscriptionItemIdMapSchema
|
||||
})
|
||||
.omit({
|
||||
|
@ -158,7 +171,7 @@ export const consumerSelectSchema = createSelectSchema(consumers, {
|
|||
.openapi('Consumer')
|
||||
|
||||
export const consumerInsertSchema = createInsertSchema(consumers, {
|
||||
deploymentId: (schema) => schema.cuid2().optional(),
|
||||
deploymentId: deploymentIdSchema.optional(),
|
||||
|
||||
plan: z.string().nonempty()
|
||||
})
|
||||
|
@ -170,7 +183,7 @@ export const consumerInsertSchema = createInsertSchema(consumers, {
|
|||
.strict()
|
||||
|
||||
export const consumerUpdateSchema = createUpdateSchema(consumers, {
|
||||
deploymentId: (schema) => schema.cuid2().optional()
|
||||
deploymentId: deploymentIdSchema.optional()
|
||||
})
|
||||
.pick({
|
||||
plan: true,
|
||||
|
|
|
@ -10,15 +10,23 @@ import {
|
|||
} from '@fisch0920/drizzle-orm/pg-core'
|
||||
import { z } from '@hono/zod-openapi'
|
||||
|
||||
import { deploymentIdentifierSchema, projectIdSchema } from '../schemas'
|
||||
import {
|
||||
deploymentIdentifierSchema,
|
||||
deploymentIdSchema,
|
||||
projectIdSchema,
|
||||
teamIdSchema,
|
||||
userIdSchema
|
||||
} from '../schemas'
|
||||
import {
|
||||
createInsertSchema,
|
||||
createSelectSchema,
|
||||
createUpdateSchema,
|
||||
cuid,
|
||||
deploymentIdentifier,
|
||||
id,
|
||||
timestamps
|
||||
deploymentPrimaryId,
|
||||
projectId,
|
||||
teamId,
|
||||
timestamps,
|
||||
userId
|
||||
} from './common'
|
||||
import { projects } from './project'
|
||||
import {
|
||||
|
@ -33,7 +41,7 @@ import { users } from './user'
|
|||
export const deployments = pgTable(
|
||||
'deployments',
|
||||
{
|
||||
id,
|
||||
id: deploymentPrimaryId,
|
||||
...timestamps,
|
||||
|
||||
identifier: deploymentIdentifier().unique().notNull(),
|
||||
|
@ -46,11 +54,11 @@ export const deployments = pgTable(
|
|||
readme: text().default('').notNull(),
|
||||
iconUrl: text(),
|
||||
|
||||
userId: cuid()
|
||||
userId: userId()
|
||||
.notNull()
|
||||
.references(() => users.id),
|
||||
teamId: cuid().references(() => teams.id),
|
||||
projectId: cuid()
|
||||
teamId: teamId().references(() => teams.id),
|
||||
projectId: projectId()
|
||||
.notNull()
|
||||
.references(() => projects.id, {
|
||||
onDelete: 'cascade'
|
||||
|
@ -115,6 +123,10 @@ export const deploymentsRelations = relations(deployments, ({ one }) => ({
|
|||
// TODO: virtual openapi spec? (hide openapi.servers)
|
||||
|
||||
export const deploymentSelectSchema = createSelectSchema(deployments, {
|
||||
id: deploymentIdSchema,
|
||||
userId: userIdSchema,
|
||||
teamId: teamIdSchema.optional(),
|
||||
projectId: projectIdSchema,
|
||||
identifier: deploymentIdentifierSchema,
|
||||
|
||||
hash: (schema) =>
|
||||
|
|
|
@ -1,14 +1,28 @@
|
|||
import { relations } from '@fisch0920/drizzle-orm'
|
||||
import { index, jsonb, pgTable, text } from '@fisch0920/drizzle-orm/pg-core'
|
||||
import {
|
||||
index,
|
||||
jsonb,
|
||||
pgTable,
|
||||
text,
|
||||
varchar
|
||||
} from '@fisch0920/drizzle-orm/pg-core'
|
||||
|
||||
import {
|
||||
createInsertSchema,
|
||||
consumerIdSchema,
|
||||
deploymentIdSchema,
|
||||
projectIdSchema,
|
||||
userIdSchema
|
||||
} from '../schemas'
|
||||
import {
|
||||
consumerId,
|
||||
createSelectSchema,
|
||||
cuid,
|
||||
id,
|
||||
deploymentId,
|
||||
logEntryLevelEnum,
|
||||
logEntryPrimaryId,
|
||||
logEntryTypeEnum,
|
||||
timestamps
|
||||
projectId,
|
||||
timestamps,
|
||||
userId
|
||||
} from './common'
|
||||
import { consumers } from './consumer'
|
||||
import { deployments } from './deployment'
|
||||
|
@ -21,7 +35,7 @@ import { users } from './user'
|
|||
export const logEntries = pgTable(
|
||||
'log_entries',
|
||||
{
|
||||
id,
|
||||
id: logEntryPrimaryId,
|
||||
...timestamps,
|
||||
|
||||
// core data (required)
|
||||
|
@ -32,29 +46,31 @@ export const logEntries = pgTable(
|
|||
// context info (required)
|
||||
environment: text(),
|
||||
service: text(),
|
||||
requestId: text(),
|
||||
traceId: text(),
|
||||
requestId: varchar({ length: 512 }),
|
||||
traceId: varchar({ length: 512 }),
|
||||
|
||||
// relations (optional)
|
||||
userId: cuid(),
|
||||
projectId: cuid(),
|
||||
deploymentId: cuid(),
|
||||
consumerId: cuid(),
|
||||
userId: userId(),
|
||||
projectId: projectId(),
|
||||
deploymentId: deploymentId(),
|
||||
consumerId: consumerId(),
|
||||
|
||||
// misc metadata (optional)
|
||||
metadata: jsonb().$type<Record<string, unknown>>().default({}).notNull()
|
||||
},
|
||||
(table) => [
|
||||
index('log_entry_type_idx').on(table.type),
|
||||
index('log_entry_level_idx').on(table.level),
|
||||
index('log_entry_environment_idx').on(table.environment),
|
||||
index('log_entry_service_idx').on(table.service),
|
||||
index('log_entry_requestId_idx').on(table.requestId),
|
||||
index('log_entry_traceId_idx').on(table.traceId),
|
||||
// TODO: Don't add these extra indices until we need them. They'll become
|
||||
// very large very fast.
|
||||
// index('log_entry_level_idx').on(table.level),
|
||||
// index('log_entry_environment_idx').on(table.environment),
|
||||
// index('log_entry_service_idx').on(table.service),
|
||||
// index('log_entry_requestId_idx').on(table.requestId),
|
||||
// index('log_entry_traceId_idx').on(table.traceId),
|
||||
index('log_entry_userId_idx').on(table.userId),
|
||||
index('log_entry_projectId_idx').on(table.projectId),
|
||||
index('log_entry_deploymentId_idx').on(table.deploymentId),
|
||||
index('log_entry_consumerId_idx').on(table.consumerId),
|
||||
// index('log_entry_consumerId_idx').on(table.consumerId),
|
||||
index('log_entry_createdAt_idx').on(table.createdAt),
|
||||
index('log_entry_updatedAt_idx').on(table.updatedAt),
|
||||
index('log_entry_deletedAt_idx').on(table.deletedAt)
|
||||
|
@ -80,7 +96,12 @@ export const logEntriesRelations = relations(logEntries, ({ one }) => ({
|
|||
})
|
||||
}))
|
||||
|
||||
export const logEntrySelectSchema = createSelectSchema(logEntries)
|
||||
export const logEntrySelectSchema = createSelectSchema(logEntries, {
|
||||
userId: userIdSchema.optional(),
|
||||
projectId: projectIdSchema.optional(),
|
||||
deploymentId: deploymentIdSchema.optional(),
|
||||
consumerId: consumerIdSchema.optional()
|
||||
})
|
||||
// .extend({
|
||||
// user: z
|
||||
// .lazy(() => userSelectSchema)
|
||||
|
@ -104,11 +125,3 @@ export const logEntrySelectSchema = createSelectSchema(logEntries)
|
|||
// })
|
||||
.strip()
|
||||
.openapi('LogEntry')
|
||||
|
||||
export const logEntryInsertSchema = createInsertSchema(logEntries)
|
||||
.omit({
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true
|
||||
})
|
||||
.strict()
|
||||
|
|
|
@ -11,18 +11,26 @@ import {
|
|||
} from '@fisch0920/drizzle-orm/pg-core'
|
||||
import { z } from '@hono/zod-openapi'
|
||||
|
||||
import { projectIdentifierSchema } from '../schemas'
|
||||
import {
|
||||
deploymentIdSchema,
|
||||
projectIdentifierSchema,
|
||||
projectIdSchema,
|
||||
teamIdSchema,
|
||||
userIdSchema
|
||||
} from '../schemas'
|
||||
import {
|
||||
createInsertSchema,
|
||||
createSelectSchema,
|
||||
createUpdateSchema,
|
||||
cuid,
|
||||
id,
|
||||
deploymentId,
|
||||
pricingCurrencyEnum,
|
||||
pricingIntervalEnum,
|
||||
projectIdentifier,
|
||||
projectPrimaryId,
|
||||
stripeId,
|
||||
timestamps
|
||||
teamId,
|
||||
timestamps,
|
||||
userId
|
||||
} from './common'
|
||||
import { deployments } from './deployment'
|
||||
import {
|
||||
|
@ -40,23 +48,23 @@ import { users } from './user'
|
|||
export const projects = pgTable(
|
||||
'projects',
|
||||
{
|
||||
id,
|
||||
id: projectPrimaryId,
|
||||
...timestamps,
|
||||
|
||||
identifier: projectIdentifier().unique().notNull(),
|
||||
name: text().notNull(),
|
||||
alias: text(),
|
||||
|
||||
userId: cuid()
|
||||
userId: userId()
|
||||
.notNull()
|
||||
.references(() => users.id),
|
||||
teamId: cuid(),
|
||||
teamId: teamId(),
|
||||
|
||||
// Most recently published Deployment if one exists
|
||||
lastPublishedDeploymentId: cuid(),
|
||||
lastPublishedDeploymentId: deploymentId(),
|
||||
|
||||
// Most recent Deployment if one exists
|
||||
lastDeploymentId: cuid(),
|
||||
lastDeploymentId: deploymentId(),
|
||||
|
||||
applicationFeePercent: integer().default(20).notNull(),
|
||||
|
||||
|
@ -162,16 +170,21 @@ export const projectsRelations = relations(projects, ({ one }) => ({
|
|||
}))
|
||||
|
||||
export const projectSelectSchema = createSelectSchema(projects, {
|
||||
id: projectIdSchema,
|
||||
userId: userIdSchema,
|
||||
teamId: teamIdSchema.optional(),
|
||||
identifier: projectIdentifierSchema,
|
||||
lastPublishedDeploymentId: deploymentIdSchema.optional(),
|
||||
lastDeploymentId: deploymentIdSchema.optional(),
|
||||
|
||||
applicationFeePercent: (schema) => schema.nonnegative(),
|
||||
|
||||
pricingIntervals: z.array(pricingIntervalSchema).nonempty(),
|
||||
defaultPricingInterval: pricingIntervalSchema,
|
||||
|
||||
_stripeProductIdMap: stripeProductIdMapSchema,
|
||||
_stripePriceIdMap: stripePriceIdMapSchema,
|
||||
_stripeMeterIdMap: stripeMeterIdMapSchema,
|
||||
|
||||
pricingIntervals: z.array(pricingIntervalSchema).nonempty(),
|
||||
defaultPricingInterval: pricingIntervalSchema
|
||||
_stripeMeterIdMap: stripeMeterIdMapSchema
|
||||
})
|
||||
.omit({
|
||||
_secret: true,
|
||||
|
|
|
@ -6,15 +6,17 @@ import {
|
|||
primaryKey
|
||||
} from '@fisch0920/drizzle-orm/pg-core'
|
||||
|
||||
import { userIdSchema } from '../schemas'
|
||||
import {
|
||||
createInsertSchema,
|
||||
createSelectSchema,
|
||||
createUpdateSchema,
|
||||
cuid,
|
||||
teamId,
|
||||
teamMemberRoleEnum,
|
||||
teamSlug,
|
||||
timestamp,
|
||||
timestamps
|
||||
timestamps,
|
||||
userId
|
||||
} from './common'
|
||||
import { teams } from './team'
|
||||
import { users } from './user'
|
||||
|
@ -24,13 +26,13 @@ export const teamMembers = pgTable(
|
|||
{
|
||||
...timestamps,
|
||||
|
||||
userId: cuid()
|
||||
userId: userId()
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: 'cascade' }),
|
||||
teamSlug: teamSlug()
|
||||
.notNull()
|
||||
.references(() => teams.slug, { onDelete: 'cascade' }),
|
||||
teamId: cuid()
|
||||
teamId: teamId()
|
||||
.notNull()
|
||||
.references(() => teams.id, { onDelete: 'cascade' }),
|
||||
role: teamMemberRoleEnum().default('user').notNull(),
|
||||
|
@ -75,7 +77,9 @@ export const teamMemberSelectSchema = createSelectSchema(teamMembers)
|
|||
.strip()
|
||||
.openapi('TeamMember')
|
||||
|
||||
export const teamMemberInsertSchema = createInsertSchema(teamMembers)
|
||||
export const teamMemberInsertSchema = createInsertSchema(teamMembers, {
|
||||
userId: userIdSchema
|
||||
})
|
||||
.pick({
|
||||
userId: true,
|
||||
role: true
|
||||
|
|
|
@ -7,14 +7,15 @@ import {
|
|||
uniqueIndex
|
||||
} from '@fisch0920/drizzle-orm/pg-core'
|
||||
|
||||
import { userIdSchema } from '../schemas'
|
||||
import {
|
||||
createInsertSchema,
|
||||
createSelectSchema,
|
||||
createUpdateSchema,
|
||||
cuid,
|
||||
id,
|
||||
teamPrimaryId,
|
||||
teamSlug,
|
||||
timestamps
|
||||
timestamps,
|
||||
userId
|
||||
} from './common'
|
||||
import { teamMembers } from './team-member'
|
||||
import { users } from './user'
|
||||
|
@ -22,13 +23,13 @@ import { users } from './user'
|
|||
export const teams = pgTable(
|
||||
'teams',
|
||||
{
|
||||
id,
|
||||
id: teamPrimaryId,
|
||||
...timestamps,
|
||||
|
||||
slug: teamSlug().notNull().unique(),
|
||||
slug: teamSlug().unique().notNull(),
|
||||
name: text().notNull(),
|
||||
|
||||
ownerId: cuid().notNull()
|
||||
ownerId: userId().notNull()
|
||||
},
|
||||
(table) => [
|
||||
uniqueIndex('team_slug_idx').on(table.slug),
|
||||
|
@ -65,7 +66,9 @@ export const teamInsertSchema = createInsertSchema(teams, {
|
|||
.omit({ id: true, createdAt: true, updatedAt: true, ownerId: true })
|
||||
.strict()
|
||||
|
||||
export const teamUpdateSchema = createUpdateSchema(teams)
|
||||
export const teamUpdateSchema = createUpdateSchema(teams, {
|
||||
ownerId: userIdSchema
|
||||
})
|
||||
.pick({
|
||||
name: true,
|
||||
ownerId: true
|
||||
|
|
|
@ -15,11 +15,11 @@ import {
|
|||
createInsertSchema,
|
||||
createSelectSchema,
|
||||
createUpdateSchema,
|
||||
id,
|
||||
stripeId,
|
||||
timestamp,
|
||||
timestamps,
|
||||
username,
|
||||
userPrimaryId,
|
||||
userRoleEnum
|
||||
} from './common'
|
||||
import { type AuthProviders, publicAuthProvidersSchema } from './schemas'
|
||||
|
@ -28,7 +28,7 @@ import { teams } from './team'
|
|||
export const users = pgTable(
|
||||
'users',
|
||||
{
|
||||
id,
|
||||
id: userPrimaryId,
|
||||
...timestamps,
|
||||
|
||||
username: username().notNull().unique(),
|
||||
|
@ -52,7 +52,7 @@ export const users = pgTable(
|
|||
// third-party auth providers
|
||||
authProviders: jsonb().$type<AuthProviders>().default({}).notNull(),
|
||||
|
||||
stripeCustomerId: stripeId().unique()
|
||||
stripeCustomerId: stripeId()
|
||||
},
|
||||
(table) => [
|
||||
uniqueIndex('user_email_idx').on(table.email),
|
||||
|
|
|
@ -1,23 +1,47 @@
|
|||
import { assert } from '@agentic/platform-core'
|
||||
import { validators } from '@agentic/platform-validators'
|
||||
import { z } from '@hono/zod-openapi'
|
||||
|
||||
import type { consumersRelations } from './schema/consumer'
|
||||
import type { deploymentsRelations } from './schema/deployment'
|
||||
import type { projectsRelations } from './schema/project'
|
||||
import { idPrefixMap, type ModelType } from './schema/common'
|
||||
|
||||
function getCuidSchema(idLabel: string) {
|
||||
return z.string().refine((id) => validators.cuid(id), {
|
||||
message: `Invalid ${idLabel}`
|
||||
})
|
||||
export function getIdSchemaForModelType(modelType: ModelType) {
|
||||
const idPrefix = idPrefixMap[modelType]
|
||||
assert(idPrefix, 500, `Invalid model type: ${modelType}`)
|
||||
|
||||
// Convert model type to PascalCase
|
||||
const modelDisplayName =
|
||||
modelType.charAt(0).toUpperCase() + modelType.slice(1)
|
||||
const example = `${idPrefix}_tz4a98xxat96iws9zmbrgj3a`
|
||||
|
||||
return z
|
||||
.string()
|
||||
.refine(
|
||||
(id) => {
|
||||
const parts = id.split('_')
|
||||
if (parts.length !== 2) return false
|
||||
if (parts[0] !== idPrefix) return false
|
||||
if (!validators.cuid(parts[1])) return false
|
||||
|
||||
return true
|
||||
},
|
||||
{
|
||||
message: `Invalid ${modelDisplayName} id`
|
||||
}
|
||||
)
|
||||
.describe(`${modelDisplayName} id (e.g. "${example}")`)
|
||||
// TODO: is this necessary?
|
||||
// .openapi(`${modelDisplayName}Id`, { example })
|
||||
}
|
||||
|
||||
export const cuidSchema = getCuidSchema('id')
|
||||
export const userIdSchema = getCuidSchema('user id')
|
||||
export const teamIdSchema = getCuidSchema('team id')
|
||||
export const consumerIdSchema = getCuidSchema('consumer id')
|
||||
export const projectIdSchema = getCuidSchema('project id')
|
||||
export const deploymentIdSchema = getCuidSchema('deployment id')
|
||||
export const logEntryIdSchema = getCuidSchema('log entry id')
|
||||
export const userIdSchema = getIdSchemaForModelType('user')
|
||||
export const teamIdSchema = getIdSchemaForModelType('team')
|
||||
export const consumerIdSchema = getIdSchemaForModelType('consumer')
|
||||
export const projectIdSchema = getIdSchemaForModelType('project')
|
||||
export const deploymentIdSchema = getIdSchemaForModelType('deployment')
|
||||
export const logEntryIdSchema = getIdSchemaForModelType('logEntry')
|
||||
|
||||
export const projectIdentifierSchema = z
|
||||
.string()
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
exports[`URL prefix and suffix success 1`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
}
|
||||
`;
|
||||
|
@ -12,8 +12,8 @@ exports[`URL prefix and suffix success 1`] = `
|
|||
exports[`URL prefix and suffix success 2`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo/bar/123",
|
||||
}
|
||||
`;
|
||||
|
@ -21,8 +21,8 @@ exports[`URL prefix and suffix success 2`] = `
|
|||
exports[`URL prefix success 1`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
}
|
||||
`;
|
||||
|
@ -30,8 +30,8 @@ exports[`URL prefix success 1`] = `
|
|||
exports[`URL prefix success 2`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
}
|
||||
`;
|
||||
|
@ -39,8 +39,8 @@ exports[`URL prefix success 2`] = `
|
|||
exports[`URL prefix success 3`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo/bar/456/123",
|
||||
}
|
||||
`;
|
||||
|
@ -48,8 +48,8 @@ exports[`URL prefix success 3`] = `
|
|||
exports[`URL prefix success 4`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo/bar/456/123",
|
||||
}
|
||||
`;
|
||||
|
@ -57,15 +57,15 @@ exports[`URL prefix success 4`] = `
|
|||
exports[`URL prefix success 5`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo/bar/456/123",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`URL prefix success 6`] = `
|
||||
{
|
||||
"projectId": "username/foo-bar",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo/bar/456/123",
|
||||
"version": "latest",
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ exports[`URL prefix success 6`] = `
|
|||
|
||||
exports[`URL prefix success 7`] = `
|
||||
{
|
||||
"projectId": "username/foo-bar",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo/bar/456/123",
|
||||
"version": "dev",
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ exports[`URL prefix success 7`] = `
|
|||
|
||||
exports[`URL prefix success 8`] = `
|
||||
{
|
||||
"projectId": "username/foo-bar",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo/bar/456/123",
|
||||
"version": "2.1.0",
|
||||
}
|
||||
|
@ -90,15 +90,15 @@ exports[`URL prefix success 8`] = `
|
|||
exports[`URL suffix success 1`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`URL suffix success 2`] = `
|
||||
{
|
||||
"projectId": "username/foo-bar",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
"version": "latest",
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ exports[`URL suffix success 2`] = `
|
|||
|
||||
exports[`URL suffix success 3`] = `
|
||||
{
|
||||
"projectId": "username/foo-bar",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
"version": "dev",
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ exports[`URL suffix success 3`] = `
|
|||
|
||||
exports[`URL suffix success 4`] = `
|
||||
{
|
||||
"projectId": "username/foo-bar",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
"version": "2.1.0",
|
||||
}
|
||||
|
@ -123,8 +123,8 @@ exports[`URL suffix success 4`] = `
|
|||
exports[`namespace success 1`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
}
|
||||
`;
|
||||
|
@ -132,8 +132,8 @@ exports[`namespace success 1`] = `
|
|||
exports[`namespace success 2`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
}
|
||||
`;
|
||||
|
@ -141,8 +141,8 @@ exports[`namespace success 2`] = `
|
|||
exports[`namespace success 3`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
}
|
||||
`;
|
||||
|
@ -150,8 +150,8 @@ exports[`namespace success 3`] = `
|
|||
exports[`namespace success 4`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
}
|
||||
`;
|
||||
|
@ -159,8 +159,8 @@ exports[`namespace success 4`] = `
|
|||
exports[`namespace success 5`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo/bar/123",
|
||||
}
|
||||
`;
|
||||
|
@ -168,15 +168,15 @@ exports[`namespace success 5`] = `
|
|||
exports[`namespace success 6`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo/bar/123",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`namespace success 7`] = `
|
||||
{
|
||||
"projectId": "username/foo-bar",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo/bar/123",
|
||||
"version": "latest",
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ exports[`namespace success 7`] = `
|
|||
|
||||
exports[`namespace success 8`] = `
|
||||
{
|
||||
"projectId": "username/foo-bar",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo/bar/123",
|
||||
"version": "dev",
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ exports[`namespace success 8`] = `
|
|||
|
||||
exports[`namespace success 9`] = `
|
||||
{
|
||||
"projectId": "username/foo-bar",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo/bar/123",
|
||||
"version": "1.2.3",
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
exports[`username/projectName success 1`] = `
|
||||
{
|
||||
"projectId": "abc/hello-world",
|
||||
"projectIdentifier": "abc/hello-world",
|
||||
"servicePath": "/",
|
||||
"version": "latest",
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ exports[`username/projectName success 1`] = `
|
|||
|
||||
exports[`username/projectName success 2`] = `
|
||||
{
|
||||
"projectId": "a16z/foo-bar",
|
||||
"projectIdentifier": "a16z/foo-bar",
|
||||
"servicePath": "/",
|
||||
"version": "latest",
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ exports[`username/projectName success 2`] = `
|
|||
|
||||
exports[`username/projectName success 3`] = `
|
||||
{
|
||||
"projectId": "foodoo/foo-bar",
|
||||
"projectIdentifier": "foodoo/foo-bar",
|
||||
"servicePath": "/",
|
||||
"version": "latest",
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ exports[`username/projectName success 3`] = `
|
|||
|
||||
exports[`username/projectName success 4`] = `
|
||||
{
|
||||
"projectId": "u/foobar123-yo",
|
||||
"projectIdentifier": "u/foobar123-yo",
|
||||
"servicePath": "/",
|
||||
"version": "latest",
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ exports[`username/projectName success 4`] = `
|
|||
|
||||
exports[`username/projectName success 5`] = `
|
||||
{
|
||||
"projectId": "abc/hello-world",
|
||||
"projectIdentifier": "abc/hello-world",
|
||||
"servicePath": "/",
|
||||
"version": "latest",
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ exports[`username/projectName success 5`] = `
|
|||
|
||||
exports[`username/projectName/servicePath success 1`] = `
|
||||
{
|
||||
"projectId": "u/foo-bar",
|
||||
"projectIdentifier": "u/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
"version": "latest",
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ exports[`username/projectName/servicePath success 1`] = `
|
|||
|
||||
exports[`username/projectName/servicePath success 2`] = `
|
||||
{
|
||||
"projectId": "a/foo-bar",
|
||||
"projectIdentifier": "a/foo-bar",
|
||||
"servicePath": "/foo_123",
|
||||
"version": "latest",
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ exports[`username/projectName/servicePath success 2`] = `
|
|||
|
||||
exports[`username/projectName/servicePath success 3`] = `
|
||||
{
|
||||
"projectId": "foo/foobar123-yo",
|
||||
"projectIdentifier": "foo/foobar123-yo",
|
||||
"servicePath": "/foo_bar_BAR_901",
|
||||
"version": "latest",
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ exports[`username/projectName/servicePath success 3`] = `
|
|||
|
||||
exports[`username/projectName/servicePath success 4`] = `
|
||||
{
|
||||
"projectId": "foo/foobar123-yo",
|
||||
"projectIdentifier": "foo/foobar123-yo",
|
||||
"servicePath": "/foo/bar/123/456",
|
||||
"version": "latest",
|
||||
}
|
||||
|
@ -75,15 +75,15 @@ exports[`username/projectName/servicePath success 4`] = `
|
|||
exports[`username/projectName@deployment success 1`] = `
|
||||
{
|
||||
"deploymentHash": "3d2e0fd5",
|
||||
"deploymentId": "abc/hello-world@3d2e0fd5",
|
||||
"projectId": "abc/hello-world",
|
||||
"deploymentIdentifier": "abc/hello-world@3d2e0fd5",
|
||||
"projectIdentifier": "abc/hello-world",
|
||||
"servicePath": "/",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`username/projectName@deployment success 2`] = `
|
||||
{
|
||||
"projectId": "a16z/foo-bar",
|
||||
"projectIdentifier": "a16z/foo-bar",
|
||||
"servicePath": "/",
|
||||
"version": "f673db32c",
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ exports[`username/projectName@deployment success 2`] = `
|
|||
|
||||
exports[`username/projectName@deployment success 3`] = `
|
||||
{
|
||||
"projectId": "foodoo/foo-bar",
|
||||
"projectIdentifier": "foodoo/foo-bar",
|
||||
"servicePath": "/",
|
||||
"version": "f673db32c",
|
||||
}
|
||||
|
@ -100,8 +100,8 @@ exports[`username/projectName@deployment success 3`] = `
|
|||
exports[`username/projectName@deployment success 4`] = `
|
||||
{
|
||||
"deploymentHash": "673db32c",
|
||||
"deploymentId": "u/foobar123-yo@673db32c",
|
||||
"projectId": "u/foobar123-yo",
|
||||
"deploymentIdentifier": "u/foobar123-yo@673db32c",
|
||||
"projectIdentifier": "u/foobar123-yo",
|
||||
"servicePath": "/",
|
||||
}
|
||||
`;
|
||||
|
@ -109,8 +109,8 @@ exports[`username/projectName@deployment success 4`] = `
|
|||
exports[`username/projectName@deployment success 5`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/",
|
||||
}
|
||||
`;
|
||||
|
@ -118,8 +118,8 @@ exports[`username/projectName@deployment success 5`] = `
|
|||
exports[`username/projectName@deployment/servicePath success 1`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foo-bar@01234567",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@01234567",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
}
|
||||
`;
|
||||
|
@ -127,8 +127,8 @@ exports[`username/projectName@deployment/servicePath success 1`] = `
|
|||
exports[`username/projectName@deployment/servicePath success 2`] = `
|
||||
{
|
||||
"deploymentHash": "abc123lz",
|
||||
"deploymentId": "username/foo-bar@abc123lz",
|
||||
"projectId": "username/foo-bar",
|
||||
"deploymentIdentifier": "username/foo-bar@abc123lz",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
}
|
||||
`;
|
||||
|
@ -136,8 +136,8 @@ exports[`username/projectName@deployment/servicePath success 2`] = `
|
|||
exports[`username/projectName@deployment/servicePath success 3`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foobar123-yo@01234567",
|
||||
"projectId": "username/foobar123-yo",
|
||||
"deploymentIdentifier": "username/foobar123-yo@01234567",
|
||||
"projectIdentifier": "username/foobar123-yo",
|
||||
"servicePath": "/foo_bar_BAR_901",
|
||||
}
|
||||
`;
|
||||
|
@ -145,15 +145,15 @@ exports[`username/projectName@deployment/servicePath success 3`] = `
|
|||
exports[`username/projectName@deployment/servicePath success 4`] = `
|
||||
{
|
||||
"deploymentHash": "01234567",
|
||||
"deploymentId": "username/foobar@01234567",
|
||||
"projectId": "username/foobar",
|
||||
"deploymentIdentifier": "username/foobar@01234567",
|
||||
"projectIdentifier": "username/foobar",
|
||||
"servicePath": "/foo/bar/123/456",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`username/projectName@version success 1`] = `
|
||||
{
|
||||
"projectId": "abc/hello-world",
|
||||
"projectIdentifier": "abc/hello-world",
|
||||
"servicePath": "/",
|
||||
"version": "1.0.3",
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ exports[`username/projectName@version success 1`] = `
|
|||
|
||||
exports[`username/projectName@version success 2`] = `
|
||||
{
|
||||
"projectId": "a16z/foo-bar",
|
||||
"projectIdentifier": "a16z/foo-bar",
|
||||
"servicePath": "/",
|
||||
"version": "latest",
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ exports[`username/projectName@version success 2`] = `
|
|||
|
||||
exports[`username/projectName@version success 3`] = `
|
||||
{
|
||||
"projectId": "a16z/foo-bar",
|
||||
"projectIdentifier": "a16z/foo-bar",
|
||||
"servicePath": "/",
|
||||
"version": "dev",
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ exports[`username/projectName@version success 3`] = `
|
|||
|
||||
exports[`username/projectName@version success 4`] = `
|
||||
{
|
||||
"projectId": "foodoo/foo-bar",
|
||||
"projectIdentifier": "foodoo/foo-bar",
|
||||
"servicePath": "/",
|
||||
"version": "1.0.1",
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ exports[`username/projectName@version success 4`] = `
|
|||
|
||||
exports[`username/projectName@version success 5`] = `
|
||||
{
|
||||
"projectId": "u/foobar123-yo",
|
||||
"projectIdentifier": "u/foobar123-yo",
|
||||
"servicePath": "/",
|
||||
"version": "3.2.2234",
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ exports[`username/projectName@version success 5`] = `
|
|||
|
||||
exports[`username/projectName@version success 6`] = `
|
||||
{
|
||||
"projectId": "username/foo-bar",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/",
|
||||
"version": "1.0.3",
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ exports[`username/projectName@version success 6`] = `
|
|||
|
||||
exports[`username/projectName@version/servicePath success 1`] = `
|
||||
{
|
||||
"projectId": "username/foo-bar",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
"version": "latest",
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ exports[`username/projectName@version/servicePath success 1`] = `
|
|||
|
||||
exports[`username/projectName@version/servicePath success 2`] = `
|
||||
{
|
||||
"projectId": "username/foo-bar",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
"version": "dev",
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ exports[`username/projectName@version/servicePath success 2`] = `
|
|||
|
||||
exports[`username/projectName@version/servicePath success 3`] = `
|
||||
{
|
||||
"projectId": "username/foo-bar",
|
||||
"projectIdentifier": "username/foo-bar",
|
||||
"servicePath": "/foo",
|
||||
"version": "1.0.0",
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ exports[`username/projectName@version/servicePath success 3`] = `
|
|||
|
||||
exports[`username/projectName@version/servicePath success 4`] = `
|
||||
{
|
||||
"projectId": "username/foobar123-yo",
|
||||
"projectIdentifier": "username/foobar123-yo",
|
||||
"servicePath": "/foo_bar_BAR_901",
|
||||
"version": "0.0.1",
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ exports[`username/projectName@version/servicePath success 4`] = `
|
|||
|
||||
exports[`username/projectName@version/servicePath success 5`] = `
|
||||
{
|
||||
"projectId": "username/foobar123-yo",
|
||||
"projectIdentifier": "username/foobar123-yo",
|
||||
"servicePath": "/foo/bar/123-456",
|
||||
"version": "0.0.1",
|
||||
}
|
||||
|
|
|
@ -20,42 +20,42 @@ export function email(value: string): boolean {
|
|||
return emailValidator.validate(value)
|
||||
}
|
||||
|
||||
export function username(value: string): boolean {
|
||||
export function username(value?: string): boolean {
|
||||
return !!value && usernameRe.test(value)
|
||||
}
|
||||
|
||||
export function team(value: string): boolean {
|
||||
export function team(value?: string): boolean {
|
||||
return username(value)
|
||||
}
|
||||
|
||||
export function password(value: string): boolean {
|
||||
export function password(value?: string): boolean {
|
||||
return !!value && passwordRe.test(value)
|
||||
}
|
||||
|
||||
export function projectName(value: string): boolean {
|
||||
export function projectName(value?: string): boolean {
|
||||
return !!value && projectNameRe.test(value)
|
||||
}
|
||||
|
||||
export function deploymentHash(value: string): boolean {
|
||||
export function deploymentHash(value?: string): boolean {
|
||||
return !!value && deploymentHashRe.test(value)
|
||||
}
|
||||
|
||||
export function projectIdentifier(value: string): boolean {
|
||||
export function projectIdentifier(value?: string): boolean {
|
||||
return !!value && projectRe.test(value)
|
||||
}
|
||||
|
||||
export function deploymentIdentifier(value: string): boolean {
|
||||
export function deploymentIdentifier(value?: string): boolean {
|
||||
return !!value && deploymentRe.test(value)
|
||||
}
|
||||
|
||||
export function serviceName(value: string): boolean {
|
||||
export function serviceName(value?: string): boolean {
|
||||
return !!value && serviceNameRe.test(value)
|
||||
}
|
||||
|
||||
export function servicePath(value: string): boolean {
|
||||
export function servicePath(value?: string): boolean {
|
||||
return !!value && servicePathRe.test(value) && isRelativeUrl(value)
|
||||
}
|
||||
|
||||
export function cuid(value: string): boolean {
|
||||
export function cuid(value?: string): boolean {
|
||||
return !!value && isCuid(value)
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue