Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MT-4469] Reorganize @prezly/slate-types repo to not use default exports #37

Merged
merged 1 commit into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/slate-types/src/nodes/AttachmentNode.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { UploadcareStoragePayload } from '../sdk';

import ElementNode, { isElementNode } from './ElementNode';
import { ElementNode, isElementNode } from './ElementNode';

export const ATTACHMENT_NODE_TYPE = 'attachment';

export default interface AttachmentNode extends ElementNode {
export interface AttachmentNode extends ElementNode {
type: typeof ATTACHMENT_NODE_TYPE;
description: string;
file: UploadcareStoragePayload;
Expand Down
4 changes: 2 additions & 2 deletions packages/slate-types/src/nodes/ContactNode.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PressContact } from '../sdk';

import ElementNode, { isElementNode } from './ElementNode';
import { ElementNode, isElementNode } from './ElementNode';

export const CONTACT_NODE_TYPE = 'contact';

export default interface ContactNode extends ElementNode {
export interface ContactNode extends ElementNode {
type: typeof CONTACT_NODE_TYPE;
contact: PressContact;
uuid: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/slate-types/src/nodes/CoverageNode.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Coverage } from '@prezly/sdk';

import ElementNode, { isElementNode } from './ElementNode';
import { ElementNode, isElementNode } from './ElementNode';

export const COVERAGE_NODE_TYPE = 'coverage';

export default interface CoverageNode extends ElementNode {
export interface CoverageNode extends ElementNode {
type: typeof COVERAGE_NODE_TYPE;
coverage: {
id: Coverage['id'];
Expand Down
4 changes: 2 additions & 2 deletions packages/slate-types/src/nodes/DividerNode.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ElementNode, { isElementNode } from './ElementNode';
import { ElementNode, isElementNode } from './ElementNode';

export const DIVIDER_NODE_TYPE = 'divider';

export default interface DividerNode extends ElementNode {
export interface DividerNode extends ElementNode {
type: typeof DIVIDER_NODE_TYPE;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/slate-types/src/nodes/DocumentNode.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ElementNode, { isElementNode } from './ElementNode';
import { ElementNode, isElementNode } from './ElementNode';

export const DOCUMENT_NODE_TYPE = 'document';

export default interface DocumentNode extends ElementNode {
export interface DocumentNode extends ElementNode {
type: typeof DOCUMENT_NODE_TYPE;
version: string;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/slate-types/src/nodes/ElementNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { BaseElement } from 'slate';

import { isObject } from '../lib';

export default interface ElementNode extends BaseElement {
export interface ElementNode extends BaseElement {
type: string;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/slate-types/src/nodes/EmbedNode.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { OEmbedInfo } from '@prezly/sdk';

import ElementNode, { isElementNode } from './ElementNode';
import { ElementNode, isElementNode } from './ElementNode';

export const EMBED_NODE_TYPE = 'embed';

export default interface EmbedNode extends ElementNode {
export interface EmbedNode extends ElementNode {
type: typeof EMBED_NODE_TYPE;
oembed: OEmbedInfo;
url: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/slate-types/src/nodes/GalleryNode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { UploadcareImageStoragePayload } from '../sdk';

import ElementNode, { isElementNode } from './ElementNode';
import { ElementNode, isElementNode } from './ElementNode';

export const GALLERY_NODE_TYPE = 'gallery';

Expand All @@ -24,7 +24,7 @@ export enum GalleryPadding {
S = 'S',
}

export default interface GalleryNode extends ElementNode {
export interface GalleryNode extends ElementNode {
type: typeof GALLERY_NODE_TYPE;
images: {
/** empty string if no caption */
Expand Down
4 changes: 2 additions & 2 deletions packages/slate-types/src/nodes/HeadingNode.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ElementNode, { isElementNode } from './ElementNode';
import { ElementNode, isElementNode } from './ElementNode';

export const HEADING_1_NODE_TYPE = 'heading-one';
export const HEADING_2_NODE_TYPE = 'heading-two';

export default interface HeadingNode extends ElementNode {
export interface HeadingNode extends ElementNode {
type: typeof HEADING_1_NODE_TYPE | typeof HEADING_2_NODE_TYPE;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/slate-types/src/nodes/ImageNode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { UploadcareImageStoragePayload } from '../sdk';

import ElementNode, { isElementNode } from './ElementNode';
import { ElementNode, isElementNode } from './ElementNode';

export const IMAGE_NODE_TYPE = 'image-block';

Expand All @@ -10,7 +10,7 @@ export enum ImageLayout {
FULL_WIDTH = 'full-width',
}

export default interface ImageNode extends ElementNode {
export interface ImageNode extends ElementNode {
type: typeof IMAGE_NODE_TYPE;
/** caption */
file: UploadcareImageStoragePayload;
Expand Down
6 changes: 3 additions & 3 deletions packages/slate-types/src/nodes/LinkNode.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ElementNode, { isElementNode } from './ElementNode';
import TextNode from './TextNode';
import { ElementNode, isElementNode } from './ElementNode';
import { TextNode } from './TextNode';

export const LINK_NODE_TYPE = 'link';

export default interface LinkNode extends ElementNode {
export interface LinkNode extends ElementNode {
type: typeof LINK_NODE_TYPE;
children: TextNode[];
href: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/slate-types/src/nodes/ListNode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ElementNode, { isElementNode } from './ElementNode';
import { ElementNode, isElementNode } from './ElementNode';

export const BULLETED_LIST_NODE_TYPE = 'bulleted-list';

Expand All @@ -8,7 +8,7 @@ export const LIST_ITEM_NODE_TYPE = 'list-item';

export const LIST_ITEM_TEXT_NODE_TYPE = 'list-item-text';

export default interface ListNode extends ElementNode {
export interface ListNode extends ElementNode {
type: typeof BULLETED_LIST_NODE_TYPE | typeof NUMBERED_LIST_NODE_TYPE;
children: ListItemNode[];
}
Expand Down
4 changes: 2 additions & 2 deletions packages/slate-types/src/nodes/MentionNode.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ElementNode, { isElementNode } from './ElementNode';
import { ElementNode, isElementNode } from './ElementNode';

export const MENTION_NODE_TYPE = 'mention';

export default interface MentionNode extends ElementNode {
export interface MentionNode extends ElementNode {
type: typeof MENTION_NODE_TYPE;
user: {
avatar_url: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/slate-types/src/nodes/ParagraphNode.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ElementNode, { isElementNode } from './ElementNode';
import { ElementNode, isElementNode } from './ElementNode';

export const PARAGRAPH_NODE_TYPE = 'paragraph';

export default interface ParagraphNode extends ElementNode {
export interface ParagraphNode extends ElementNode {
type: typeof PARAGRAPH_NODE_TYPE;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/slate-types/src/nodes/PlaceholderNode.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ElementNode, { isElementNode } from './ElementNode';
import { ElementNode, isElementNode } from './ElementNode';

export const PLACEHOLDER_NODE_TYPE = 'placeholder';

export default interface PlaceholderNode extends ElementNode {
export interface PlaceholderNode extends ElementNode {
type: typeof PLACEHOLDER_NODE_TYPE;
key: string;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/slate-types/src/nodes/QuoteNode.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ElementNode, { isElementNode } from './ElementNode';
import { ElementNode, isElementNode } from './ElementNode';

export const QUOTE_NODE_TYPE = 'block-quote';

export default interface QuoteNode extends ElementNode {
export interface QuoteNode extends ElementNode {
type: typeof QUOTE_NODE_TYPE;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/slate-types/src/nodes/TextNode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default interface TextNode {
export interface TextNode {
bold?: boolean;
italic?: boolean;
subscript?: boolean;
Expand Down
17 changes: 0 additions & 17 deletions packages/slate-types/src/nodes/index.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
export { default as AttachmentNode } from './AttachmentNode';
export * from './AttachmentNode';
export { default as ContactNode } from './ContactNode';
export * from './ContactNode';
export { default as CoverageNode } from './CoverageNode';
export * from './CoverageNode';
export { default as DividerNode } from './DividerNode';
export * from './DividerNode';
export { default as DocumentNode } from './DocumentNode';
export * from './DocumentNode';
export { default as ElementNode } from './ElementNode';
export * from './ElementNode';
export { default as EmbedNode } from './EmbedNode';
export * from './EmbedNode';
export { default as GalleryNode } from './GalleryNode';
export * from './GalleryNode';
export { default as HeadingNode } from './HeadingNode';
export * from './HeadingNode';
export { default as ImageNode } from './ImageNode';
export * from './ImageNode';
export { default as LinkNode } from './LinkNode';
export * from './LinkNode';
export { default as ListNode } from './ListNode';
export * from './ListNode';
export { default as MentionNode } from './MentionNode';
export * from './MentionNode';
export { default as ParagraphNode } from './ParagraphNode';
export * from './ParagraphNode';
export { default as PlaceholderNode } from './PlaceholderNode';
export * from './PlaceholderNode';
export { default as QuoteNode } from './QuoteNode';
export * from './QuoteNode';
export { default as TextNode } from './TextNode';
export * from './TextNode';
4 changes: 1 addition & 3 deletions packages/slate-types/src/sdk/EmailPlaceholderKey.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
type EmailPlaceholderKey =
export type EmailPlaceholderKey =
| 'contact.firstname'
| 'contact.lastname'
| 'contact.fullname'
// TODO: consider including 'contact.salutation' conditionally as it is a behind-a-flag feature
| 'contact.salutation'
| 'release.url'
| 'release.shorturl';

export default EmailPlaceholderKey;
8 changes: 3 additions & 5 deletions packages/slate-types/src/sdk/PlaceholderKey.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import EmailPlaceholderKey from './EmailPlaceholderKey';
import StoryPlaceholderKey from './StoryPlaceholderKey';
import { EmailPlaceholderKey } from './EmailPlaceholderKey';
import { StoryPlaceholderKey } from './StoryPlaceholderKey';

type PlaceholderKey = EmailPlaceholderKey | StoryPlaceholderKey;

export default PlaceholderKey;
export type PlaceholderKey = EmailPlaceholderKey | StoryPlaceholderKey;
2 changes: 1 addition & 1 deletion packages/slate-types/src/sdk/PressContact.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default interface PressContact {
export interface PressContact {
avatar_url: string | null;
company: string | null;
// TODO: cultures
Expand Down
4 changes: 1 addition & 3 deletions packages/slate-types/src/sdk/StoryPlaceholderKey.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
type StoryPlaceholderKey = 'publication.date';

export default StoryPlaceholderKey;
export type StoryPlaceholderKey = 'publication.date';
6 changes: 3 additions & 3 deletions packages/slate-types/src/sdk/UploadcareFile.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UPLOADCARE_CDN_URL } from '../constants';

import UploadcareFileInfo from './UploadcareFileInfo';
import UploadcareFileStoragePayload from './UploadcareFileStoragePayload';
import { UploadcareFileInfo } from './UploadcareFileInfo';
import { UploadcareFileStoragePayload } from './UploadcareFileStoragePayload';

interface UploadcareFileParameters {
filename: UploadcareFileStoragePayload['filename'];
Expand Down Expand Up @@ -37,7 +37,7 @@ const fromWidgetPayload = ({ uuid, name: filename, size, mimeType }: UploadcareF
uuid,
});

export default class UploadcareFile {
export class UploadcareFile {
static createFromPrezlyStoragePayload = (
payload: UploadcareFileStoragePayload,
): UploadcareFile => new UploadcareFile(fromStoragePayload(payload));
Expand Down
2 changes: 1 addition & 1 deletion packages/slate-types/src/sdk/UploadcareFileInfo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @see https://uploadcare.com/docs/api_reference/javascript/files_uploads/#file-info
*/
export default interface UploadcareFileInfo {
export interface UploadcareFileInfo {
uuid: string;
name: string;
size: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default interface UploadcareFileStoragePayload {
export interface UploadcareFileStoragePayload {
filename: string;
mime_type: string;
size: number;
Expand Down
6 changes: 2 additions & 4 deletions packages/slate-types/src/sdk/UploadcareGifVideo.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { UPLOADCARE_CDN_URL } from '../constants';

import UploadcareImage from './UploadcareImage';
import { UploadcareImage } from './UploadcareImage';

type Quality = 'lightest' | 'lighter' | 'normal' | 'better' | 'best';

type VideoFormat = 'mp4' | 'webm';

class UploadcareGifVideo {
export class UploadcareGifVideo {
public static createFromUploadcareImage(image: UploadcareImage): UploadcareGifVideo {
// The `gif2video` transformation is supported only for gifs,
// otherwise the server responds with "400 Bad Request".
Expand Down Expand Up @@ -94,5 +94,3 @@ class UploadcareGifVideo {
return `${cdnUrl}${encodeURIComponent(this.filename)}`;
}
}

export default UploadcareGifVideo;
12 changes: 5 additions & 7 deletions packages/slate-types/src/sdk/UploadcareImage.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { UPLOADCARE_CDN_URL, UPLOADCARE_FILE_DATA_KEY } from '../constants';

import UploadcareFile from './UploadcareFile';
import UploadcareFileInfo from './UploadcareFileInfo';
import UploadcareGifVideo from './UploadcareGifVideo';
import UploadcareImageStoragePayload from './UploadcareImageStoragePayload';
import { UploadcareFile } from './UploadcareFile';
import { UploadcareFileInfo } from './UploadcareFileInfo';
import { UploadcareGifVideo } from './UploadcareGifVideo';
import { UploadcareImageStoragePayload } from './UploadcareImageStoragePayload';

type ImageFormat = 'auto' | 'jpeg' | 'png' | 'web';

const MAX_PREVIEW_SIZE = 2000;

class UploadcareImage {
export class UploadcareImage {
public static createFromUploadcareWidgetPayload = (
fileInfo: UploadcareFileInfo,
): UploadcareImage => {
Expand Down Expand Up @@ -259,5 +259,3 @@ class UploadcareImage {
});
};
}

export default UploadcareImage;
4 changes: 2 additions & 2 deletions packages/slate-types/src/sdk/UploadcareImageStoragePayload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UploadcareFileStoragePayload from './UploadcareFileStoragePayload';
import { UploadcareFileStoragePayload } from './UploadcareFileStoragePayload';

export default interface UploadcareImageStoragePayload extends UploadcareFileStoragePayload {
export interface UploadcareImageStoragePayload extends UploadcareFileStoragePayload {
effects: string[];
original_height: number;
original_width: number;
Expand Down
8 changes: 3 additions & 5 deletions packages/slate-types/src/sdk/UploadcareStoragePayload.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { isObject } from '../lib';

import UploadcareFileStoragePayload from './UploadcareFileStoragePayload';
import UploadcareImageStoragePayload from './UploadcareImageStoragePayload';
import { UploadcareFileStoragePayload } from './UploadcareFileStoragePayload';
import { UploadcareImageStoragePayload } from './UploadcareImageStoragePayload';

type UploadcareStoragePayload = UploadcareFileStoragePayload | UploadcareImageStoragePayload;
export type UploadcareStoragePayload = UploadcareFileStoragePayload | UploadcareImageStoragePayload;

export const isPrezlyStoragePayload = (value: any): value is UploadcareFileStoragePayload => {
return (
Expand All @@ -14,5 +14,3 @@ export const isPrezlyStoragePayload = (value: any): value is UploadcareFileStora
typeof value.uuid === 'string'
);
};

export default UploadcareStoragePayload;
Loading