From b13ce87b7694d47d0ab3afaba2ca7fe9789a471a Mon Sep 17 00:00:00 2001 From: Andreas Richter <708186+richtera@users.noreply.github.com> Date: Mon, 5 Feb 2024 18:27:22 -0500 Subject: [PATCH] fix: Rename and cleanup api docs gen --- .gitignore | 2 - README.md | 22 +++--- etc/data-provider-base.api.md | 58 ++++++++++++++ etc/data-provider-ipfs-http-client.api.md | 26 +++++++ etc/data-provider-pinata.api.md | 77 +++++++++++++++++++ etc/data-provider-urlresolver.api.md | 28 +++++++ package.json | 2 +- .../etc/data-provider-base.api.md | 58 ++++++++++++++ packages/data-provider-base/package.json | 2 +- .../etc/data-provider-ipfs-http-client.api.md | 26 +++++++ .../package.json | 2 +- packages/data-provider-pinata/etc/.gitkeep | 0 .../etc/data-provider-pinata.api.md | 77 +++++++++++++++++++ packages/data-provider-pinata/package.json | 2 +- .../etc/data-provider-urlresolver.api.md | 28 +++++++ .../data-provider-urlresolver/package.json | 4 +- 16 files changed, 395 insertions(+), 19 deletions(-) create mode 100644 etc/data-provider-base.api.md create mode 100644 etc/data-provider-ipfs-http-client.api.md create mode 100644 etc/data-provider-pinata.api.md create mode 100644 etc/data-provider-urlresolver.api.md create mode 100644 packages/data-provider-base/etc/data-provider-base.api.md create mode 100644 packages/data-provider-ipfs-http-client/etc/data-provider-ipfs-http-client.api.md delete mode 100644 packages/data-provider-pinata/etc/.gitkeep create mode 100644 packages/data-provider-pinata/etc/data-provider-pinata.api.md create mode 100644 packages/data-provider-urlresolver/etc/data-provider-urlresolver.api.md diff --git a/.gitignore b/.gitignore index 8733413..6f21c68 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ .turbo node_modules /.env* -temp /docs dist -/packages/*/etc .DS_Store diff --git a/README.md b/README.md index 5e73bf3..856bc64 100644 --- a/README.md +++ b/README.md @@ -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"); @@ -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, }); @@ -74,7 +74,7 @@ const provider = new PinataProvider({ or ```mjs -const provider = new PinataProvider({ +const provider = new PinataUploader({ pinataJWTKey: import.meta.env.TEST_PINATAJWTKEY, }); ``` @@ -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}` @@ -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, }, @@ -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 { @@ -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(null); @@ -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: { diff --git a/etc/data-provider-base.api.md b/etc/data-provider-base.api.md new file mode 100644 index 0000000..6fdfb50 --- /dev/null +++ b/etc/data-provider-base.api.md @@ -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; + getToken(): Promise; + // @internal (undocumented) + resolveUrl(result: any): string; +} + +// @public +export class BaseFormDataUploader { + // (undocumented) + addMetadata(dataContent: FormData, meta?: FormDataPostHeaders): Promise; + getEndpoint(): string; + getPostEndpoint(): string; + getRequestOptions(dataContent: FormData, meta?: FormDataPostHeaders): Promise; + getToken(): Promise; + resolveUrl(result: any): string; + // @internal + upload(data: any, meta?: FormDataPostHeaders): Promise; + // @internal + uploadFormData(requestOptions: FormDataRequestOptions, dataContent: FormData): Promise; + // (undocumented) + protected wrapStream(data: any): Promise; +} + +// @public +export type FormDataPostHeaders = Record; + +// @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) + +``` diff --git a/etc/data-provider-ipfs-http-client.api.md b/etc/data-provider-ipfs-http-client.api.md new file mode 100644 index 0000000..bded6a1 --- /dev/null +++ b/etc/data-provider-ipfs-http-client.api.md @@ -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; + // (undocumented) + resolveUrl(result: any): string; +} +export { IPFSHttpClientUploader } +export default IPFSHttpClientUploader; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/etc/data-provider-pinata.api.md b/etc/data-provider-pinata.api.md new file mode 100644 index 0000000..555cfff --- /dev/null +++ b/etc/data-provider-pinata.api.md @@ -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; + // (undocumented) + getEndpoint(): string; + // (undocumented) + getRequestOptions(_dataContent: FormData, meta?: FormDataPostHeaders): Promise; + // (undocumented) + resolveUrl(result: any): string; +} +export { PinataUploader } +export default PinataUploader; + +// @public +export function validateMetadata(metadata: any): void; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/etc/data-provider-urlresolver.api.md b/etc/data-provider-urlresolver.api.md new file mode 100644 index 0000000..c6771a3 --- /dev/null +++ b/etc/data-provider-urlresolver.api.md @@ -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) + +``` diff --git a/package.json b/package.json index 9fc2f5c..83f0882 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/packages/data-provider-base/etc/data-provider-base.api.md b/packages/data-provider-base/etc/data-provider-base.api.md new file mode 100644 index 0000000..6fdfb50 --- /dev/null +++ b/packages/data-provider-base/etc/data-provider-base.api.md @@ -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; + getToken(): Promise; + // @internal (undocumented) + resolveUrl(result: any): string; +} + +// @public +export class BaseFormDataUploader { + // (undocumented) + addMetadata(dataContent: FormData, meta?: FormDataPostHeaders): Promise; + getEndpoint(): string; + getPostEndpoint(): string; + getRequestOptions(dataContent: FormData, meta?: FormDataPostHeaders): Promise; + getToken(): Promise; + resolveUrl(result: any): string; + // @internal + upload(data: any, meta?: FormDataPostHeaders): Promise; + // @internal + uploadFormData(requestOptions: FormDataRequestOptions, dataContent: FormData): Promise; + // (undocumented) + protected wrapStream(data: any): Promise; +} + +// @public +export type FormDataPostHeaders = Record; + +// @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) + +``` diff --git a/packages/data-provider-base/package.json b/packages/data-provider-base/package.json index a1575ff..27f2e09 100644 --- a/packages/data-provider-base/package.json +++ b/packages/data-provider-base/package.json @@ -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:*", diff --git a/packages/data-provider-ipfs-http-client/etc/data-provider-ipfs-http-client.api.md b/packages/data-provider-ipfs-http-client/etc/data-provider-ipfs-http-client.api.md new file mode 100644 index 0000000..bded6a1 --- /dev/null +++ b/packages/data-provider-ipfs-http-client/etc/data-provider-ipfs-http-client.api.md @@ -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; + // (undocumented) + resolveUrl(result: any): string; +} +export { IPFSHttpClientUploader } +export default IPFSHttpClientUploader; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/packages/data-provider-ipfs-http-client/package.json b/packages/data-provider-ipfs-http-client/package.json index 813f3a2..45447de 100644 --- a/packages/data-provider-ipfs-http-client/package.json +++ b/packages/data-provider-ipfs-http-client/package.json @@ -20,7 +20,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:*", diff --git a/packages/data-provider-pinata/etc/.gitkeep b/packages/data-provider-pinata/etc/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/packages/data-provider-pinata/etc/data-provider-pinata.api.md b/packages/data-provider-pinata/etc/data-provider-pinata.api.md new file mode 100644 index 0000000..555cfff --- /dev/null +++ b/packages/data-provider-pinata/etc/data-provider-pinata.api.md @@ -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; + // (undocumented) + getEndpoint(): string; + // (undocumented) + getRequestOptions(_dataContent: FormData, meta?: FormDataPostHeaders): Promise; + // (undocumented) + resolveUrl(result: any): string; +} +export { PinataUploader } +export default PinataUploader; + +// @public +export function validateMetadata(metadata: any): void; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/packages/data-provider-pinata/package.json b/packages/data-provider-pinata/package.json index cbf4de1..df63712 100644 --- a/packages/data-provider-pinata/package.json +++ b/packages/data-provider-pinata/package.json @@ -20,7 +20,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:*", diff --git a/packages/data-provider-urlresolver/etc/data-provider-urlresolver.api.md b/packages/data-provider-urlresolver/etc/data-provider-urlresolver.api.md new file mode 100644 index 0000000..c6771a3 --- /dev/null +++ b/packages/data-provider-urlresolver/etc/data-provider-urlresolver.api.md @@ -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) + +``` diff --git a/packages/data-provider-urlresolver/package.json b/packages/data-provider-urlresolver/package.json index 21babc4..01c5d41 100644 --- a/packages/data-provider-urlresolver/package.json +++ b/packages/data-provider-urlresolver/package.json @@ -19,8 +19,8 @@ "build": "tsup src/index.ts --format esm,cjs --sourcemap --dts-resolve --dts", "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" + "clean": "rm -rf .turbo node_modules dist etc", + "docs": "mkdir -p ./etc && api-extractor run --local --verbose" }, "devDependencies": { "@lukso/tsconfig": "workspace:*",