Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sarthakjdev/wapi.js
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthakjdev committed May 16, 2024
2 parents 81abe6e + 25f7ca7 commit 5c1b50c
Show file tree
Hide file tree
Showing 16 changed files with 6,244 additions and 42 deletions.
5 changes: 2 additions & 3 deletions api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,18 @@
}
}
},

"apiReport": {
"enabled": false
},

"docModel": {
"enabled": true,
"apiJsonFilePath": "<projectFolder>/docs/docs.api.json"
},
"dtsRollup": {
"enabled": false,
"enabled": true,
"untrimmedFilePath": "<projectFolder>/dist/esm/index.d.ts"
},
"tsdocMetadata": {},
"newlineKind": "lf",
"messages": {
"compilerMessageReporting": {
Expand Down
9 changes: 6 additions & 3 deletions apps/wapijs.co/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/** @type {import('next').NextConfig} */
const nextConfig = {

};
reactStrictMode: true,
compiler: {
removeConsole: process.env.NODE_ENV === 'production'
}
}

export default nextConfig;
export default nextConfig
2 changes: 1 addition & 1 deletion apps/wapijs.co/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"dev": "NODE_ENV=development next dev",
"build": "NODE_ENV=production next build",
"start": "NODE_ENV=production next start",
"start": "NODE_ENV=production next start ",
"lint": "next lint",
"pretty": "pnpm prettier --write \"src/**/*.{ts,tsx,css}\""
},
Expand Down
3 changes: 3 additions & 0 deletions apps/wapijs.co/src/app/docs/[version]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { resolveItemUri } from '~/reusable-function'
import { notFound } from 'next/navigation'
import { addPackageToModel, fetchDocumentationJsonDataFromSlug } from '~/utils/api-extractor'

export const revalidate = 60 * 60 * 24 * 30
export const dynamicParams = true

export default async function VersionHomeLayout({
children,
params
Expand Down
3 changes: 3 additions & 0 deletions apps/wapijs.co/src/app/docs/[version]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { readFile } from 'node:fs/promises'
import getWasm from 'shiki/wasm'
import { fetchVersions } from '~/reusable-function'

export const revalidate = 60 * 60 * 24 * 30
export const dynamicParams = true

async function fetchReadMeFileFromGithub() {
if (IS_DEVELOPMENT) {
const fileContent = await readFile(join(process.cwd(), '..', '..', 'README.md'), 'utf8')
Expand Down
33 changes: 33 additions & 0 deletions apps/wapijs.co/src/app/global-error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use client'

import Link from 'next/link'
import { Button } from '@wapijs/ui'
import { ArrowPathIcon, ChatBubbleBottomCenterIcon } from '@heroicons/react/24/solid'

export default function GlobalError({
reset,
error
}: {
error: Error & { digest?: string }
reset: () => void
}) {
console.log({ error: error, stack: error.stack })
return (
<div className="flex h-[70vh] min-h-screen flex-col items-center justify-center gap-4">
<h2 className="mx-auto text-center text-xl text-gray-900">
Oops! Something went wrong{' '}
</h2>
<div className="flex gap-4">
<Button onClick={() => reset()} size={'medium'}>
<ArrowPathIcon className="h-6 w-6 text-white" /> Try again
</Button>
<Link title="contact-support" href={'/'} rel="">
<Button size={'medium'} variant={'outline'}>
<ChatBubbleBottomCenterIcon className="h-6 w-6 text-white" /> Contact
Support
</Button>
</Link>
</div>
</div>
)
}
8 changes: 6 additions & 2 deletions apps/wapijs.co/src/utils/api-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import { type ResolvedParameter } from '~/types'
import { TSDocConfiguration } from '@microsoft/tsdoc'
import { TSDocConfigFile } from '@microsoft/tsdoc-config'
import { readFile } from 'node:fs/promises'
import { join } from 'node:path'
import path, { join } from 'node:path'
import { readdirSync } from 'node:fs'

export async function fetchDocumentationJsonDataFromSlug(version: string) {
try {
Expand All @@ -43,7 +44,7 @@ export async function fetchDocumentationJsonDataFromSlug(version: string) {
return response
}
} catch (error) {
console.log(error)
console.error(error)
return null
}
}
Expand Down Expand Up @@ -188,6 +189,9 @@ export function parametersString(item: ApiDocumentedItem & ApiParameterListMixin
}

export function addPackageToModel(model: ApiModel, data: any) {
const nodeModulesPath = path.join(process.cwd(), 'node_modules')
const files = readdirSync(nodeModulesPath)
console.log('node_modules:', files)
const tsdocConfiguration = new TSDocConfiguration()
const tsdocConfigFile = TSDocConfigFile.loadFromObject(data.metadata.tsdocConfig)
tsdocConfigFile.configureParser(tsdocConfiguration)
Expand Down
1 change: 1 addition & 0 deletions apps/wapijs.co/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"**/*.tsx",
".next/types/**/*.ts",
"tailwind.config.js",
"prettier.config.js",
".eslintrc.js"
],
"exclude": ["node_modules"]
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@microsoft/api-extractor": "^7.43.1",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^10.0.3",
"@types/node": "^20.5.9",
Expand All @@ -64,5 +65,10 @@
"turbo": "^1.10.13",
"typescript": "5.4.5"
},
"packageManager": "pnpm@9.1.0"
"packageManager": "pnpm@9.1.0",
"pnpm": {
"patchedDependencies": {
"@microsoft/tsdoc-config@0.16.2": "patches/@microsoft__tsdoc-config@0.16.2.patch"
}
}
}
4 changes: 2 additions & 2 deletions packages/wapi.js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wapijs/wapi.js",
"version": "0.0.4",
"version": "0.0.5",
"description": "a typescript based client library to build whatsapp cloud api based chat bots",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand All @@ -21,7 +21,7 @@
"lint": "pnpm eslint . --max-warnings=20",
"pretty": "pnpm prettier --write \"src/**/*.ts\"",
"clean-install": "rm -rf ./node_modules && pnpm install --frozen-lockfile",
"doc:gen": "api-extractor run --local"
"doc:gen": "api-extractor run --local --diagnostics"
},
"keywords": [
"whatsapp",
Expand Down
3 changes: 1 addition & 2 deletions packages/wapi.js/src/manager/message/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import { type WapiMessageResponseSchemaType } from "../../client/schema";
*/
export class MessageManager
extends BaseManager
implements MessageManagerInterface
{
implements MessageManagerInterface {
client: Client;
constructor(props: { client: Client }) {
super(props.client);
Expand Down
Loading

0 comments on commit 5c1b50c

Please sign in to comment.