diff --git a/packages/ingest-types/src/index.ts b/packages/ingest-types/src/index.ts index efc8c17ea2d..381110b690c 100644 --- a/packages/ingest-types/src/index.ts +++ b/packages/ingest-types/src/index.ts @@ -258,7 +258,11 @@ export type { CccCreatorSummary, Cccjson, CccLegacyTarget, + CccMediaConstraint, + CccPublicationCondition, + CccPublicationRule, CccPublicItemsPage, + CccTypeSchema, CccWebsiteCardFacet, CccWebsiteCardFacets, CccWebsiteCardsPage, diff --git a/packages/ingest-types/src/types.gen.ts b/packages/ingest-types/src/types.gen.ts index 5f2e3e44423..4d7e7f24dd1 100644 --- a/packages/ingest-types/src/types.gen.ts +++ b/packages/ingest-types/src/types.gen.ts @@ -3476,6 +3476,14 @@ export type CccLegacyTarget = { type: 'workflow' | 'app' | 'model' } +export type CccMediaConstraint = { + max_bytes?: number + max_height?: number + max_width?: number + mime_type: string + min_bytes?: number +} + export type CccPublicItemsPage = ContentCatalogProjection & { has_more: boolean /** @@ -3485,6 +3493,70 @@ export type CccPublicItemsPage = ContentCatalogProjection & { page_size: number } +/** + * Holds when field equals equals (a bool or string). if_absent decides when field is absent or null; a value of another shape holds. + */ +export type CccPublicationCondition = { + /** + * A boolean or string. + */ + equals: unknown + field: string + if_absent?: CccPublicationCondition +} + +/** + * One publish-time field rule. Publish enforces required levels, media constraints and resolves_to references; recommended levels are advice only. + */ +export type CccPublicationRule = { + /** + * Document paths such as $.title or $.workflow_versions[0].api. A level is met when any one is filled; [*] matches every array index. + */ + fields: Array + /** + * Absent means the rule only constrains a value that is set. + */ + level?: 'required' | 'recommended' + media?: CccMediaConstraint + /** + * Display text. Required and media faults return it. + */ + message: string + /** + * Content type a referenced UID must resolve to as enabled public content; "content" means any type. + */ + resolves_to?: string + /** + * Content types the rule applies to; absent means every type. + */ + types?: Array<'model' | 'workflow' | 'app' | 'template_set'> + when?: CccPublicationCondition +} + +export type CccTypeSchema = { + contract_version: string + environment: string + format: 'openapi-3.0-schema' + /** + * Content types only. + */ + publication?: { + rules: Array + } + /** + * OpenAPI 3.0 schema the save validator applies. + */ + schema: { + [key: string]: unknown + } + schema_version: number + /** + * Content types only. The readOnly CCCJSON properties; a save never applies them. + */ + server_fields?: Array + type: 'model' | 'workflow' | 'app' | 'template_set' | 'media' +} + export type CccWebsiteCardFacet = { /** * Staff-only eligible facet count @@ -19009,7 +19081,7 @@ export type GetCccTypeSchemaResponses = { /** * Build-coupled OpenAPI 3.0 schema object, type, version and API environment */ - 200: Cccjson + 200: CccTypeSchema } export type GetCccTypeSchemaResponse = diff --git a/packages/ingest-types/src/zod.gen.ts b/packages/ingest-types/src/zod.gen.ts index cd0456dd8ba..7657a38e785 100644 --- a/packages/ingest-types/src/zod.gen.ts +++ b/packages/ingest-types/src/zod.gen.ts @@ -1654,6 +1654,69 @@ export const zCccLegacyTarget = z.object({ type: z.enum(['workflow', 'app', 'model']) }) +export const zCccMediaConstraint = z.object({ + max_bytes: z.coerce + .bigint() + .min(BigInt('-9223372036854775808'), { + error: 'Invalid value: Expected int64 to be >= -9223372036854775808' + }) + .max(BigInt('9223372036854775807'), { + error: 'Invalid value: Expected int64 to be <= 9223372036854775807' + }) + .optional(), + max_height: z.int().optional(), + max_width: z.int().optional(), + mime_type: z.string(), + min_bytes: z.coerce + .bigint() + .min(BigInt('-9223372036854775808'), { + error: 'Invalid value: Expected int64 to be >= -9223372036854775808' + }) + .max(BigInt('9223372036854775807'), { + error: 'Invalid value: Expected int64 to be <= 9223372036854775807' + }) + .optional() +}) + +/** + * Holds when field equals equals (a bool or string). if_absent decides when field is absent or null; a value of another shape holds. + */ +export const zCccPublicationCondition = z.object({ + equals: z.unknown(), + field: z.string(), + if_absent: z.lazy((): any => zCccPublicationCondition).optional() +}) + +/** + * One publish-time field rule. Publish enforces required levels, media constraints and resolves_to references; recommended levels are advice only. + */ +export const zCccPublicationRule = z.object({ + fields: z.array(z.string()).min(1), + level: z.enum(['required', 'recommended']).optional(), + media: zCccMediaConstraint.optional(), + message: z.string(), + resolves_to: z.string().optional(), + types: z + .array(z.enum(['model', 'workflow', 'app', 'template_set'])) + .optional(), + when: zCccPublicationCondition.optional() +}) + +export const zCccTypeSchema = z.object({ + contract_version: z.string(), + environment: z.string(), + format: z.enum(['openapi-3.0-schema']), + publication: z + .object({ + rules: z.array(zCccPublicationRule) + }) + .optional(), + schema: z.record(z.string(), z.unknown()), + schema_version: z.int(), + server_fields: z.array(z.string()).optional(), + type: z.enum(['model', 'workflow', 'app', 'template_set', 'media']) +}) + export const zCccWebsiteCardFacet = z.object({ count: z.int().gte(0).optional(), label: z.string(), @@ -7497,7 +7560,7 @@ export const zGetCccTypeSchemaPath = z.object({ /** * Build-coupled OpenAPI 3.0 schema object, type, version and API environment */ -export const zGetCccTypeSchemaResponse = zCccjson +export const zGetCccTypeSchemaResponse = zCccTypeSchema /** * Private state; never cacheable