Relax id validation from UUID to UUID or NonEmptyString to support ES generated id's

This commit is contained in:
Garrett Spong 2024-05-15 11:02:26 -06:00
parent 252b8e8095
commit ddf93a8dd1
No known key found for this signature in database
GPG key ID: 6529D629648F8C57
12 changed files with 47 additions and 25 deletions

View file

@ -16,7 +16,7 @@ import { z } from 'zod';
* version: 1
*/
import { UUID } from '../common_attributes.gen';
import { UUID, NonEmptyString } from '../common_attributes.gen';
import { Replacements } from '../conversations/common_attributes.gen';
export type ExecuteConnectorRequestParams = z.infer<typeof ExecuteConnectorRequestParams>;
@ -30,7 +30,7 @@ export type ExecuteConnectorRequestParamsInput = z.input<typeof ExecuteConnector
export type ExecuteConnectorRequestBody = z.infer<typeof ExecuteConnectorRequestBody>;
export const ExecuteConnectorRequestBody = z.object({
conversationId: UUID.optional(),
conversationId: z.union([UUID, NonEmptyString]).optional(),
message: z.string().optional(),
model: z.string().optional(),
subAction: z.enum(['invokeAI', 'invokeStream']),

View file

@ -31,7 +31,9 @@ paths:
- subAction
properties:
conversationId:
$ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
oneOf:
- $ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
- $ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
message:
type: string
model:

View file

@ -44,7 +44,7 @@ export const NormalizedAnonymizationFieldError = z.object({
export type AnonymizationFieldResponse = z.infer<typeof AnonymizationFieldResponse>;
export const AnonymizationFieldResponse = z.object({
id: UUID,
id: z.union([UUID, NonEmptyString]),
timestamp: NonEmptyString.optional(),
field: z.string(),
allowed: z.boolean().optional(),

View file

@ -103,7 +103,9 @@ components:
- field
properties:
id:
$ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
oneOf:
- $ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
- $ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
'timestamp':
$ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
field:

View file

@ -152,7 +152,7 @@ export const ConversationSummary = z.object({
export type ErrorSchema = z.infer<typeof ErrorSchema>;
export const ErrorSchema = z
.object({
id: UUID.optional(),
id: z.union([UUID, NonEmptyString]).optional(),
error: z.object({
status_code: z.number().int().min(400),
message: z.string(),

View file

@ -130,7 +130,9 @@ components:
additionalProperties: false
properties:
id:
$ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
oneOf:
- $ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
- $ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
error:
type: object
required:

View file

@ -22,7 +22,7 @@ import {
ConversationUpdateProps,
ConversationMessageCreateProps,
} from './common_attributes.gen';
import { UUID } from '../common_attributes.gen';
import { UUID, NonEmptyString } from '../common_attributes.gen';
export type AppendConversationMessageRequestParams = z.infer<
typeof AppendConversationMessageRequestParams
@ -31,7 +31,7 @@ export const AppendConversationMessageRequestParams = z.object({
/**
* The conversation's `id` value.
*/
id: UUID,
id: z.union([UUID, NonEmptyString]),
});
export type AppendConversationMessageRequestParamsInput = z.input<
typeof AppendConversationMessageRequestParams
@ -60,7 +60,7 @@ export const DeleteConversationRequestParams = z.object({
/**
* The conversation's `id` value.
*/
id: UUID,
id: z.union([UUID, NonEmptyString]),
});
export type DeleteConversationRequestParamsInput = z.input<typeof DeleteConversationRequestParams>;
@ -72,7 +72,7 @@ export const ReadConversationRequestParams = z.object({
/**
* The conversation's `id` value.
*/
id: UUID,
id: z.union([UUID, NonEmptyString]),
});
export type ReadConversationRequestParamsInput = z.input<typeof ReadConversationRequestParams>;
@ -84,7 +84,7 @@ export const UpdateConversationRequestParams = z.object({
/**
* The conversation's `id` value.
*/
id: UUID,
id: z.union([UUID, NonEmptyString]),
});
export type UpdateConversationRequestParamsInput = z.input<typeof UpdateConversationRequestParams>;

View file

@ -52,7 +52,9 @@ paths:
required: true
description: The conversation's `id` value.
schema:
$ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
oneOf:
- $ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
- $ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
responses:
200:
description: Indicates a successful call.
@ -86,7 +88,9 @@ paths:
required: true
description: The conversation's `id` value.
schema:
$ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
oneOf:
- $ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
- $ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
requestBody:
required: true
content:
@ -126,7 +130,9 @@ paths:
required: true
description: The conversation's `id` value.
schema:
$ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
oneOf:
- $ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
- $ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
responses:
200:
description: Indicates a successful call.
@ -162,7 +168,9 @@ paths:
required: true
description: The conversation's `id` value.
schema:
$ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
oneOf:
- $ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
- $ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
requestBody:
required: true
content:

View file

@ -21,7 +21,7 @@ import {
KnowledgeBaseEntryResponse,
KnowledgeBaseEntryUpdateProps,
} from './common_attributes.gen';
import { UUID } from '../common_attributes.gen';
import { UUID, NonEmptyString } from '../common_attributes.gen';
export type CreateKnowledgeBaseEntryRequestBody = z.infer<
typeof CreateKnowledgeBaseEntryRequestBody
@ -41,7 +41,7 @@ export const DeleteKnowledgeBaseEntryRequestParams = z.object({
/**
* The Knowledge Base Entry's `id` value
*/
id: UUID,
id: z.union([UUID, NonEmptyString]),
});
export type DeleteKnowledgeBaseEntryRequestParamsInput = z.input<
typeof DeleteKnowledgeBaseEntryRequestParams
@ -57,7 +57,7 @@ export const ReadKnowledgeBaseEntryRequestParams = z.object({
/**
* The Knowledge Base Entry's `id` value.
*/
id: UUID,
id: z.union([UUID, NonEmptyString]),
});
export type ReadKnowledgeBaseEntryRequestParamsInput = z.input<
typeof ReadKnowledgeBaseEntryRequestParams
@ -73,7 +73,7 @@ export const UpdateKnowledgeBaseEntryRequestParams = z.object({
/**
* The Knowledge Base Entry's `id` value
*/
id: UUID,
id: z.union([UUID, NonEmptyString]),
});
export type UpdateKnowledgeBaseEntryRequestParamsInput = z.input<
typeof UpdateKnowledgeBaseEntryRequestParams

View file

@ -45,7 +45,9 @@ paths:
required: true
description: The Knowledge Base Entry's `id` value.
schema:
$ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
oneOf:
- $ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
- $ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
responses:
200:
description: Successful request returning a Knowledge Base Entry
@ -72,7 +74,9 @@ paths:
required: true
description: The Knowledge Base Entry's `id` value
schema:
$ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
oneOf:
- $ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
- $ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
requestBody:
required: true
content:
@ -105,7 +109,9 @@ paths:
required: true
description: The Knowledge Base Entry's `id` value
schema:
$ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
oneOf:
- $ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
- $ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
responses:
200:
description: Successful request returning the deleted Knowledge Base Entry

View file

@ -44,7 +44,7 @@ export const NormalizedPromptError = z.object({
export type PromptResponse = z.infer<typeof PromptResponse>;
export const PromptResponse = z.object({
id: UUID,
id: z.union([UUID, NonEmptyString]),
timestamp: NonEmptyString.optional(),
name: z.string(),
promptType: z.string(),

View file

@ -105,7 +105,9 @@ components:
- content
properties:
id:
$ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
oneOf:
- $ref: '../common_attributes.schema.yaml#/components/schemas/UUID'
- $ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
'timestamp':
$ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
name: