From 744c083c7d9e7fb92af63be9420ffd1d9627a67d Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 24 Apr 2023 18:00:18 -0500 Subject: [PATCH] more complete schema --- .../src/schema.ts | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/packages/kbn-content-management-utils/src/schema.ts b/packages/kbn-content-management-utils/src/schema.ts index 639695ebec813..a13a224f60a35 100644 --- a/packages/kbn-content-management-utils/src/schema.ts +++ b/packages/kbn-content-management-utils/src/schema.ts @@ -68,9 +68,49 @@ export const objectTypeToGetResultSchema = (soSchema: ObjectType) => ); export const createOptionsSchema = schema.object({ + id: schema.maybe(schema.string()), references: schema.maybe(referencesSchema), + overwrite: schema.maybe(schema.boolean()), + version: schema.maybe(schema.string()), + refresh: schema.maybe(schema.boolean()), + initialNamespaces: schema.maybe(schema.arrayOf(schema.string())), }); +export const schemaAndOr = schema.oneOf([schema.literal('AND'), schema.literal('OR')]); + +export const searchOptionsSchema = schema.object({ + page: schema.maybe(schema.number()), + perPage: schema.maybe(schema.number()), + sortField: schema.maybe(schema.string()), + sortOrder: schema.maybe(schema.oneOf([schema.literal('asc'), schema.literal('desc')])), + fields: schema.maybe(schema.arrayOf(schema.string())), + search: schema.maybe(schema.string()), + searchFields: schema.maybe(schema.oneOf([schema.string(), schema.arrayOf(schema.string())])), + rootSearchFields: schema.maybe(schema.arrayOf(schema.string())), + + hasReference: schema.maybe(schema.oneOf([referenceSchema, schema.arrayOf(referenceSchema)])), + hasReferenceOperator: schema.maybe(schemaAndOr), + hasNoReference: schema.maybe(schema.oneOf([referenceSchema, schema.arrayOf(referenceSchema)])), + hasNoReferenceOperator: schema.maybe(schemaAndOr), + defaultSearchOperator: schema.maybe(schemaAndOr), + namespaces: schema.maybe(schema.arrayOf(schema.string())), + type: schema.maybe(schema.string()), + + filter: schema.maybe(schema.string()), + pit: schema.maybe( + schema.object({ id: schema.string(), keepAlive: schema.maybe(schema.string()) }) + ), +}); + +export const updateOptionsSchema = (attributesSchema: ObjectType) => + schema.object({ + references: schema.maybe(referencesSchema), + version: schema.maybe(schema.string()), + refresh: schema.maybe(schema.oneOf([schema.boolean(), schema.literal('wait_for')])), + upsert: schema.maybe(savedObjectSchema(attributesSchema)), + retryOnConflict: schema.maybe(schema.number()), + }); + export const createResultSchema = (soSchema: ObjectType) => schema.object( {