Skip to content

Commit

Permalink
feat: add client option for including all in query (#133)
Browse files Browse the repository at this point in the history
fix(docs): update broken code examples

fix(types): return correct requests for normalize and simplify methods

fix: update normalize and simplify methods to not crash
  • Loading branch information
ghostrider-05 authored Feb 6, 2025
1 parent 5397959 commit 1b19772
Show file tree
Hide file tree
Showing 36 changed files with 2,046 additions and 3,755 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ Typescript Oauth library for the [V2 Patreon API](https://docs.patreon.com/) wit
- Typescript types that strongly reflect your query for raw or normalized responses

```ts
const query = buildQuery.campaign([])({ campaign: ['title']})
const query = QueryBuilder.campaign
.setAttributes({ campaign: ['patron_count']})

const payload = await client.fetchCampaign(query)
// ^? { data: { attributes: { title: string } }, ... }
// ^? { data: { attributes: { patron_count: number } }, ... }
const campaign = await client.normalized.fetchCampaign(query)
// ^? { title: string, id: string, type: Type.Campaign }
// ^? { patron_count: number, id: string, type: Type.Campaign }
```

<!-- #endregion introduction -->
Expand Down
48 changes: 15 additions & 33 deletions docs/.vitepress/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { DefaultTheme, defineConfig } from 'vitepress'

import { useSidebar } from 'vitepress-openapi'
import { transformerTwoslash } from '@shikijs/vitepress-twoslash'

import * as shared from './shared'

import { fetchOpenAPISchema, openapiUrl } from '../theme/openapi'

import {
author,
bugs,
Expand Down Expand Up @@ -35,6 +33,20 @@ export default defineConfig({
cleanUrls: true,
lastUpdated: true,

markdown: {
codeTransformers: [
transformerTwoslash({
twoslashOptions: {
compilerOptions: {
paths: {
'patreon-api.ts': ['../']
}
}
}
}),
],
},

vite: {
ssr: {
noExternal: [ /\.css$/, /^vuetify/ ],
Expand Down Expand Up @@ -64,36 +76,6 @@ export default defineConfig({
sidebar: {
'/guide/': createSidebarItems(),
'/apps/': createSidebarItems(),
'/api/': [
{
text: 'Patreon API',
items: [
{
text: 'Overview',
link: '/api/',
},
...useSidebar({
spec: await fetchOpenAPISchema(),
linkPrefix: '/api/',
}).generateSidebarGroups(),
{
text: 'OpenAPI schema',
link: openapiUrl,
target: '_blank',
},
{
text: 'GitHub',
link: 'https://github.com/ghostrider-05/patreon-api-spec',
target: '_blank',
},
{
text: 'Report an issue',
link: 'https://github.com/ghostrider-05/patreon-api-spec/issues',
target: '_blank',
},
]
}
]
},

externalLinkIcon: true,
Expand Down
19 changes: 6 additions & 13 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { type Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme'

import { createVuetify } from 'vuetify'
import TwoslashFloatingVue from '@shikijs/vitepress-twoslash/client'
// @ts-expect-error style import
import '@shikijs/vitepress-twoslash/style.css'

import { theme, useOpenapi } from 'vitepress-openapi'
// @ts-expect-error Style import
import 'vitepress-openapi/dist/style.css'
import { createVuetify } from 'vuetify'

import { fetchOpenAPISchema } from './openapi'
import Layout from './Layout.vue'
// @ts-expect-error Style import
import './style.css'
Expand All @@ -23,15 +22,9 @@ export default {
Layout,
async enhanceApp(ctx) {
DefaultTheme.enhanceApp(ctx)
ctx.app.use(createVuetify())

const spec = await fetchOpenAPISchema()

// @ts-expect-error Unused variable
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const openapi = useOpenapi({ spec })

theme.enhanceApp({ app: ctx.app })
ctx.app.use(createVuetify())
ctx.app.use(TwoslashFloatingVue)

ctx.app.component('AutoComplete', AutoComplete)
ctx.app.component('Chip', Chip)
Expand Down
16 changes: 0 additions & 16 deletions docs/.vitepress/theme/openapi.ts

This file was deleted.

16 changes: 0 additions & 16 deletions docs/api/[operationId].md

This file was deleted.

30 changes: 0 additions & 30 deletions docs/api/[operationId].paths.js

This file was deleted.

12 changes: 0 additions & 12 deletions docs/api/index.md

This file was deleted.

Loading

0 comments on commit 1b19772

Please sign in to comment.