Skip to content

Commit

Permalink
KCL-11649 Install delivery-sdk and add proper types [WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladislav Bulyukhin committed Jan 17, 2024
1 parent dfbea27 commit a92bd3b
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 25 deletions.
173 changes: 153 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,8 @@
"webpack-bundle-analyzer": "4.5.0",
"webpack-cli": "4.10.0",
"webpack-merge": "5.8.0"
},
"dependencies": {
"@kontent-ai/delivery-sdk": "^14.6.0"
}
}
48 changes: 48 additions & 0 deletions src/lib/DeliverElementData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Elements } from '@kontent-ai/delivery-sdk';
import { ElementType as DeliverElementType } from '@kontent-ai/delivery-sdk/dist/cjs/elements/element-type';

type DeliverElementDataTemplate<TElement, TType extends DeliverElementType> = {
readonly type: TType;
readonly data: Omit<TElement, 'type' | 'name'>;
};

export type DeliverAssetElementData = DeliverElementDataTemplate<Elements.AssetsElement, DeliverElementType.Asset>;
export type DeliverCustomElementData = DeliverElementDataTemplate<
Elements.CustomElement<any>,
DeliverElementType.Custom
>;
export type DeliverDatetimeElementData = DeliverElementDataTemplate<
Elements.DateTimeElement,
DeliverElementType.DateTime
>;
export type DeliverLinkedItemsElementData = DeliverElementDataTemplate<
Elements.LinkedItemsElement,
DeliverElementType.ModularContent
>;
export type DeliverMultipleChoiceElementData = DeliverElementDataTemplate<
Elements.MultipleChoiceElement,
DeliverElementType.MultipleChoice
>;
export type DeliverNumberElementData = DeliverElementDataTemplate<Elements.NumberElement, DeliverElementType.Number>;
export type DeliverRichTextElementData = DeliverElementDataTemplate<
Elements.RichTextElement,
DeliverElementType.RichText
>;
export type DeliverTaxonomyElementData = DeliverElementDataTemplate<
Elements.TaxonomyElement,
DeliverElementType.Taxonomy
>;
export type DeliverTextElementData = DeliverElementDataTemplate<Elements.TextElement, DeliverElementType.Text>;
export type DeliverUrlSlugElementData = DeliverElementDataTemplate<Elements.UrlSlugElement, DeliverElementType.UrlSlug>;

export type DeliverElementData =
| DeliverAssetElementData
| DeliverCustomElementData
| DeliverDatetimeElementData
| DeliverLinkedItemsElementData
| DeliverMultipleChoiceElementData
| DeliverNumberElementData
| DeliverRichTextElementData
| DeliverTaxonomyElementData
| DeliverTextElementData
| DeliverUrlSlugElementData;
Loading

0 comments on commit a92bd3b

Please sign in to comment.