@builder.io/sdk-qwik 0.4.3 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/lib/index.qwik.cjs +475 -393
  2. package/lib/index.qwik.mjs +476 -394
  3. package/package.json +1 -1
  4. package/types/blocks/text/text.d.ts +1 -1
  5. package/types/components/block/block.d.ts +10 -0
  6. package/types/components/block/block.helpers.d.ts +12 -0
  7. package/types/components/block/components/block-styles.d.ts +8 -0
  8. package/types/components/block/components/component-ref.d.ts +21 -0
  9. package/types/components/block/components/component.d.ts +21 -0
  10. package/types/components/block/components/repeated-block.d.ts +10 -0
  11. package/types/components/block/types.d.ts +6 -0
  12. package/types/components/blocks/blocks-wrapper.d.ts +15 -0
  13. package/types/components/blocks/blocks.d.ts +9 -0
  14. package/types/components/content/builder-editing.d.ts +23 -0
  15. package/types/components/content/components/content-styles.d.ts +8 -0
  16. package/types/components/content/components/content-styles.helpers.d.ts +15 -0
  17. package/types/components/content/components/enable-editor.d.ts +23 -0
  18. package/types/components/content/components/render-styles.d.ts +8 -0
  19. package/types/components/content/components/render-styles.helpers.d.ts +15 -0
  20. package/types/components/content/content.d.ts +7 -0
  21. package/types/components/content/content.helpers.d.ts +7 -0
  22. package/types/components/content/content.types.d.ts +38 -0
  23. package/types/components/content/index.d.ts +1 -0
  24. package/types/components/content/wrap-component-ref.d.ts +6 -0
  25. package/types/components/content-variants/content-variants.d.ts +3 -0
  26. package/types/components/content-variants/helpers.d.ts +17 -0
  27. package/types/components/inlined-script.d.ts +6 -0
  28. package/types/components/inlined-styles.d.ts +6 -0
  29. package/types/components/render-content/render-content.types.d.ts +9 -23
  30. package/types/components/render-content-variants/helpers.d.ts +27 -3
  31. package/types/components/render-content-variants/render-content-variants.d.ts +8 -2
  32. package/types/components/render-content-variants/render-content-variants.types.d.ts +20 -0
  33. package/types/constants/sdk-version.d.ts +1 -1
  34. package/types/types/builder-props.d.ts +10 -0
  35. package/types/types/enforced-partials.d.ts +21 -0
  36. package/types/types/typescript.d.ts +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-qwik",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Builder.io Qwik SDK",
5
5
  "type": "module",
6
6
  "main": "./lib/index.qwik.cjs",
@@ -1,5 +1,5 @@
1
1
  export interface TextProps {
2
- text: string;
2
+ text?: string;
3
3
  }
4
4
  export declare const Text: import("@builder.io/qwik").Component<TextProps>;
5
5
  export default Text;
@@ -0,0 +1,10 @@
1
+ import { BuilderContextInterface, RegisteredComponent } from "../../context/types.js";
2
+ import { BuilderBlock } from "../../types/builder-block.js";
3
+ import { Dictionary } from "../../types/typescript.js";
4
+ export type BlockProps = {
5
+ block: BuilderBlock;
6
+ context: BuilderContextInterface;
7
+ components: Dictionary<RegisteredComponent>;
8
+ };
9
+ export declare const Block: import("@builder.io/qwik").Component<BlockProps>;
10
+ export default Block;
@@ -0,0 +1,12 @@
1
+ import type { BuilderContextInterface } from '../../context/types';
2
+ import type { BuilderBlock } from '../../types/builder-block';
3
+ import type { RepeatData } from './types';
4
+ export declare const isEmptyHtmlElement: (tagName: unknown) => boolean;
5
+ export declare const getComponent: ({ block, context, }: {
6
+ block: BuilderBlock;
7
+ context: BuilderContextInterface;
8
+ }) => import("../../context/types").RegisteredComponent | null | undefined;
9
+ export declare const getRepeatItemData: ({ block, context, }: {
10
+ block: BuilderBlock;
11
+ context: BuilderContextInterface;
12
+ }) => RepeatData[] | undefined;
@@ -0,0 +1,8 @@
1
+ import { BuilderContextInterface } from "../../../context/types.js";
2
+ import { BuilderBlock } from "../../../types/builder-block.js";
3
+ export type BlockStylesProps = {
4
+ block: BuilderBlock;
5
+ context: BuilderContextInterface;
6
+ };
7
+ export declare const BlockStyles: import("@builder.io/qwik").Component<BlockStylesProps>;
8
+ export default BlockStyles;
@@ -0,0 +1,21 @@
1
+ import { BuilderContextInterface, RegisteredComponent } from "../../../context/types.js";
2
+ import { BuilderBlock } from "../../../types/builder-block.js";
3
+ import { PropsWithBuilderData } from "../../../types/builder-props.js";
4
+ import { Dictionary } from "../../../types/typescript.js";
5
+ type ComponentOptions = PropsWithBuilderData<{
6
+ [index: string]: any;
7
+ attributes?: {
8
+ [index: string]: any;
9
+ };
10
+ }>;
11
+ export interface ComponentProps {
12
+ componentRef: any;
13
+ componentOptions: ComponentOptions;
14
+ blockChildren: BuilderBlock[];
15
+ context: BuilderContextInterface;
16
+ components: Dictionary<RegisteredComponent>;
17
+ }
18
+ export declare const ComponentRef: (props: ComponentProps & {
19
+ key?: any;
20
+ }) => import("@builder.io/qwik/jsx-runtime").JSX.Element;
21
+ export default ComponentRef;
@@ -0,0 +1,21 @@
1
+ import { BuilderContextInterface, RegisteredComponent } from "../../../context/types.js";
2
+ import { BuilderBlock } from "../../../types/builder-block.js";
3
+ import { PropsWithBuilderData } from "../../../types/builder-props.js";
4
+ import { Dictionary } from "../../../types/typescript.js";
5
+ type ComponentOptions = PropsWithBuilderData<{
6
+ [index: string]: any;
7
+ attributes?: {
8
+ [index: string]: any;
9
+ };
10
+ }>;
11
+ export interface ComponentProps {
12
+ componentRef: any;
13
+ componentOptions: ComponentOptions;
14
+ blockChildren: BuilderBlock[];
15
+ context: BuilderContextInterface;
16
+ components: Dictionary<RegisteredComponent>;
17
+ }
18
+ export declare const Component: (props: ComponentProps & {
19
+ key?: any;
20
+ }) => import("@builder.io/qwik/jsx-runtime").JSX.Element;
21
+ export default Component;
@@ -0,0 +1,10 @@
1
+ import { BuilderContextInterface, RegisteredComponent } from "../../../context/types.js";
2
+ import { BuilderBlock } from "../../../types/builder-block";
3
+ import { Dictionary } from "../../../types/typescript";
4
+ type Props = {
5
+ block: BuilderBlock;
6
+ repeatContext: BuilderContextInterface;
7
+ components: Dictionary<RegisteredComponent>;
8
+ };
9
+ export declare const RepeatedBlock: import("@builder.io/qwik").Component<Props>;
10
+ export default RepeatedBlock;
@@ -0,0 +1,6 @@
1
+ import type { BuilderContextInterface } from '../../context/types.js';
2
+ import type { BuilderBlock } from '../../types/builder-block.js';
3
+ export interface RepeatData {
4
+ block: BuilderBlock;
5
+ context: BuilderContextInterface;
6
+ }
@@ -0,0 +1,15 @@
1
+ import { BuilderBlock } from "../../types/builder-block.js";
2
+ export type BlocksWrapperProps = {
3
+ blocks: BuilderBlock[] | undefined;
4
+ parent: string | undefined;
5
+ path: string | undefined;
6
+ styleProp: Record<string, any> | undefined;
7
+ };
8
+ type PropsWithChildren = BlocksWrapperProps & {
9
+ children?: any;
10
+ };
11
+ export declare const onClick: (props: any, state: any) => void;
12
+ export declare const onMouseEnter: (props: any, state: any) => void;
13
+ export declare const BlocksWrapper: import("@builder.io/qwik").Component<PropsWithChildren>;
14
+ export default BlocksWrapper;
15
+ export declare const STYLES = "\n.div-BlocksWrapper {\n display: flex;\n flex-direction: column;\n align-items: stretch;\n}\n";
@@ -0,0 +1,9 @@
1
+ import { BuilderContextInterface, RegisteredComponent } from "../../context/types.js";
2
+ import { Dictionary } from "../../types/typescript";
3
+ import { BlocksWrapperProps } from "./blocks-wrapper";
4
+ export type BlocksProps = Partial<BlocksWrapperProps> & {
5
+ context: BuilderContextInterface;
6
+ components: Dictionary<RegisteredComponent>;
7
+ };
8
+ export declare const Blocks: import("@builder.io/qwik").Component<BlocksProps>;
9
+ export default Blocks;
@@ -0,0 +1,23 @@
1
+ import { BuilderContextInterface } from "../../context/types.js";
2
+ import { BuilderContent } from "../../types/builder-content.js";
3
+ import { ComponentInfo } from "../../types/components.js";
4
+ import { Dictionary } from "../../types/typescript.js";
5
+ import { RenderContentProps } from "./content.types.js";
6
+ type BuilderEditorProps = Omit<RenderContentProps, "customComponents"> & {
7
+ customComponents: Dictionary<ComponentInfo>;
8
+ builderContextSignal: BuilderContextInterface;
9
+ children?: any;
10
+ };
11
+ export declare const mergeNewContent: (props: any, state: any, elementRef: any, newContent: BuilderContent) => void;
12
+ export declare const processMessage: (props: any, state: any, elementRef: any, event: MessageEvent) => void;
13
+ export declare const evaluateJsCode: (props: any, state: any, elementRef: any) => void;
14
+ export declare const onClick: (props: any, state: any, elementRef: any, event: any) => void;
15
+ export declare const evalExpression: (props: any, state: any, elementRef: any, expression: string) => string;
16
+ export declare const handleRequest: (props: any, state: any, elementRef: any, { url, key, }: {
17
+ key: string;
18
+ url: string;
19
+ }) => void;
20
+ export declare const runHttpRequests: (props: any, state: any, elementRef: any) => void;
21
+ export declare const emitStateUpdate: (props: any, state: any, elementRef: any) => void;
22
+ export declare const BuilderEditing: import("@builder.io/qwik").Component<BuilderEditorProps>;
23
+ export default BuilderEditing;
@@ -0,0 +1,8 @@
1
+ import { CustomFont } from "./content-styles.helpers";
2
+ interface Props {
3
+ cssCode?: string;
4
+ customFonts?: CustomFont[];
5
+ contentId?: string;
6
+ }
7
+ export declare const ContentStyles: import("@builder.io/qwik").Component<Props>;
8
+ export default ContentStyles;
@@ -0,0 +1,15 @@
1
+ export interface CustomFont {
2
+ family?: string;
3
+ kind?: string;
4
+ fileUrl?: string;
5
+ files?: {
6
+ [key: string]: string;
7
+ };
8
+ }
9
+ export declare const getFontCss: ({ customFonts }: {
10
+ customFonts?: CustomFont[] | undefined;
11
+ }) => string;
12
+ export declare const getCss: ({ cssCode, contentId, }: {
13
+ cssCode?: string | undefined;
14
+ contentId?: string | undefined;
15
+ }) => string;
@@ -0,0 +1,23 @@
1
+ import { BuilderContextInterface } from "../../../context/types.js";
2
+ import { BuilderContent } from "../../../types/builder-content.js";
3
+ import { ComponentInfo } from "../../../types/components.js";
4
+ import { Dictionary } from "../../../types/typescript.js";
5
+ import { ContentProps } from "../content.types.js";
6
+ type BuilderEditorProps = Omit<ContentProps, "customComponents"> & {
7
+ customComponents: Dictionary<ComponentInfo>;
8
+ builderContextSignal: BuilderContextInterface;
9
+ mergeNewContent: (newContent: BuilderContent) => void;
10
+ children?: any;
11
+ };
12
+ export declare const processMessage: (props: any, state: any, elementRef: any, event: MessageEvent) => void;
13
+ export declare const evaluateJsCode: (props: any, state: any, elementRef: any) => void;
14
+ export declare const onClick: (props: any, state: any, elementRef: any, event: any) => void;
15
+ export declare const evalExpression: (props: any, state: any, elementRef: any, expression: string) => string;
16
+ export declare const handleRequest: (props: any, state: any, elementRef: any, { url, key, }: {
17
+ key: string;
18
+ url: string;
19
+ }) => void;
20
+ export declare const runHttpRequests: (props: any, state: any, elementRef: any) => void;
21
+ export declare const emitStateUpdate: (props: any, state: any, elementRef: any) => void;
22
+ export declare const EnableEditor: import("@builder.io/qwik").Component<BuilderEditorProps>;
23
+ export default EnableEditor;
@@ -0,0 +1,8 @@
1
+ import { CustomFont } from "./render-styles.helpers";
2
+ interface Props {
3
+ cssCode?: string;
4
+ customFonts?: CustomFont[];
5
+ contentId?: string;
6
+ }
7
+ export declare const RenderContentStyles: import("@builder.io/qwik").Component<Props>;
8
+ export default RenderContentStyles;
@@ -0,0 +1,15 @@
1
+ export interface CustomFont {
2
+ family?: string;
3
+ kind?: string;
4
+ fileUrl?: string;
5
+ files?: {
6
+ [key: string]: string;
7
+ };
8
+ }
9
+ export declare const getFontCss: ({ customFonts }: {
10
+ customFonts?: CustomFont[] | undefined;
11
+ }) => string;
12
+ export declare const getCss: ({ cssCode, contentId, }: {
13
+ cssCode?: string | undefined;
14
+ contentId?: string | undefined;
15
+ }) => string;
@@ -0,0 +1,7 @@
1
+ import { BuilderRenderState } from "../../context/types.js";
2
+ import { BuilderContent } from "../../types/builder-content.js";
3
+ import { ContentProps } from "./content.types.js";
4
+ export declare const mergeNewContent: (props: any, state: any, newContent: BuilderContent) => void;
5
+ export declare const contentSetState: (props: any, state: any, newRootState: BuilderRenderState) => void;
6
+ export declare const Content: import("@builder.io/qwik").Component<ContentProps>;
7
+ export default Content;
@@ -0,0 +1,7 @@
1
+ import type { BuilderContent } from '../../types/builder-content';
2
+ import type { Nullable } from '../../types/typescript';
3
+ import type { ContentProps } from './content.types';
4
+ export declare const getContextStateInitialValue: ({ content, data, locale, }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
5
+ [x: string]: unknown;
6
+ };
7
+ export declare const getContentInitialValue: ({ content, data, }: Pick<ContentProps, 'content' | 'data'>) => Nullable<BuilderContent>;
@@ -0,0 +1,38 @@
1
+ import type { BuilderRenderContext, RegisteredComponent, BuilderRenderState } from '../../context/types';
2
+ import type { BuilderContent } from '../../types/builder-content';
3
+ import type { Nullable } from '../../types/typescript';
4
+ import type { ApiVersion } from '../../types/api-version';
5
+ export interface ContentProps {
6
+ content?: Nullable<BuilderContent>;
7
+ model?: string;
8
+ data?: {
9
+ [key: string]: any;
10
+ };
11
+ context?: BuilderRenderContext;
12
+ apiKey: string;
13
+ apiVersion?: ApiVersion;
14
+ customComponents?: RegisteredComponent[];
15
+ canTrack?: boolean;
16
+ locale?: string;
17
+ /** @deprecated use `enrich` instead **/
18
+ includeRefs?: boolean;
19
+ enrich?: boolean;
20
+ /**
21
+ * TO-DO: improve qwik generator to not remap this name for non-HTML tags, then name it `className`
22
+ */
23
+ classNameProp?: string;
24
+ hideContent?: boolean;
25
+ parentContentId?: string;
26
+ isSsrAbTest?: boolean;
27
+ }
28
+ export interface BuilderComponentStateChange {
29
+ state: BuilderRenderState;
30
+ ref: {
31
+ name?: string;
32
+ props?: {
33
+ builderBlock?: {
34
+ id?: string;
35
+ };
36
+ };
37
+ };
38
+ }
@@ -0,0 +1 @@
1
+ export { default } from './content';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Apply target-specific transformations to the component reference.
3
+ *
4
+ * See overrides/* for examples.
5
+ */
6
+ export declare const wrapComponentRef: (component: any) => any;
@@ -0,0 +1,3 @@
1
+ import { ContentProps } from "../content/content.types";
2
+ export declare const RenderContentVariants: import("@builder.io/qwik").Component<ContentProps>;
3
+ export default RenderContentVariants;
@@ -0,0 +1,17 @@
1
+ import type { Nullable } from '../../helpers/nullable';
2
+ import type { BuilderContent } from '../../types/builder-content';
3
+ export declare const getVariants: (content: Nullable<BuilderContent>) => import("../../types/builder-content").BuilderContentVariation[];
4
+ export declare const checkShouldRunVariants: ({ canTrack, content, }: {
5
+ canTrack: Nullable<boolean>;
6
+ content: Nullable<BuilderContent>;
7
+ }) => boolean;
8
+ type VariantData = {
9
+ id: string;
10
+ testRatio?: number;
11
+ };
12
+ export declare const getVariantsScriptString: (variants: VariantData[], contentId: string) => string;
13
+ export declare const getRenderContentScriptString: ({ parentContentId, contentId, }: {
14
+ contentId: string;
15
+ parentContentId: string;
16
+ }) => string;
17
+ export {};
@@ -0,0 +1,6 @@
1
+ interface Props {
2
+ scriptStr: string;
3
+ id?: string;
4
+ }
5
+ export declare const InlinedScript: import("@builder.io/qwik").Component<Props>;
6
+ export default InlinedScript;
@@ -0,0 +1,6 @@
1
+ interface Props {
2
+ styles: string;
3
+ id?: string;
4
+ }
5
+ export declare const InlinedStyles: import("@builder.io/qwik").Component<Props>;
6
+ export default InlinedStyles;
@@ -1,30 +1,15 @@
1
- import type { BuilderRenderContext, RegisteredComponent, BuilderRenderState } from '../../context/types';
2
- import type { BuilderContent } from '../../types/builder-content';
3
- import type { Nullable } from '../../types/typescript';
4
- import type { ApiVersion } from '../../types/api-version';
5
- export interface RenderContentProps {
6
- content?: Nullable<BuilderContent>;
7
- model?: string;
8
- data?: {
9
- [key: string]: any;
10
- };
11
- context?: BuilderRenderContext;
12
- apiKey: string;
13
- apiVersion?: ApiVersion;
14
- customComponents?: RegisteredComponent[];
15
- canTrack?: boolean;
16
- locale?: string;
17
- /** @deprecated use `enrich` instead **/
18
- includeRefs?: boolean;
19
- enrich?: boolean;
1
+ import type { BuilderRenderState } from '../../context/types';
2
+ import type { EnforcePartials } from '../../types/enforced-partials';
3
+ import type { RenderContentVariantsProps } from '../render-content-variants/render-content-variants.types';
4
+ interface InternalRenderProps {
20
5
  /**
21
6
  * TO-DO: improve qwik generator to not remap this name for non-HTML tags, then name it `className`
22
7
  */
23
- classNameProp?: string;
24
- hideContent?: boolean;
25
- parentContentId?: string;
26
- isSsrAbTest?: boolean;
8
+ classNameProp: string | undefined;
9
+ showContent: boolean;
10
+ isSsrAbTest: boolean;
27
11
  }
12
+ export type RenderContentProps = InternalRenderProps & EnforcePartials<RenderContentVariantsProps>;
28
13
  export interface BuilderComponentStateChange {
29
14
  state: BuilderRenderState;
30
15
  ref: {
@@ -36,3 +21,4 @@ export interface BuilderComponentStateChange {
36
21
  };
37
22
  };
38
23
  }
24
+ export {};
@@ -1,6 +1,29 @@
1
1
  import type { Nullable } from '../../helpers/nullable';
2
2
  import type { BuilderContent } from '../../types/builder-content';
3
- export declare const getVariants: (content: Nullable<BuilderContent>) => import("../../types/builder-content").BuilderContentVariation[];
3
+ export declare const getVariants: (content: Nullable<BuilderContent>) => {
4
+ testVariationId: string | undefined;
5
+ id: string | undefined;
6
+ data?: {
7
+ [key: string]: any;
8
+ title?: string | undefined;
9
+ blocks?: import("../../types/builder-block").BuilderBlock[] | undefined;
10
+ inputs?: import("../../types/input").Input[] | undefined;
11
+ state?: {
12
+ [key: string]: any;
13
+ } | undefined;
14
+ jsCode?: string | undefined;
15
+ tsCode?: string | undefined;
16
+ httpRequests?: {
17
+ [key: string]: string;
18
+ } | undefined;
19
+ } | undefined;
20
+ name?: string | undefined;
21
+ testRatio?: number | undefined;
22
+ meta?: {
23
+ [key: string]: any;
24
+ breakpoints?: import("../../types/typescript").Nullable<import("../../types/builder-content").Breakpoints>;
25
+ } | undefined;
26
+ }[];
4
27
  export declare const checkShouldRunVariants: ({ canTrack, content, }: {
5
28
  canTrack: Nullable<boolean>;
6
29
  content: Nullable<BuilderContent>;
@@ -9,9 +32,10 @@ type VariantData = {
9
32
  id: string;
10
33
  testRatio?: number;
11
34
  };
35
+ export declare const getScriptString: () => string;
12
36
  export declare const getVariantsScriptString: (variants: VariantData[], contentId: string) => string;
13
- export declare const getRenderContentScriptString: ({ parentContentId, contentId, }: {
37
+ export declare const getRenderContentScriptString: ({ contentId, variationId, }: {
38
+ variationId: string;
14
39
  contentId: string;
15
- parentContentId: string;
16
40
  }) => string;
17
41
  export {};
@@ -1,3 +1,9 @@
1
- import { RenderContentProps } from "../render-content/render-content.types";
2
- export declare const RenderContentVariants: import("@builder.io/qwik").Component<RenderContentProps>;
1
+ import { RenderContentVariantsProps } from "./render-content-variants.types";
2
+ type VariantsProviderProps = RenderContentVariantsProps & {
3
+ /**
4
+ * For internal use only. Do not provide this prop.
5
+ */
6
+ __isNestedRender?: boolean;
7
+ };
8
+ export declare const RenderContentVariants: import("@builder.io/qwik").Component<VariantsProviderProps>;
3
9
  export default RenderContentVariants;
@@ -0,0 +1,20 @@
1
+ import type { BuilderRenderContext, RegisteredComponent } from '../../context/types';
2
+ import type { ApiVersion } from '../../types/api-version';
3
+ import type { BuilderContent } from '../../types/builder-content';
4
+ import type { Nullable } from '../../types/typescript';
5
+ export interface RenderContentVariantsProps {
6
+ content?: Nullable<BuilderContent>;
7
+ model?: string;
8
+ data?: {
9
+ [key: string]: any;
10
+ };
11
+ context?: BuilderRenderContext;
12
+ apiKey: string;
13
+ apiVersion?: ApiVersion;
14
+ customComponents?: RegisteredComponent[];
15
+ canTrack?: boolean;
16
+ locale?: string;
17
+ /** @deprecated use `enrich` instead **/
18
+ includeRefs?: boolean;
19
+ enrich?: boolean;
20
+ }
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.4.3";
1
+ export declare const SDK_VERSION = "0.4.5";
@@ -0,0 +1,10 @@
1
+ import type { BuilderContextInterface, RegisteredComponent } from '../context/types';
2
+ import type { BuilderBlock } from './builder-block';
3
+ import type { Dictionary } from './typescript';
4
+ export type PropsWithBuilderData<T> = T & {
5
+ builderBlock: BuilderBlock;
6
+ builderContext: BuilderContextInterface;
7
+ };
8
+ export type BuilderComponentsProp = {
9
+ builderComponents: Dictionary<RegisteredComponent>;
10
+ };
@@ -0,0 +1,21 @@
1
+ import type { Prettify } from './typescript';
2
+ type OptionalFieldsOnly<T> = {
3
+ [K in keyof T as T[K] extends Required<T>[K] ? never : K]: T[K];
4
+ };
5
+ type RequiredFieldsOnly<T> = {
6
+ [K in keyof T as T[K] extends Required<T>[K] ? K : never]: T[K];
7
+ };
8
+ type Enforced<T> = {
9
+ [K in keyof T]-?: T[K];
10
+ };
11
+ type AndUndefined<T> = {
12
+ [K in keyof T]: T[K] | undefined;
13
+ };
14
+ /**
15
+ * Enforce that all optional fields are undefined
16
+ * @example
17
+ * type Foo = { a: string, b?: number }
18
+ * type Bar = EnforcePartials<Foo> // { a: string, b: number | undefined }
19
+ */
20
+ export type EnforcePartials<From> = Prettify<AndUndefined<Enforced<OptionalFieldsOnly<From>>> & RequiredFieldsOnly<From>>;
21
+ export {};
@@ -3,3 +3,6 @@ export type Dictionary<T> = {
3
3
  [key: string]: T;
4
4
  };
5
5
  export type Overwrite<T, U> = keyof U extends keyof T ? Pick<T, Exclude<keyof T, keyof U>> & U : never;
6
+ export type Prettify<T> = {
7
+ [K in keyof T]: T[K];
8
+ } & {};