-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove todo and add basic test and example
- Loading branch information
Showing
13 changed files
with
91 additions
and
49 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 |
---|---|---|
@@ -1,9 +1,41 @@ | ||
#!/usr/bin/env tsx | ||
|
||
import landlubber from 'landlubber' | ||
import { env } from 'node:process' | ||
|
||
import * as todo from './todo.js' | ||
import landlubber, { | ||
type DefaultContext, | ||
defaultMiddleware, | ||
type EmptyOptions, | ||
type Handler as DefaultHandler, | ||
type MiddlewareFunction, | ||
} from 'landlubber' | ||
|
||
const commands = [todo] | ||
import { SeamHttp } from '@seamapi/http/connect' | ||
|
||
await landlubber(commands).parse() | ||
import * as workspace from './workspace.js' | ||
|
||
export type Handler<Options = EmptyOptions> = DefaultHandler<Options, Context> | ||
|
||
type Context = DefaultContext & ClientContext | ||
|
||
interface ClientContext { | ||
client: SeamHttp | ||
} | ||
|
||
const commands = [workspace] | ||
|
||
const createAppContext: MiddlewareFunction = async (argv) => { | ||
const apiKey = argv['api-key'] | ||
if (typeof apiKey !== 'string') throw new Error('Missing Seam API key') | ||
const client = SeamHttp.fromApiKey(apiKey) | ||
argv['client'] = client | ||
} | ||
|
||
const middleware = [...defaultMiddleware, createAppContext] | ||
|
||
await landlubber<Context>(commands, { middleware }) | ||
.describe('api-key', 'Seam API key') | ||
.string('api-key') | ||
.default('api-key', env['SEAM_API_KEY'], 'SEAM_API_KEY') | ||
.demandOption('api-key') | ||
.parse() |
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
import type { Builder, Command, Describe } from 'landlubber' | ||
|
||
import type { Handler } from './index.js' | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
interface Options {} | ||
|
||
export const command: Command = 'workspace' | ||
|
||
export const describe: Describe = 'Get workspace' | ||
|
||
export const builder: Builder = {} | ||
|
||
export const handler: Handler<Options> = async ({ client, logger }) => { | ||
const workspace = await client.workspaces.get() | ||
logger.info({ workspace }, 'workspace') | ||
} |
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
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
export { default } from 'lib/index.js' | ||
export * from 'lib/index.js' | ||
export default null |
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
import test from 'ava' | ||
|
||
import { SeamHttp } from './client.js' | ||
|
||
test('SeamHttp: fromApiKey', (t) => { | ||
t.truthy(SeamHttp.fromApiKey('some-api-key')) | ||
}) |
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 |
---|---|---|
@@ -1 +1,19 @@ | ||
export class SeamHttpClient {} | ||
export class SeamHttp { | ||
static fromApiKey(_apiKey: string): SeamHttp { | ||
return new SeamHttp() | ||
} | ||
|
||
static fromClientSessionToken(): SeamHttp { | ||
return new SeamHttp() | ||
} | ||
|
||
static async fromPublishableKey(): Promise<SeamHttp> { | ||
return new SeamHttp() | ||
} | ||
|
||
workspaces = { | ||
async get(): Promise<null> { | ||
return null | ||
}, | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
import test from 'ava' | ||
|
||
import { SeamHttp } from '@seamapi/http/connect' | ||
|
||
test('SeamHttp: fromApiKey', (t) => { | ||
t.truthy(SeamHttp.fromApiKey('some-api-key')) | ||
}) |
This file was deleted.
Oops, something went wrong.
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