8000 canvas-api-client package by seanrcollings · Pull Request #165 · atomicjolt/atomic-libs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

canvas-api-client package #165

New issue 8000

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
509 changes: 487 additions & 22 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"packages/lti-client",
"packages/lti-server",
"packages/lti-components",
"packages/canvas-client"
"packages/canvas-client",
"packages/canvas-api-client"
],
"scripts": {
"prepare": "npm run storybook:cssprops",
Expand Down
7 changes: 7 additions & 0 deletions packages/canvas-api-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @atomicjolt/canvas-api-client

## 0.0.1

### Patch Changes

- Intial Release of auto-generated Canvas API SDK
32 changes: 32 additions & 0 deletions packages/canvas-api-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# @atomicjolt/canvas-api-client

A TypeScript client for the Canvas LMS API.

## Development

To regenerate the API client from the OpenAPI spec:

```bash
npm run generate
```

## Usage

```typescript
import * as CanvasClient from "@atomicjolt/canvas-api-client";

CanvasClient.configureClient({
baseUrl: "https://atomicjolt.instructure.com/api",
token: "TOKEN",
});

CanvasClient.getSubAccountsOfAccount({
path: {
account_id: "1",
},
})
.then((response) => {
console.log(response.data);
})
.catch(console.error);
```
5 changes: 5 additions & 0 deletions packages/canvas-api-client/docs/Index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sidebar_position: 1
---

# Introduction
8 changes: 8 additions & 0 deletions packages/canvas-api-client/openapi-ts.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from "@hey-api/openapi-ts";

export default defineConfig({
input:
"https://gitlab.com/lauraschauer/canvas-openapi-specification/-/raw/main/openapi-specs/openapi3.yaml",
output: "./src/generated",
plugins: ["@hey-api/client-fetch"],
});
24 changes: 24 additions & 0 deletions packages/canvas-api-client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@atomicjolt/canvas-api-client",
"version": "0.0.2",
"license": "MIT",
"type": "module",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
"files": [
"dist",
"src"
],
"scripts": {
"build": "tsc -p ./tsconfig.build.json",
"test": "vitest run",
"prepublishOnly": "npm run build",
"generate": "openapi-ts"
},
"devDependencies": {
"@hey-api/openapi-ts": "^0.66.3"
},
"dependencies": {
"@hey-api/client-fetch": "^0.10.0"
}
}
18 changes: 18 additions & 0 deletions packages/canvas-api-client/src/canvas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { client } from "./generated/client.gen";

interface CanvasClientConfig {
baseUrl: string;
token: string;
headers?: Record<string, string>;
timeout?: number;
}

export function configureClient(config: CanvasClientConfig) {
const { baseUrl, token, headers, timeout } = config;

client.setConfig({
baseUrl,
auth: token,
headers,
});
}
18 changes: 18 additions & 0 deletions packages/canvas-api-client/src/generated/client.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// This file is auto-generated by @hey-api/openapi-ts

import type { ClientOptions } from './types.gen';
import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';

/**
* The `createClientConfig()` function will be called on client initialization
* and the returned object will become the client's initial configuration.
*
* You may want to initialize your client this way instead of calling
* `setConfig()`. This is useful for example if you're using Next.js
* to ensure your client always has the correct values.
*/
export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;

export const client = createClient(createConfig<ClientOptions>({
baseUrl: 'https://gitlab.com'
}));
3 changes: 3 additions & 0 deletions packages/canvas-api-client/src/generated/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file is auto-generated by @hey-api/openapi-ts
export * from './types.gen';
export * from './sdk.gen';
16,219 changes: 16,219 additions & 0 deletions packages/canvas-api-client/src/generated/sdk.gen.ts

Large diffs are not rendered by default.

Loading
Loading
0