Skip to content

Commit

Permalink
⬆️ (deps) [email protected] 🚨 format [skip ci] (#2666)
Browse files Browse the repository at this point in the history
- [x] upgrade to canary build
- [x] apply fixes
  • Loading branch information
JeromeFitz authored Jul 23, 2024
1 parent e32c80a commit 58972c7
Show file tree
Hide file tree
Showing 62 changed files with 497 additions and 345 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@jeromefitz/conventional-gitmoji": "4.0.4",
"@jeromefitz/eslint-config": "4.0.2",
"@jeromefitz/eslint-config": "5.0.0-canary.3",
"@jeromefitz/lint-staged": "2.0.4",
"@jeromefitz/prettier-config": "2.0.8",
"@jeromefitz/release-notes-generator": "3.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/design-system/src/components/Callout/Callout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { cx } from '../../utils/cx'
import { FileTextIcon } from '../Icon/index'

type AdditionalProps = {
interface AdditionalProps {
children?: ReactNode
className?: string
classNameText?: string
Expand Down
1 change: 1 addition & 0 deletions packages/next-notion/src/Notion.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ms from 'ms'
/**
* @redis is in seconds not ms
*/
// eslint-disable-next-line no-constant-binary-expression
const getTimeInSeconds = (time: number) => time / 1000 ?? 0

/**
Expand Down
10 changes: 5 additions & 5 deletions packages/next-notion/src/Notion.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type Spread<A extends readonly [...any]> = A extends [infer L, ...infer R]
*
*/
type Direction = 'ascending' | 'descending'
type SortItem = {
interface SortItem {
direction: Direction
property: string
}
Expand All @@ -64,7 +64,7 @@ type FilterType =
| 'equals'
| 'starts_with'

type BulletedListBlockObjectResponse = {
interface BulletedListBlockObjectResponse {
archived: boolean
bulleted_list: any
created_by: PartialUserObjectResponse
Expand All @@ -81,7 +81,7 @@ type BulletedListBlockObjectResponse = {
| { type: 'workspace'; workspace: true }
type: 'bulleted_list'
}
type NumberedListBlockObjectResponse = {
interface NumberedListBlockObjectResponse {
archived: boolean
created_by: PartialUserObjectResponse
created_time: string
Expand Down Expand Up @@ -142,7 +142,7 @@ type SelectColor =
| 'purple'
| 'red'
| 'yellow'
type SelectPropertyResponse = {
interface SelectPropertyResponse {
color: SelectColor
id: StringRequest
name: StringRequest
Expand Down Expand Up @@ -741,7 +741,7 @@ type TimeZoneRequest =
| 'W-SU'
| 'WET'
| 'Zulu'
type DateResponse = {
interface DateResponse {
end: null | string
start: string
time_zone: TimeZoneRequest | null
Expand Down
1 change: 1 addition & 0 deletions packages/next-notion/src/blocks/Emoji.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ async function EmojiWrapper({ id, text }) {
// isDev && console.dir(`> lazy load emoji libraries`)

let emojiIndex = 0
// eslint-disable-next-line no-unsafe-optional-chaining
for (const match of text?.matchAll(regex)) {
const emoji = match[0]
// @note(emoji) double to take into account emoji codepoint length
Expand Down
1 change: 1 addition & 0 deletions packages/next-notion/src/blocks/Emoji.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function EmojiWrapper({ id, text }) {
// isDev && console.dir(`> lazy load emoji libraries`)

let emojiIndex = 0
// eslint-disable-next-line no-unsafe-optional-chaining
for (const match of text?.matchAll(regex)) {
const emoji = match[0]
// @note(emoji) double to take into account emoji codepoint length
Expand Down
4 changes: 2 additions & 2 deletions packages/next-notion/src/blocks/RichText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function RichTextArray({ id, items }) {
)
}

const Component = !!props.className ? 'span' : Fragment
const Component = props.className ? 'span' : Fragment
if (Component === Fragment) delete props.className

return (
Expand Down Expand Up @@ -97,7 +97,7 @@ function RichText({
const key = getBlockKey(block.id, block.type, order)
const data: {
color: ApiColor
rich_text: Array<RichTextItemResponse>
rich_text: RichTextItemResponse[]
} = block[block.type]

if (!data) return null
Expand Down
6 changes: 3 additions & 3 deletions packages/next-notion/src/queries/getDatabaseQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { notion } from '../helper'

const DATABASE_ID = envServer.NOTION__DATABASE__PAGES ?? ''

type GetDatabaseQueryTypes = {
interface GetDatabaseQueryTypes {
database_id?: string
filterType?: FilterType
segmentInfo: SegmentInfo
Expand Down Expand Up @@ -70,7 +70,7 @@ const getDatabaseQuery = async ({
const sorts = sortsData

const options = {
database_id: !!database_id ? database_id : DATABASE_ID,
database_id: database_id ? database_id : DATABASE_ID,
filter,
page_size: 100, // max
sorts,
Expand Down Expand Up @@ -172,7 +172,7 @@ const getDatabaseQueryByDateRange = async ({
const sorts = sortsData

const options = {
database_id: !!database_id ? database_id : DATABASE_ID,
database_id: database_id ? database_id : DATABASE_ID,
filter,
sorts,
}
Expand Down
36 changes: 18 additions & 18 deletions packages/next-notion/src/utils/getPropertyTypeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import type {
SelectPropertyResponse,
} from '../Notion.types'

type CheckboxData = {
interface CheckboxData {
checkbox: boolean
id: string
type: 'checkbox'
Expand All @@ -43,7 +43,7 @@ function getCheckboxData({ data, type }: { data: CheckboxData; type: string }) {
return dataReturn
}

type DateData = {
interface DateData {
date: DateResponse | null
id: string
type: 'date'
Expand All @@ -57,7 +57,7 @@ function getDateData({ data, type }: { data: DateData; type: string }) {
return dataReturn
}

type FilesData = {
interface FilesData {
id: string
type: 'url'
url: null | string
Expand Down Expand Up @@ -89,9 +89,9 @@ function getFormulaData({ data, type }: { data: any; type: string }) {
return dataReturn[dataReturn.type]
}

type MultiSelectData = {
interface MultiSelectData {
id: string
multi_select: Array<SelectPropertyResponse>
multi_select: SelectPropertyResponse[]
type: 'multi_select'
}
function getMultiSelectData({
Expand All @@ -107,7 +107,7 @@ function getMultiSelectData({
return dataReturn
}

type NumberData = {
interface NumberData {
id: string
number: null | number
type: 'number'
Expand All @@ -119,12 +119,12 @@ function getNumberData({ data, type }: { data: NumberData; type: string }) {
return dataReturn
}

type RelationData = {
interface RelationData {
has_more?: boolean
id: string
relation: Array<{
relation: {
id: string
}>
}[]
type: 'relation'
}
function getRelationData({ data, type }: { data: RelationData; type: string }) {
Expand All @@ -134,12 +134,12 @@ function getRelationData({ data, type }: { data: RelationData; type: string }) {
return dataReturn
}

type RichTextData = {
interface RichTextData {
has_more?: boolean
id: string
relation: Array<{
relation: {
id: string
}>
}[]
type: 'relation'
}
function getRichTextData({ data, type }: { data: RichTextData; type: string }) {
Expand All @@ -158,12 +158,12 @@ function getRichTextData({ data, type }: { data: RichTextData; type: string }) {
return dataReturn
}

type RollupData = {
interface RollupData {
id: string
object: 'property_item'
rollup:
| {
array: Array<EmptyObject>
array: EmptyObject[]
function: RollupFunction
type: 'array'
}
Expand Down Expand Up @@ -240,7 +240,7 @@ function getRollupData({ data, type }: { data: RollupData; type: string }) {
return dataReturn
}

type SelectData = {
interface SelectData {
id: string
select: SelectPropertyResponse | null
type: 'select'
Expand All @@ -252,9 +252,9 @@ function getSelectData({ data, type }: { data: SelectData; type: string }) {
return dataReturn
}

type TitleData = {
interface TitleData {
id: string
title: Array<RichTextItemResponse>
title: RichTextItemResponse[]
type: 'title'
}
function getTitleData({ data, type }: { data: TitleData; type: string }) {
Expand All @@ -265,7 +265,7 @@ function getTitleData({ data, type }: { data: TitleData; type: string }) {
return dataReturn
}

type UrlData = {
interface UrlData {
id: string
type: 'url'
url: null | string
Expand Down
3 changes: 2 additions & 1 deletion packages/next-notion/src/utils/getSegmentInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _first from 'lodash/first.js'
import _isInteger from 'lodash/isInteger.js'
import _last from 'lodash/last.js'

type SegmentInfo = {
interface SegmentInfo {
catchAll: string[]
hasMeta: boolean
isIndex: boolean
Expand All @@ -14,6 +14,7 @@ type SegmentInfo = {
function getSegmentInfo({ SEGMENT, ...props }) {
const segment = SEGMENT
const catchAll = [segment]
// eslint-disable-next-line no-unsafe-optional-chaining
!!props.params?.catchAll && catchAll.push(...props.params?.catchAll)

const first = _first(catchAll)
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/components/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Navigation({}) {
function Navigation() {
return (
<>
<></>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function EmbedTwitter({ block }) {
/**
* @todo(notion) TextAnnotations
*/
const caption = !!block[block.type]?.caption
const caption = block[block.type]?.caption
? block[block.type]?.caption[0]?.plain_text
: null

Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/components/Notion/Blocks/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async function getImageFromBlock({ block, url }) {

const cache: any = await redis.get(key)
const isCached = !!cache && !isObjectEmpty(cache)
let image = !!cache ? { ...cache } : {}
let image = cache ? { ...cache } : {}

/**
* @note(notion) AWS, Notion, and Cache
Expand Down Expand Up @@ -175,7 +175,7 @@ async function ImageImpl({
const imageUrl = getImageUrl(block)
if (!imageUrl) return null

const imageCaption = !!block[block.type]?.caption
const imageCaption = block[block.type]?.caption
? block[block.type]?.caption[0]?.plain_text
: null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function getImageAlt(comments) {
)
return !!c && c.length > 0
? c[0]?.rich_text[0]?.plain_text.slice(FIND_ALT.length)
: !!comment
: comment
? comment?.rich_text[0]?.plain_text
: ''
}
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/components/Notion/Blocks/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function VideoImpl({ block }: { block: VideoBlockObjectResponse | any }) {
/**
* @todo(notion) TextAnnotations
*/
const caption = !!block[block.type]?.caption
const caption = block[block.type]?.caption
? block[block.type]?.caption[0]?.plain_text
: null

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/hooks/useSWRInfinitePages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type PageKeyMaker<Page, Key extends any[]> = (
*/
) => Key

type UseSWRInfinitePagesConfig<Page extends object> = {
interface UseSWRInfinitePagesConfig<Page extends object> {
dataPath: keyof Page | string[]
limit?: number
} // & SWRInfiniteConfiguration<Page>
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ms from 'ms'
/**
* @redis is in seconds not ms
*/
// eslint-disable-next-line no-constant-binary-expression
const getTimeInSeconds = (time: number) => time / 1000 ?? 0

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/shared/src/notion/utils/getDataFromCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { getDatabaseQuery, getMetadata } from './index'

const notion = new Client({ auth: envServer.NOTION_API_KEY })

type GetDataFromCache = {
interface GetDataFromCache {
database_id: string
draft?: boolean
filterType: any //FilterType
Expand Down Expand Up @@ -84,7 +84,7 @@ const getDataFromCache = cache(
const page = data.results[0]

let blocks = {}
if (!!page) {
if (page) {
const blockChildrenParentData = getBlockChildrenDataParent(page?.id)
const [blockChildrenParent] = await Promise.all([blockChildrenParentData])
blocks = blockChildrenParent
Expand Down Expand Up @@ -114,7 +114,7 @@ const getDataFromCache = cache(
*/
let isExpired = false
const blockSeoImage = data?.page?.properties['SEO.Image']?.files[0]
const SEO_IMAGE_IS_AWS = !!blockSeoImage
const SEO_IMAGE_IS_AWS = blockSeoImage
? isAwsImage(blockSeoImage[blockSeoImage?.type]?.url)
: false
if (SEO_IMAGE_IS_AWS) {
Expand All @@ -131,7 +131,7 @@ const getDataFromCache = cache(
*/
if (
!!data?.page?.id &&
(isExpired || isObjectEmpty(!!data?.seo ? data?.seo : {}))
(isExpired || isObjectEmpty(data?.seo ? data?.seo : {}))
) {
// @todo(types)
const pageData: any = await notion?.pages?.retrieve({
Expand Down
Loading

0 comments on commit 58972c7

Please sign in to comment.