-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0d639d9
Showing
315 changed files
with
254,125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"extends": "next/core-web-vitals", | ||
"plugins": ["@typescript-eslint"], | ||
"rules": { | ||
"import/order": [ | ||
"warn", | ||
{ | ||
"newlines-between": "always", | ||
"alphabetize": {"order": "asc"}, | ||
"groups": [ | ||
"builtin", | ||
"external", | ||
"internal", | ||
["parent", "sibling"], | ||
"index", | ||
"type" | ||
] | ||
} | ||
], | ||
|
||
"no-unused-vars": "off", | ||
|
||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
"argsIgnorePattern": "^_", | ||
"varsIgnorePattern": "^_", | ||
"caughtErrorsIgnorePattern": "^_" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Alex MacCaw | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# openpm | ||
|
||
openpm is a package manager for OpenAPI files. | ||
|
||
For more information please see: https://openpm.ai/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# openpm | ||
|
||
openpm is a package manager for OpenAPI files. | ||
|
||
For more information please see: https://openpm.ai/ | ||
|
||
# Development | ||
|
||
``` | ||
yarn | ||
yarn dev | ||
``` | ||
|
||
# TODO | ||
|
||
[x] - Registration | ||
[x] - New package submission | ||
[x] - Search (ish) | ||
[x] - Auth | ||
[x] - Access | ||
[x] - API key creation (need to set user attrs) | ||
[x] - Performant search | ||
[x] - Format code examples | ||
[x] - Format schema | ||
[x] - Fix examples request response | ||
[x] - Auth section | ||
[x] - Examples (curl, node, ruby, python) | ||
[x] - Design | ||
[x] - search in header | ||
[x] - about page | ||
[x] - db download links | ||
[x] - Improve search results | ||
[x] - pagination | ||
[x] - package update | ||
[x] - disable button | ||
[x] - package sizes | ||
|
||
# Release | ||
|
||
[ ] - autogpt example | ||
[ ] - crawl for openapi files | ||
[ ] - submit own openapi file | ||
[ ] - tos / privacy | ||
[ ] - migrate domain / hanko auth | ||
|
||
|
||
# V2 | ||
|
||
[ ] - Generate typescript types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import Link from 'next/link' | ||
|
||
import {MainTemplate} from '@/components/main-template' | ||
|
||
export default async function AboutPage() { | ||
return ( | ||
<MainTemplate> | ||
<article className="prose prose-headings:text-xl prose-headings:font-medium"> | ||
<h1>About</h1> | ||
|
||
<div className="prose max-w-prose"> | ||
<p> | ||
AI is the next platform. It will fundamentally change how we live and work. | ||
</p> | ||
|
||
<p> | ||
A new platform needs a new app-store. We engineers currently have a slim | ||
chance of creating our own app-store before some large corporation does it. | ||
</p> | ||
|
||
<p>We must seize this chance.</p> | ||
|
||
<p> | ||
It is vitally important that we don't repeat the travesty that is | ||
Apple's App store. Fundamental layers of the internet are too important | ||
to be controlled by any single monopolistic tax-collecting company. | ||
</p> | ||
|
||
<p> | ||
APIs serve as the apps on the AI platform. We need a headless app-store so | ||
that AIs can discover and use APIs. A store that is built upon the open web | ||
and the OpenAPI specification. | ||
</p> | ||
|
||
<p> | ||
<Link prefetch={false} href="/" className="text-pink-500"> | ||
openpm.ai | ||
</Link>{' '} | ||
is that store. We are an open source package-manager for OpenAPI files. | ||
Everything we release is under the MIT license. We will never charge a | ||
transaction fee for our services. We will never wield editorial control. We | ||
will only take down packages that are scams or illegal under US law. At any | ||
point you can choose to{' '} | ||
<Link prefetch={false} href="/export"> | ||
export all of our packages | ||
</Link>{' '} | ||
and run them on your own server. | ||
</p> | ||
</div> | ||
</article> | ||
</MainTemplate> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import Link from 'next/link' | ||
import React from 'react' | ||
|
||
export function AccountSidebar() { | ||
return ( | ||
<aside className="sticky top-0 w-72 px-6 py-4"> | ||
<div className="space-y-1"> | ||
<h3 className="flex justify-between font-mono"> | ||
<Link className="text-pink-500 " href="/"> | ||
openpm.ai | ||
</Link> | ||
</h3> | ||
</div> | ||
|
||
<div className="space-y-8 pt-24"> | ||
<div className="space-y-3"> | ||
<h3 className="text-xs font-semibold text-zinc-900 dark:text-white">Account</h3> | ||
<ul role="list" className="border-l border-zinc-900/10 dark:border-white/5"> | ||
<li className="relative"> | ||
<MenuItem href="#auth">Emails</MenuItem> | ||
<MenuItem href="#auth">Passkeys</MenuItem> | ||
<MenuItem href="#packages">Packages</MenuItem> | ||
<MenuItem href="#api-keys">API Keys</MenuItem> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</aside> | ||
) | ||
} | ||
|
||
const MenuItem = ({children, href}: {children: React.ReactNode; href: string}) => ( | ||
<a | ||
className=" | ||
relative flex justify-between gap-2 py-1 pl-4 | ||
pr-3 text-sm text-zinc-600 transition | ||
before:absolute before:inset-0 before:inset-x-1 before:rounded-md before:bg-zinc-800/2.5 before:opacity-0 hover:text-zinc-900 hover:before:opacity-100 | ||
dark:text-zinc-400 before:dark:bg-white/2.5 dark:hover:text-white" | ||
href={href} | ||
> | ||
<span className="relative truncate">{children}</span> | ||
</a> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use client' | ||
|
||
import {useRouter} from 'next/navigation' | ||
|
||
import {RedactedApiKey} from '@/server/db/api-keys/types' | ||
|
||
export function ApiKeyItem({apiKey}: {apiKey: RedactedApiKey}) { | ||
const router = useRouter() | ||
|
||
const onRevoke = async () => { | ||
if (!confirm('Are you sure you want to revoke this API key?')) { | ||
return | ||
} | ||
|
||
const response = await fetch(`/api/api-keys/${apiKey.id}/revoke`, { | ||
method: 'POST', | ||
}) | ||
|
||
if (!response.ok) { | ||
const error = await response.json() | ||
alert(error.message ?? 'Unknown error') | ||
throw new Error(error.message ?? 'Unknown error') | ||
} | ||
|
||
router.refresh() | ||
} | ||
|
||
return ( | ||
<li className="grid max-w-sm grid-cols-2"> | ||
<span> | ||
<code className="font-mono text-sm">sk-...{apiKey.keyExcerpt}</code> | ||
</span> | ||
<span> | ||
<button | ||
type="button" | ||
onClick={onRevoke} | ||
className="text-xs font-medium text-red-500" | ||
> | ||
Revoke | ||
</button> | ||
</span> | ||
</li> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use server' | ||
|
||
import {getUnrevokedApiKeys} from '@/server/db/api-keys/getters' | ||
|
||
import {ApiKeyItem} from './api-key-item' | ||
import {NewApiKey} from './new-api-key' | ||
|
||
export async function ApiKeys({userId}: {userId: string}) { | ||
const apiKeys = await getUnrevokedApiKeys({userId}) | ||
|
||
return ( | ||
<section className="space-y-3" id="api-keys"> | ||
<h2 className="text-base font-medium">API Keys</h2> | ||
<ul> | ||
{apiKeys.map((apiKey) => ( | ||
<ApiKeyItem key={apiKey.id} apiKey={apiKey} /> | ||
))} | ||
</ul> | ||
|
||
<footer className="mt-5"> | ||
<NewApiKey /> | ||
</footer> | ||
</section> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
'use client' | ||
|
||
import {useRouter} from 'next/navigation' | ||
import React, {useState} from 'react' | ||
|
||
import {Modal} from '@/components/modal' | ||
|
||
import {CreateApiKeyResponse} from '../api/api-keys/types' | ||
|
||
export function NewApiKey() { | ||
const router = useRouter() | ||
const [apiKey, setApiKey] = useState<CreateApiKeyResponse | null>(null) | ||
|
||
const onCreateApiKey = async () => { | ||
const result = await fetch('/api/api-keys', { | ||
method: 'POST', | ||
}) | ||
|
||
if (!result.ok) { | ||
alert('Failed to create API key') | ||
throw new Error('Failed to create API key') | ||
} | ||
|
||
const newApiKey = await result.json() | ||
setApiKey(newApiKey) | ||
|
||
router.refresh() | ||
} | ||
|
||
return ( | ||
<section> | ||
<button type="button" onClick={onCreateApiKey} className="text-xs text-blue-500"> | ||
New API key... | ||
</button> | ||
|
||
{apiKey && <NewApiKeyModal apiKey={apiKey.key} onClose={() => setApiKey(null)} />} | ||
</section> | ||
) | ||
} | ||
|
||
function NewApiKeyModal({apiKey, onClose}: {apiKey: string; onClose: () => void}) { | ||
return ( | ||
<Modal title="New API Key" show={!!apiKey} onClose={onClose}> | ||
{apiKey && ( | ||
<div className="space-y-5"> | ||
<p> | ||
Here is your new API key. Be sure to copy it. This will be the last time that | ||
it is shown. | ||
</p> | ||
|
||
<pre> | ||
<code className="font-mono">{apiKey}</code> | ||
</pre> | ||
|
||
<footer className="flex justify-end"> | ||
<button | ||
type="button" | ||
onClick={onClose} | ||
className="rounded-md bg-indigo-600 px-3 py-1 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600" | ||
> | ||
Close | ||
</button> | ||
</footer> | ||
</div> | ||
)} | ||
</Modal> | ||
) | ||
} |
Oops, something went wrong.