diff --git a/packages/ui/app/src/playground/form/PlaygroundObjectPropertyForm.tsx b/packages/ui/app/src/playground/form/PlaygroundObjectPropertyForm.tsx index ba861f7e09..3960226be0 100644 --- a/packages/ui/app/src/playground/form/PlaygroundObjectPropertyForm.tsx +++ b/packages/ui/app/src/playground/form/PlaygroundObjectPropertyForm.tsx @@ -13,13 +13,60 @@ import { PlusCircle } from "iconoir-react"; import dynamic from "next/dynamic"; import { FC, memo, useCallback, useEffect, useMemo, useState } from "react"; import { renderTypeShorthandRoot } from "../../type-shorthand"; +import { WithLabel } from "../WithLabel"; import { castToRecord, getEmptyValueForType, isExpandable } from "../utils"; +import { PlaygroundMapForm } from "./PlaygroundMapForm"; import { PlaygroundTypeReferenceForm } from "./PlaygroundTypeReferenceForm"; const Markdown = dynamic(() => import("../../mdx/Markdown").then(({ Markdown }) => Markdown)); const ADD_ALL_KEY = "__FERN_ADD_ALL__" as const; +const ADDITIONAL_PROPERTIES_KEY_SHAPE = { + type: "primitive", + value: { + type: "string", + regex: undefined, + minLength: undefined, + maxLength: undefined, + default: undefined, + }, +} as const; + +const ADDITIONAL_PROPERTIES_VALUE_SHAPE = { + type: "primitive", + value: { + type: "string", + regex: undefined, + minLength: undefined, + maxLength: undefined, + default: undefined, + }, +} as const; + +// TODO: This is hardcoded for now, but change to dynamic type references, by setting value +const ADDITIONAL_PROPERTIES_DEFAULT_SHAPE = { + type: "alias", + value: { + type: "optional", + shape: { + type: "alias", + value: { + type: "map", + keyShape: { + type: "alias", + value: ADDITIONAL_PROPERTIES_KEY_SHAPE, + }, + valueShape: { + type: "alias", + value: ADDITIONAL_PROPERTIES_VALUE_SHAPE, + }, + }, + }, + default: undefined, + }, +} as const; + interface PlaygroundObjectPropertyFormProps { id: string; property: ObjectProperty; @@ -114,7 +161,7 @@ export const PlaygroundObjectPropertiesForm = memo({}); const onChangeAdditionalObjectProperty = useCallback( - (key: string, newValue: unknown) => { + (newValue: unknown) => { onChange((oldValue: unknown) => { const oldObject = castToRecord(oldValue); const val = castToRecord(newValue); @@ -256,62 +303,31 @@ export const PlaygroundObjectPropertiesForm = memo - , key) => { - if (!properties.some((p) => p.key === key)) { - acc[key] = castToRecord(value)[key]; - } - return acc; - }, {})} + value={"Optional Extra Properties"} + onRemove={() => onChangeAdditionalObjectProperty(undefined)} types={types} - disabled={disabled} - /> + > + , key) => { + if (!properties.some((p) => p.key === key)) { + acc[key] = castToRecord(value)[key]; + } + return acc; + }, {})} + types={types} + /> + )} diff --git a/servers/fdr/src/services/docs-cache/DocsDefinitionCache.ts b/servers/fdr/src/services/docs-cache/DocsDefinitionCache.ts index e236d043e1..c25cbe5736 100644 --- a/servers/fdr/src/services/docs-cache/DocsDefinitionCache.ts +++ b/servers/fdr/src/services/docs-cache/DocsDefinitionCache.ts @@ -211,12 +211,7 @@ export class DocsDefinitionCacheImpl implements DocsDefinitionCache { private async cacheResponse({ url, value }: { url: URL; value: CachedDocsResponse }): Promise { if (this.redisDocsCache) { - try { - await this.redisDocsCache.set({ url, value }); - } catch (e) { - console.error("failed cache replaceDocsForInstanceId", new Error().stack, JSON.stringify(value).length); - throw e; - } + await this.redisDocsCache.set({ url, value }); } this.localDocsCache.set({ url, value }); }