Skip to content

Commit

Permalink
fix: Rename and cleanup api docs gen
Browse files Browse the repository at this point in the history
  • Loading branch information
richtera committed Feb 5, 2024
1 parent 981a6f3 commit b13ce87
Show file tree
Hide file tree
Showing 16 changed files with 395 additions and 19 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.turbo
node_modules
/.env*
temp
/docs
dist
/packages/*/etc
.DS_Store
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ For a local IPFS node running as a .mjs file.

```mjs
import { createReadStream } from "fs";
import { IPFSHttpClientProvider } from "@lukso/data-provider-ipfs-http-client";
import { IPFSHttpClientUploader } from "@lukso/data-provider-ipfs-http-client";

const provider = new IPFSHttpClientProvider("http://127.0.0.1:5001/api/v0/add");
const provider = new IPFSHttpClientUploader("http://127.0.0.1:5001/api/v0/add");

const file = createReadStream("./test-image.png");

Expand All @@ -59,13 +59,13 @@ There are various ways to supply the file content. When using a browser File or
## Local IPFS

```mjs
const provider = new IPFSHttpClientProvider("http://127.0.0.1:5001/api/v0/add");
const provider = new IPFSHttpClientUploader("http://127.0.0.1:5001/api/v0/add");
```

### Pinata

```mjs
const provider = new PinataProvider({
const provider = new PinataUploader({
pinataApiKey: import.meta.env.TEST_PINATAAPIKEY,
pinataSecretApiKey: import.meta.env.TEST_PINATASECRETAPIKEY,
});
Expand All @@ -74,7 +74,7 @@ const provider = new PinataProvider({
or

```mjs
const provider = new PinataProvider({
const provider = new PinataUploader({
pinataJWTKey: import.meta.env.TEST_PINATAJWTKEY,
});
```
Expand All @@ -85,7 +85,7 @@ const provider = new PinataProvider({
// import.meta.env.VAR is the new way of importing environment within vite and astro and
// equivalent to the old process.env.VAR
//
const provider = new IPFSHttpClientProvider(import.meta.env.INFURA_GATEWAY, {
const provider = new IPFSHttpClientUploader(import.meta.env.INFURA_GATEWAY, {
headers: {
authorization: `Basic ${Buffer.from(
`${import.meta.env.INFURA_API_KEY_NAME}:${import.meta.env.INFURA_API_KEY}`
Expand All @@ -101,7 +101,7 @@ Some providers like pinata can supply additional fields with other custom inform
for standard pinning which is the main use case of this library.

```mjs
const provider = new IPFSHttpClientProvider(POST_URL, {
const provider = new IPFSHttpClientUploader(POST_URL, {
headers: {
...HEADERS,
},
Expand All @@ -114,7 +114,7 @@ const provider = new IPFSHttpClientProvider(POST_URL, {
```tsx
import React, { useCallback, useMemo, useRef, useState } from "react";
import { IPFSHttpClientProvider } from "@lukso/data-provider-ipfs-http-client";
import { IPFSHttpClientUploader } from "@lukso/data-provider-ipfs-http-client";
import { urlResolver } from "./shared";

export interface Props {
Expand All @@ -124,7 +124,7 @@ export interface Props {

export default function UploadLocal({ gateway, options }: Props) {
const provider = useMemo(
() => new IPFSHttpClientProvider(gateway, options),
() => new IPFSHttpClientUploader(gateway, options),
[]
);
const fileInput = useRef<HTMLInputElement>(null);
Expand Down Expand Up @@ -188,13 +188,13 @@ This would connect to this kind of endpoint

```ts
import type { APIContext } from "astro";
import { IPFSHttpClientProvider } from "@lukso/data-provider-ipfs-http-client";
import { IPFSHttpClientUploader } from "@lukso/data-provider-ipfs-http-client";

export async function POST({ request }: APIContext) {
const formData = await request.formData();
const file = formData.get("file");

const provider = new IPFSHttpClientProvider(
const provider = new IPFSHttpClientUploader(
import.meta.env.TEST_INFURA_GATEWAY,
{
headers: {
Expand Down
58 changes: 58 additions & 0 deletions etc/data-provider-base.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
## API Report File for "@lukso/data-provider-base"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts

// @public
export interface AssetBuffer {
buffer: Buffer;
mimeType: string;
}

// @public
export class AuthenticatedFormDataUploader extends BaseFormDataUploader {
// (undocumented)
getRequestOptions(dataContent: FormData, meta?: FormDataPostHeaders): Promise<FormDataRequestOptions>;
getToken(): Promise<string>;
// @internal (undocumented)
resolveUrl(result: any): string;
}

// @public
export class BaseFormDataUploader {
// (undocumented)
addMetadata(dataContent: FormData, meta?: FormDataPostHeaders): Promise<void>;
getEndpoint(): string;
getPostEndpoint(): string;
getRequestOptions(dataContent: FormData, meta?: FormDataPostHeaders): Promise<FormDataRequestOptions>;
getToken(): Promise<string>;
resolveUrl(result: any): string;
// @internal
upload(data: any, meta?: FormDataPostHeaders): Promise<string>;
// @internal
uploadFormData(requestOptions: FormDataRequestOptions, dataContent: FormData): Promise<any>;
// (undocumented)
protected wrapStream(data: any): Promise<any>;
}

// @public
export type FormDataPostHeaders = Record<string, string | number | any>;

// @public
export type FormDataRequestOptions = {
maxContentLength?: number;
maxBodyLength?: number;
withCredentials?: boolean;
headers?: FormDataPostHeaders;
[key: string]: any;
};

// Warning: (ae-internal-missing-underscore) The name "handleError" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
export const handleError: (error: any) => any;

// (No @packageDocumentation comment for this package)

```
26 changes: 26 additions & 0 deletions etc/data-provider-ipfs-http-client.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## API Report File for "@lukso/data-provider-ipfs-http-client"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts

import { BaseFormDataUploader } from '@lukso/data-provider-base';
import { FormDataPostHeaders } from '@lukso/data-provider-base';
import { FormDataRequestOptions } from '@lukso/data-provider-base';

// @public
class IPFSHttpClientUploader extends BaseFormDataUploader {
constructor(gateway: string, options?: FormDataRequestOptions | undefined);
// (undocumented)
getEndpoint(): string;
// (undocumented)
getRequestOptions(dataContent: FormData, meta?: FormDataPostHeaders): Promise<FormDataRequestOptions>;
// (undocumented)
resolveUrl(result: any): string;
}
export { IPFSHttpClientUploader }
export default IPFSHttpClientUploader;

// (No @packageDocumentation comment for this package)

```
77 changes: 77 additions & 0 deletions etc/data-provider-pinata.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
## API Report File for "@lukso/data-provider-pinata"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts

import { BaseFormDataUploader } from '@lukso/data-provider-base';
import { FormDataPostHeaders } from '@lukso/data-provider-base';
import { FormDataRequestOptions } from '@lukso/data-provider-base';
import { PinataConfig } from '@pinata/sdk';

// Warning: (ae-internal-missing-underscore) The name "createConfigForAxiosHeaders" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
export function createConfigForAxiosHeaders(config: PinataConfig): {
withCredentials: boolean;
headers: {
pinata_api_key: string;
pinata_secret_api_key: string;
Authorization?: undefined;
};
} | {
headers: {
Authorization: string;
pinata_api_key?: undefined;
pinata_secret_api_key?: undefined;
};
withCredentials?: undefined;
};

// Warning: (ae-internal-missing-underscore) The name "createConfigForAxiosHeadersWithFormData" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
export function createConfigForAxiosHeadersWithFormData(config: PinataConfig): {
maxContentLength: number;
maxBodyLength: number;
withCredentials: boolean;
headers: {
pinata_api_key: string;
pinata_secret_api_key: string;
Authorization?: undefined;
};
} | {
maxContentLength: number;
maxBodyLength: number;
headers: {
Authorization: string;
pinata_api_key?: undefined;
pinata_secret_api_key?: undefined;
};
withCredentials?: undefined;
};

// @public (undocumented)
export const ERROR_NO_CREDENTIALS_PROVIDED = "No credentials provided! Please provide your pinata api key and pinata secret api key or your pinata JWT key as an argument when you start this script";

// @public
class PinataUploader extends BaseFormDataUploader {
constructor(pinataConfig: PinataConfig);
// (undocumented)
addMetadata(dataContent: FormData, meta?: FormDataPostHeaders): Promise<void>;
// (undocumented)
getEndpoint(): string;
// (undocumented)
getRequestOptions(_dataContent: FormData, meta?: FormDataPostHeaders): Promise<FormDataRequestOptions>;
// (undocumented)
resolveUrl(result: any): string;
}
export { PinataUploader }
export default PinataUploader;

// @public
export function validateMetadata(metadata: any): void;

// (No @packageDocumentation comment for this package)

```
28 changes: 28 additions & 0 deletions etc/data-provider-urlresolver.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## API Report File for "@lukso/data-provider-urlresolver"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts

// @public
export class UrlConverter {
constructor(destination: string | URL, match?: RegExp | string);
// (undocumented)
protected destination: string;
// (undocumented)
protected match?: RegExp | string;
// (undocumented)
resolveUrl(match: RegExp | string, url: string): string;
}

// @public
class UrlResolver {
constructor(converters: Array<[string | RegExp, UrlConverter | string]>);
resolveUrl(url: string): string;
}
export { UrlResolver }
export default UrlResolver;

// (No @packageDocumentation comment for this package)

```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"test": "turbo test",
"version-packages": "turbo run build lint test",
"publish-packages": "turbo run build lint test && changeset version && changeset publish",
"documentation": "turbo run docs && mkdir -p temp && cp packages/*/temp/* temp/ && api-documenter markdown -i temp -o docs",
"documentation": "turbo run docs && mkdir -p etc && cp packages/*/etc/* etc/ && api-documenter markdown -i etc -o docs",
"demo": "turbo run demo"
},
"devDependencies": {
Expand Down
58 changes: 58 additions & 0 deletions packages/data-provider-base/etc/data-provider-base.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
## API Report File for "@lukso/data-provider-base"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts

// @public
export interface AssetBuffer {
buffer: Buffer;
mimeType: string;
}

// @public
export class AuthenticatedFormDataUploader extends BaseFormDataUploader {
// (undocumented)
getRequestOptions(dataContent: FormData, meta?: FormDataPostHeaders): Promise<FormDataRequestOptions>;
getToken(): Promise<string>;
// @internal (undocumented)
resolveUrl(result: any): string;
}

// @public
export class BaseFormDataUploader {
// (undocumented)
addMetadata(dataContent: FormData, meta?: FormDataPostHeaders): Promise<void>;
getEndpoint(): string;
getPostEndpoint(): string;
getRequestOptions(dataContent: FormData, meta?: FormDataPostHeaders): Promise<FormDataRequestOptions>;
getToken(): Promise<string>;
resolveUrl(result: any): string;
// @internal
upload(data: any, meta?: FormDataPostHeaders): Promise<string>;
// @internal
uploadFormData(requestOptions: FormDataRequestOptions, dataContent: FormData): Promise<any>;
// (undocumented)
protected wrapStream(data: any): Promise<any>;
}

// @public
export type FormDataPostHeaders = Record<string, string | number | any>;

// @public
export type FormDataRequestOptions = {
maxContentLength?: number;
maxBodyLength?: number;
withCredentials?: boolean;
headers?: FormDataPostHeaders;
[key: string]: any;
};

// Warning: (ae-internal-missing-underscore) The name "handleError" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
export const handleError: (error: any) => any;

// (No @packageDocumentation comment for this package)

```
2 changes: 1 addition & 1 deletion packages/data-provider-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dev": "tsup src/index.ts --format esm,cjs --watch --dts",
"lint": "eslint \"src/**/*.ts*\"",
"clean": "rm -rf .turbo node_modules dist temp etc",
"docs": "mkdir -p ./temp ./etc && api-extractor run --local --verbose"
"docs": "mkdir -p ./etc && api-extractor run --local --verbose"
},
"devDependencies": {
"@lukso/tsconfig": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## API Report File for "@lukso/data-provider-ipfs-http-client"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts

import { BaseFormDataUploader } from '@lukso/data-provider-base';
import { FormDataPostHeaders } from '@lukso/data-provider-base';
import { FormDataRequestOptions } from '@lukso/data-provider-base';

// @public
class IPFSHttpClientUploader extends BaseFormDataUploader {
constructor(gateway: string, options?: FormDataRequestOptions | undefined);
// (undocumented)
getEndpoint(): string;
// (undocumented)
getRequestOptions(dataContent: FormData, meta?: FormDataPostHeaders): Promise<FormDataRequestOptions>;
// (undocumented)
resolveUrl(result: any): string;
}
export { IPFSHttpClientUploader }
export default IPFSHttpClientUploader;

// (No @packageDocumentation comment for this package)

```
Loading

0 comments on commit b13ce87

Please sign in to comment.