### Make a Payment using cURL Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/test-files/getting-started.md This example shows how to make a POST request to create a simple payment. It includes the necessary headers for authorization and content type, along with a JSON payload specifying payment details. ```bash curl -X POST https://api.example.com/v1/payments \ -H "Authorization: Bearer sk_test_your_api_key_here" \ -H "Content-Type: application/json" \ -d '{ "amount": 2000, "currency": "USD", "source": "tok_visa_4242", "description": "My first payment" }' ``` -------------------------------- ### Install Dependencies, Build, and Test Packages Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Essential commands for setting up your project, building all packages, and running tests and linting. Assumes yarn is used as the package manager. ```bash # Install dependencies yarn install # Build all packages yarn build:packages # Run tests and linting yarn test yarn lint ``` -------------------------------- ### Install Prerelease Versions of Docusaurus Plugins Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Examples of how users can install specific prerelease versions of a Docusaurus plugin using npm. This includes installing by tag (alpha, beta, dev, canary) or by a specific version number. ```bash # Install specific tag npm install @your-org/package@alpha npm install @your-org/package@beta npm install @your-org/package@dev npm install @your-org/package@canary # Install specific version npm install @your-org/package@1.0.0-alpha.0 ``` -------------------------------- ### Create Payment Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/test-files/getting-started.md This endpoint allows you to create a new payment. It requires amount, currency, source, and an optional description. ```APIDOC ## POST /v1/payments ### Description Creates a new payment transaction. You must provide the payment amount, currency, payment source, and an optional description. ### Method POST ### Endpoint /v1/payments ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **amount** (integer) - Required - The amount to charge in the smallest currency unit (e.g., cents for USD). - **currency** (string) - Required - The currency of the payment (e.g., "USD", "EUR"). - **source** (string) - Required - The payment source identifier (e.g., a token from a payment form). - **description** (string) - Optional - A description for the payment. ### Request Example ```json { "amount": 2000, "currency": "USD", "source": "tok_visa_4242", "description": "My first payment" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the payment. - **status** (string) - The current status of the payment (e.g., "succeeded", "pending", "failed"). - **amount** (integer) - The amount of the payment. - **currency** (string) - The currency of the payment. - **created** (string) - The ISO 8601 timestamp when the payment was created. #### Response Example ```json { "id": "py_1abc123", "status": "succeeded", "amount": 2000, "currency": "USD", "created": "2024-01-15T10:30:00Z" } ``` ``` -------------------------------- ### Authentication Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/test-files/getting-started.md All API requests require authentication. Include your API key in the 'Authorization' header as a Bearer token. ```APIDOC ## GET /v1/payments ### Description This endpoint is used to authenticate your API requests. Include your API key in the `Authorization` header. ### Method GET ### Endpoint /v1/payments ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash curl -H "Authorization: Bearer sk_test_your_api_key_here" \ https://api.example.com/v1/payments ``` ### Response #### Success Response (200) - **message** (string) - Authentication successful. #### Response Example ```json { "message": "Authenticated successfully" } ``` ``` -------------------------------- ### Error Handling Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/test-files/getting-started.md Details on the HTTP status codes and common error response formats returned by the API. ```APIDOC ## API Error Codes and Responses ### Description This section outlines the HTTP status codes used by the API and provides examples of common error responses. ### Method N/A (Applies to all requests) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Common HTTP Status Codes - **200** - OK: Everything worked as expected. - **400** - Bad Request: Invalid parameters were provided in the request. - **401** - Unauthorized: The API key is invalid or missing. - **402** - Payment Required: The payment could not be processed. - **404** - Not Found: The requested resource does not exist. - **500** - Internal Server Error: An error occurred on the server. #### Common Error Response Format ```json { "error": { "type": "string", "code": "string", "message": "string" } } ``` #### Example Error Response (Card Declined) ```json { "error": { "type": "card_error", "code": "card_declined", "message": "Your card was declined." } } ``` ``` -------------------------------- ### Local Publishing: Initial Setup and Pull Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Bash commands to ensure you are on the main branch and have the latest changes before proceeding with local publishing. This step is crucial for avoiding merge conflicts and ensuring you're working with the most up-to-date codebase. ```bash git checkout main git pull origin main ``` -------------------------------- ### Start Docusaurus Development Server Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/docs/intro.md Changes the directory to your Docusaurus project and starts the development server. The site will be served locally at http://localhost:3000/ and reloads automatically on changes. ```bash cd my-website yarn run start ``` -------------------------------- ### Example Docusaurus Plugin package.json Configuration Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Essential fields for a Docusaurus plugin's `package.json` file. Includes package name, version, description, entry points (`main`, `types`), files to include in the package, keywords, npm publish configuration, and peer dependencies. ```json { "name": "@your-org/package-name", "version": "1.0.0", "description": "Clear description", "main": "./lib/index.js", "types": "./lib/public/index.d.ts", "files": ["lib", "README.md", "CHANGELOG.md"], "keywords": ["docusaurus", "plugin", "..."], "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" }, "peerDependencies": { "@docusaurus/core": "^3.0.0" } } ``` -------------------------------- ### Set Up Docusaurus Plugins Monorepo with Yarn Source: https://github.com/signalwire/docusaurus-plugins/blob/main/README.md This bash script outlines the initial setup process for the Docusaurus Plugins monorepo. It includes cloning the repository, installing dependencies using Yarn, and building all packages within the monorepo. ```bash # Clone the repository git clone https://github.com/signalwire/docusaurus-plugins.git cd docusaurus-plugins # Install dependencies yarn install # Build all packages yarn build:packages ``` -------------------------------- ### Authenticate API Request using cURL Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/test-files/getting-started.md This snippet demonstrates how to authenticate API requests by including your API key in the `Authorization` header. It's a prerequisite for all subsequent API interactions. ```bash curl -H "Authorization: Bearer sk_test_your_api_key_here" \ https://api.example.com/v1/payments ``` -------------------------------- ### Start localized site using yarn Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/docs/tutorial-extras/translate-your-site.md This command starts the Docusaurus development server for a specific locale. It's useful for testing translations in development as Docusaurus typically only supports one locale at a time during development. ```bash yarn run start -- --locale fr ``` -------------------------------- ### Dockerfile for Docusaurus Site Containerization Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/docs/guides/deployment-guide.md A Dockerfile to create a container image for your Docusaurus site. It uses a Node.js Alpine image, copies project files, installs dependencies, builds the site, and exposes port 3000 for serving. ```dockerfile FROM node:18-alpine WORKDIR /app COPY . . RUN npm ci RUN npm run build EXPOSE 3000 CMD ["npm", "run", "serve"] ``` -------------------------------- ### Package Verification Commands Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Commands to verify a published package on NPM. After publishing, you can use 'npm info' to check package details and 'npm install' in a test project to ensure the package is correctly installed and functional. ```bash # Check package info npm info @your-org/docusaurus-plugin-llms-txt # Install in a test project npm install @your-org/docusaurus-plugin-llms-txt ``` -------------------------------- ### Install Project Dependencies (Yarn) Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/README.md Installs all necessary project dependencies using the Yarn package manager. Ensure Yarn is installed globally. ```bash yarn ``` -------------------------------- ### Deploy Docusaurus Site using npm command Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/docs/guides/deployment-guide.md This command automates the deployment process for Docusaurus sites, typically configured for platforms like GitHub Pages. Ensure your `docusaurus.config.js` is correctly set up. ```bash npm run deploy ``` -------------------------------- ### MDX Component with Simple Props Source: https://github.com/signalwire/docusaurus-plugins/blob/main/packages/docusaurus-plugin-llms-txt/docs/plugin/overview.md An example of an MDX component using simple props for API endpoints and code examples. This highlights the initial, less informative state of content before Docusaurus processing. ```mdx ``` -------------------------------- ### Install Docusaurus Theme with npm or yarn Source: https://github.com/signalwire/docusaurus-plugins/blob/main/packages/docusaurus-theme-llms-txt/README.md Instructions for installing the @signalwire/docusaurus-theme-llms-txt package using either npm or yarn package managers. ```bash npm install @signalwire/docusaurus-theme-llms-txt # or yarn add @signalwire/docusaurus-theme-llms-txt ``` -------------------------------- ### Configure Docusaurus for GitHub Pages Deployment Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/docs/guides/deployment-guide.md Configure your docusaurus.config.js file to specify the URL, base URL, organization name, and project name for deployment to GitHub Pages. This setup is essential for the `npm run deploy` command to function correctly. ```javascript module.exports = { url: 'https://yourusername.github.io', baseUrl: '/your-repo-name/', organizationName: 'yourusername', projectName: 'your-repo-name' }; ``` -------------------------------- ### Deploy Docusaurus Site using Vercel CLI Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/docs/guides/deployment-guide.md Deploy your Docusaurus site using the Vercel command-line interface. This command initiates Vercel's zero-configuration deployment process, detecting and building your site automatically. ```bash npx vercel ``` -------------------------------- ### Successful Payment Response JSON Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/test-files/getting-started.md This JSON object represents a successful payment response from the API. It includes details such as the payment ID, status, amount, currency, and creation timestamp. ```json { "id": "py_1abc123", "status": "succeeded", "amount": 2000, "currency": "USD", "created": "2024-01-15T10:30:00Z" } ``` -------------------------------- ### Create a Changeset for Versioning and Changelog Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Command to initiate the Changesets process, which guides you through selecting changed packages, change types (patch, minor, major), and adding a description for changelog generation. A changeset file is created in the `.changeset/` directory. ```bash yarn changeset ``` -------------------------------- ### Build and Test Packages for Manual Publishing Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md A command to run pre-release scripts, typically including building, testing, and linting, before proceeding with manual publishing. This ensures the packages are in a release-ready state. ```bash yarn prerelease ``` -------------------------------- ### Bash: Install LLMs Docusaurus Plugin Source: https://github.com/signalwire/docusaurus-plugins/blob/main/packages/docusaurus-plugin-llms-txt/README.md These bash commands show how to install the SignalWire Docusaurus LLMs plugin using either npm or yarn. This is the first step to integrating the plugin into your Docusaurus project. ```bash npm install @signalwire/docusaurus-plugin-llms-txt # or yarn add @signalwire/docusaurus-plugin-llms-txt ``` -------------------------------- ### Start Local Development Server (Yarn) Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/README.md Starts a local development server for the Docusaurus website. This command automatically reloads the browser on most file changes, facilitating live development. It's a crucial step for previewing changes during development. ```bash yarn start ``` -------------------------------- ### Version Packages and Publish with Changesets Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Commands to update package versions, generate changelogs using the created changeset, install updated dependencies, and finally publish the packages to npm. This is the recommended approach for automated versioning and changelog management. ```bash # Update package versions and generate changelogs yarn changeset:version # Install updated dependencies yarn install # Publish to npm yarn changeset:publish ``` -------------------------------- ### Plugin Configuration Example (JavaScript) Source: https://github.com/signalwire/docusaurus-plugins/blob/main/packages/docusaurus-theme-llms-txt/README.md Shows a sample configuration object for the Docusaurus plugin within `docusaurus.config.js`. This configuration affects theme behavior, such as the copy page button's label and AI actions. ```js { copyPageButton: { buttonLabel: 'Share Content', actions: { markdown: true, ai: { chatGPT: { prompt: 'Help me understand this:' }, claude: false // Disables Claude option } } } } ``` -------------------------------- ### HTTP Request Examples for Orders API Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/api-docs/orders/index.md Examples of common HTTP requests for interacting with the Orders API. These include fetching orders, retrieving a specific order by ID, creating a new order, updating an order's status, and cancelling an order. No specific client libraries are required, only standard HTTP clients. ```http GET https://api.example.com/v3/orders?status=pending&user_id=123 ``` ```http GET https://api.example.com/v3/orders/456 ``` ```http POST https://api.example.com/v3/orders { "user_id": "123", "items": [ { "product_id": "abc", "quantity": 2, "price": 10.00 } ], "shipping_address": {} } ``` ```http PATCH https://api.example.com/v3/orders/456/status { "status": "shipped" } ``` ```http DELETE https://api.example.com/v3/orders/456 ``` -------------------------------- ### GET /products Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/api-docs/products/index.md Retrieves a list of products from the catalog. Supports filtering and searching. ```APIDOC ## GET /products ### Description Retrieves a list of products from the catalog. Supports filtering and searching. ### Method GET ### Endpoint https://api.example.com/v3/products ### Parameters #### Query Parameters - `category` (string) - Optional - Filter by category. - `search` (string) - Optional - Search in name and description. - `in_stock` (boolean) - Optional - Filter by availability. - `price_min` (number) - Optional - Minimum price filter. - `price_max` (number) - Optional - Maximum price filter ### Response #### Success Response (200) - `products` (array) - List of product objects. #### Response Example { "products": [ { "id": "string", "name": "string", "description": "string", "category": "string", "price": 0.0, "currency": "string", "inventory": { "quantity": 0, "low_stock_threshold": 0, "track_inventory": true }, "images": [ { "url": "string", "alt": "string", "primary": true } ], "metadata": {}, "created_at": "string", "updated_at": "string" } ] } ``` -------------------------------- ### Run Pre-publish Checklist for Docusaurus Plugins Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Command to execute a pre-publish check, ensuring the package is ready for release. This typically involves cleaning build artifacts, rebuilding, linting, and type checking. ```bash yarn publish:check ``` -------------------------------- ### Create Subscription Billing (TypeScript) Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/test-files/advanced-guide.mdx Sets up a recurring subscription for a customer using provided configuration. Handles potential errors during subscription creation and returns the subscription object. Requires an 'api' object with a 'subscriptions' client. ```typescript interface SubscriptionConfig { customerId: string; priceId: string; interval: 'month' | 'year'; trialPeriodDays?: number; } const createSubscription = async (config: SubscriptionConfig) => { try { const subscription = await api.subscriptions.create({ customer: config.customerId, items: [{ price: config.priceId }], trial_period_days: config.trialPeriodDays, expand: ['latest_invoice.payment_intent'] }); return subscription; } catch (error) { console.error('Subscription creation failed:', error); throw error; } }; ``` -------------------------------- ### Snapshot Prerelease Commands Reference Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Commands for creating snapshot prereleases (canary, alpha, beta, dev) with timestamps. These are useful for testing pre-release versions before a stable release. They allow for iterative development and testing of new features. ```bash # Canary release (snapshot with timestamp) yarn canary # Alpha release (snapshot with timestamp) yarn alpha # Beta release (snapshot with timestamp) yarn beta # Dev release (snapshot with timestamp) yarn dev:release ``` -------------------------------- ### GET /products Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/api_versioned_docs/version-v1/products/index.md Retrieves a list of products from the catalog, with options to filter and search. ```APIDOC ## GET /products ### Description Retrieves a list of products from the catalog. Supports filtering by category, stock availability, and price range, as well as searching by name and description. ### Method GET ### Endpoint /v3/products ### Query Parameters - **category** (string) - Optional - Filter by product category. - **search** (string) - Optional - Search term for product name and description. - **in_stock** (boolean) - Optional - Filter for products that are currently in stock. - **price_min** (number) - Optional - Minimum price for filtering. - **price_max** (number) - Optional - Maximum price for filtering. ### Response #### Success Response (200) - **products** (array) - A list of product objects. #### Response Example ```json { "products": [ { "id": "string", "name": "string", "description": "string", "category": "string", "price": "number", "currency": "string", "inventory": { "quantity": "number", "low_stock_threshold": "number", "track_inventory": "boolean" }, "images": [ { "url": "string", "alt": "string", "primary": "boolean" } ], "metadata": {}, "created_at": "string", "updated_at": "string" } ] } ``` ``` -------------------------------- ### Full Prerelease Mode Commands Reference Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Commands for managing a full prerelease workflow, including entering and exiting prerelease mode, versioning packages within this mode, and publishing prerelease packages. This is for more controlled prerelease cycles. ```bash # Enter prerelease mode (specify tag: alpha, beta, rc, etc.) yarn prerelease:enter # Exit prerelease mode yarn prerelease:exit # Version packages in prerelease mode yarn prerelease:version # Publish prerelease packages yarn prerelease:publish ``` -------------------------------- ### Configure Docusaurus Theme and LLMS Plugin Source: https://github.com/signalwire/docusaurus-plugins/blob/main/packages/docusaurus-theme-llms-txt/README.md Example configuration for a Docusaurus project to enable the llms-txt theme and plugin. This includes setting up the theme and defining custom options for the copy page button, such as labels and AI integrations. ```javascript // docusaurus.config.js export default { // ... other config themes: ['@signalwire/docusaurus-theme-llms-txt'], plugins: [ [ '@signalwire/docusaurus-plugin-llms-txt', { copyPageButton: { buttonLabel: 'Copy Page', actions: { markdown: true, ai: { chatGPT: true, claude: true, }, }, }, }, ], ], }; ``` -------------------------------- ### Generate Beta Release Versions Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Command to create beta releases, intended for testing feature-complete versions before a stable release. These versions are tagged with 'beta' on npm and include a timestamp. ```bash yarn beta ``` -------------------------------- ### Check and Login to NPM Account Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Commands to verify your npm login status and log in if necessary. These commands use yarn for package management. ```bash # Check if you're logged in yarn npm:check # Login if needed yarn npm:login ``` -------------------------------- ### Get Products Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/api_versioned_docs/version-v2/products/index.md Retrieves a list of products from the catalog. Supports filtering by category, search terms, stock availability, and price range. ```APIDOC ## GET /products ### Description Retrieves a list of products from the catalog. Supports filtering by category, search terms, stock availability, and price range. ### Method GET ### Endpoint https://api.example.com/v3/products ### Parameters #### Query Parameters - **category** (string) - Optional - Filter by category - **search** (string) - Optional - Search in name and description - **in_stock** (boolean) - Optional - Filter by availability - **price_min** (number) - Optional - Minimum price filter - **price_max** (number) - Optional - Maximum price filter ### Response #### Success Response (200) - **products** (array) - An array of product objects. #### Response Example ```json { "products": [ { "id": "string", "name": "string", "description": "string", "category": "string", "price": 0.0, "currency": "string", "inventory": { "quantity": 0, "low_stock_threshold": 0, "track_inventory": true }, "images": [ { "url": "string", "alt": "string", "primary": true } ], "metadata": {}, "created_at": "string", "updated_at": "string" } ] } ``` ``` -------------------------------- ### Markdown Link Examples Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/docs/tutorial-basics/markdown-features.mdx Demonstrates how to create hyperlinks within Markdown documents. Supports both external URLs and relative paths to other Markdown files within the project. ```md Let's see how to [Create a page](/create-a-page). Let's see how to [Create a page](./create-a-page.md). ``` -------------------------------- ### Create NPM Organization Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Command to create a new organization on NPM. This is a prerequisite for publishing packages under an organization name. Ensure you have an NPM account with the necessary permissions. ```bash npm org create your-org-name ``` -------------------------------- ### CLI Commands for Docusaurus Plugin Source: https://context7.com/signalwire/docusaurus-plugins/llms.txt Provides examples of command-line interface (CLI) commands for interacting with the Docusaurus plugin. These commands cover building documentation, generating llms.txt, cleaning generated files, and setting log levels. ```bash # Build documentation and generate llms.txt automatically npm run build # Generate llms.txt manually without full build npx docusaurus llms-txt # Clean generated markdown files and llms.txt npx docusaurus llms-txt clean # With custom log level npx docusaurus llms-txt --logLevel 3 ``` -------------------------------- ### Continue Releasing Prereleases for Docusaurus Plugins Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Steps to continue releasing prereleases after entering prerelease mode. This involves creating new changesets, versioning packages (which increments the prerelease number), committing, and publishing again. ```bash # Add changesets as normal yarn changeset # Version packages (increments prerelease number) yarn prerelease:version # Commit and publish git add . git commit -m "Version alpha packages" yarn prerelease:publish ``` -------------------------------- ### Generate Alpha Release Versions Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Command to create alpha releases, suitable for early testing of new features. These versions are tagged with 'alpha' on npm and include a timestamp in their version string. ```bash yarn alpha ``` -------------------------------- ### Generate Canary Release Versions Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Command to create canary releases, which are typically used for quick testing or pre-release versions without formal Git commits. These versions are tagged with 'canary' on npm. ```bash yarn canary ``` -------------------------------- ### Products API - Get Products Endpoint Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/api_versioned_docs/version-v2/products/index.md This endpoint retrieves a list of products from the catalog. It supports filtering by category, search terms, stock availability, and price range. No specific programming language is associated as this is an HTTP request description. ```http GET /products Query parameters: - `category`: Filter by category - `search`: Search in name and description - `in_stock`: Filter by availability - `price_min`: Minimum price filter - `price_max`: Maximum price filter ``` -------------------------------- ### Configure Public Package Access Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md JSON configuration to set the access level of a package to 'public' when publishing under an NPM organization. This ensures that the package is visible and installable by anyone. ```json { "publishConfig": { "access": "public" } } ``` -------------------------------- ### Authorize, Capture, and Void Payments (JavaScript) Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/test-files/advanced-guide.mdx Demonstrates a multi-step payment process. First, authorize a payment, then capture a portion of it, or optionally void the authorization if it's no longer needed. Assumes a 'payments' API object is available. ```javascript // Step 1: Authorize the payment const authorization = await payments.authorize({ amount: 5000, currency: 'USD', source: paymentMethod.id, description: 'Pre-authorization for service' }); console.log('Authorization ID:', authorization.id); ``` ```javascript // Step 2: Capture the authorized amount const capture = await payments.capture(authorization.id, { amount: 3500, // Can be less than authorized amount description: 'Final charge for delivered service' }); console.log('Captured:', capture.amount, 'cents'); ``` ```javascript // Alternative: Void the authorization if not needed const voided = await payments.void(authorization.id); console.log('Authorization voided:', voided.status); ``` -------------------------------- ### Docusaurus Plugin Configuration Example Source: https://context7.com/signalwire/docusaurus-plugins/llms.txt Illustrates the structure of the Docusaurus plugin configuration, including options for different LLM providers like OpenAI and Claude, and theme settings. This configuration is typed with `PluginOptions` for schema validation. ```typescript import type { PluginOptions } from './types'; const config = { plugins: [ [ 'docusaurus-plugin-llms-txt', { openai: { apiKey: process.env.OPENAI_API_KEY, defaultModel: 'gpt-3.5-turbo', models: [ { model: 'gpt-4' }, { model: 'gpt-3.5-turbo' }, ], prompt: 'Help me understand this documentation:', }, claude: { prompt: 'Analyze this documentation and explain:' }, }, ], ], themes: ['@signalwire/docusaurus-theme-llms-txt'], }; export default config; ``` -------------------------------- ### Docusaurus Plugin Configuration with TypeScript Source: https://context7.com/signalwire/docusaurus-plugins/llms.txt Example TypeScript configuration for the Docusaurus LLM plugin, demonstrating runtime behavior, Markdown generation settings, content extraction rules, and manual section organization with attachments and optional links. ```typescript import type { Config } from '@docusaurus/types'; import type { PluginOptions } from '@signalwire/docusaurus-plugin-llms-txt/public'; const config: Config = { plugins: [ [ '@signalwire/docusaurus-plugin-llms-txt', { // Runtime behavior controls logLevel: 3, onRouteError: 'warn', onSectionError: 'warn', runOnPostBuild: true, // Markdown file generation options markdown: { enableFiles: true, relativePaths: true, includeBlog: true, includePages: true, includeDocs: true, includeVersionedDocs: true, includeGeneratedIndex: true, excludeRoutes: ['/admin/**', '/internal/**'], // CSS selectors for content extraction contentSelectors: [ '.theme-doc-markdown', 'main .container .col', 'article' ], // Custom selectors for specific routes routeRules: [ { route: '/api/**', contentSelectors: ['.api-content', 'article'] } ], // Markdown processing options remarkStringify: { bullet: '-', emphasis: '_', fences: true, }, remarkGfm: true, rehypeProcessTables: true, }, // llms.txt index file configuration llmsTxt: { enableLlmsFullTxt: true, includeBlog: true, includePages: true, includeDocs: true, includeVersionedDocs: false, excludeRoutes: ['/admin/**'], // Site metadata siteTitle: 'My Documentation', siteDescription: 'Comprehensive developer documentation', enableDescriptions: true, // Auto-section organization autoSectionDepth: 2, autoSectionPosition: 10, // Manual section organization sections: [ { id: 'getting-started', name: 'Getting Started', description: 'Quick start guides and tutorials', position: 1, routes: [{ route: '/docs/intro/**' }], }, { id: 'api-reference', name: 'API Reference', description: 'Complete API documentation', position: 2, routes: [ { route: '/docs/api/**' }, { route: '/api/advanced/**', contentSelectors: ['.api-advanced-content'] } ], attachments: [ { source: './specs/openapi.yaml', title: 'OpenAPI Specification', description: 'Complete API specification in OpenAPI 3.0 format', fileName: 'api-spec', includeInFullTxt: true, }, { source: './schemas/webhook-events.json', title: 'Webhook Event Schemas', description: 'JSON schemas for all webhook events', }, ], optionalLinks: [ { title: 'API Status Page', url: 'https://status.example.com', description: 'Real-time API status monitoring' } ], subsections: [ { id: 'api-authentication', name: 'Authentication', description: 'API authentication methods', position: 1, routes: [{ route: '/docs/api/auth/**' }], }, ], }, ], // Global attachments attachments: [ { source: './CHANGELOG.md', title: 'Changelog', description: 'Complete version history', }, ], // Global optional links optionalLinks: [ { title: 'Community Forum', url: 'https://forum.example.com', description: 'Ask questions and share knowledge' } ], }, // UI features (requires theme package) ui: { copyPageContent: { buttonLabel: 'Copy Page', display: { docs: true, excludeRoutes: ['/admin/**'], }, contentStrategy: 'prefer-markdown', actions: { viewMarkdown: true, ai: { chatGPT: { //... } } } } } } ] ] }; ``` -------------------------------- ### Serve Docusaurus Production Build Locally Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/docs/tutorial-basics/deploy-your-site.md Tests the production build of the Docusaurus site by serving the 'build' folder locally. This allows for verification before actual deployment. ```bash yarn run serve ``` -------------------------------- ### Common Error Response JSON Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/test-files/getting-started.md This JSON structure illustrates a common error response from the API, typically indicating issues with a card payment. It includes the error type, a specific error code, and a human-readable message. ```json { "error": { "type": "card_error", "code": "card_declined", "message": "Your card was declined." } } ``` -------------------------------- ### POST /products Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/api-docs/products/index.md Creates a new product in the catalog. ```APIDOC ## POST /products ### Description Creates a new product in the catalog. ### Method POST ### Endpoint https://api.example.com/v3/products ### Parameters #### Request Body - `name` (string) - Required - The name of the product. - `description` (string) - Required - The description of the product. - `category` (string) - Optional - The category of the product. - `price` (number) - Required - The price of the product. - `currency` (string) - Required - The currency of the price (e.g., USD, EUR). - `inventory` (object) - Optional - Inventory details. - `quantity` (number) - Required - Current stock quantity. - `low_stock_threshold` (number) - Optional - Threshold for low stock alerts. - `track_inventory` (boolean) - Optional - Whether to track inventory for this product. - `images` (array) - Optional - List of image objects. - `url` (string) - Required - URL of the image. - `alt` (string) - Optional - Alt text for the image. - `primary` (boolean) - Optional - Whether this is the primary image. - `metadata` (object) - Optional - Custom key-value pairs for additional information. ### Request Example ```json { "name": "Example Widget", "description": "A high-quality example widget.", "category": "Widgets", "price": 19.99, "currency": "USD", "inventory": { "quantity": 100, "low_stock_threshold": 10, "track_inventory": true }, "images": [ { "url": "https://example.com/images/widget1.jpg", "alt": "Front view", "primary": true } ], "metadata": { "color": "blue" } } ``` ### Response #### Success Response (201) - `product` (object) - The newly created product object. #### Response Example { "product": { "id": "new_product_id", "name": "Example Widget", "description": "A high-quality example widget.", "category": "Widgets", "price": 19.99, "currency": "USD", "inventory": { "quantity": 100, "low_stock_threshold": 10, "track_inventory": true }, "images": [ { "url": "https://example.com/images/widget1.jpg", "alt": "Front view", "primary": true } ], "metadata": { "color": "blue" }, "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } } ``` -------------------------------- ### Core Publishing Commands Reference Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md A collection of essential commands for managing monorepo publishing using Yarn and Changesets. These commands cover checking publish status, building packages, running pre-release tests, creating/versioning changesets, publishing, and checking/logging into NPM. ```bash # Check what would be published yarn publish:check # Build all packages yarn build:packages # Test everything before publishing yarn prerelease # Create a changeset yarn changeset # Version packages yarn changeset:version # Publish to npm yarn changeset:publish # Check npm login status yarn npm:check # Login to npm yarn npm:login ``` -------------------------------- ### Troubleshooting: Build Failures and Changeset Issues Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Guidance for resolving build failures before publishing and issues where Changeset might not detect changes. This includes running cleaning and build commands, checking TypeScript and linting errors, and verifying Git status. ```bash # Run `yarn clean` then `yarn build:packages` # Check TypeScript errors: `yarn type-check` # Check linting: `yarn lint` # Ensure you have uncommitted changes # Run `git status` to verify changes exist # Check that you're in a git repository ``` -------------------------------- ### Install Docusaurus Plugins with npm or Yarn Source: https://github.com/signalwire/docusaurus-plugins/blob/main/README.md This snippet shows how to install the Docusaurus LLMS plugins using either npm or Yarn package managers. These packages are essential for integrating LLMS-related functionalities into your Docusaurus site. ```bash npm install @signalwire/docusaurus-plugin-llms-txt @signalwire/docusaurus-theme-llms-txt # or yarn add @signalwire/docusaurus-plugin-llms-txt @signalwire/docusaurus-theme-llms-txt ``` -------------------------------- ### POST /products Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/api_versioned_docs/version-v1/products/index.md Creates a new product in the catalog. ```APIDOC ## POST /products ### Description Creates a new product in the product catalog. Requires a JSON payload with product details. ### Method POST ### Endpoint /v3/products ### Request Body - **name** (string) - Required - The name of the product. - **description** (string) - Required - A detailed description of the product. - **category** (string) - Required - The category the product belongs to. - **price** (number) - Required - The price of the product. - **currency** (string) - Required - The currency of the price (e.g., 'USD', 'EUR'). - **inventory** (object) - Optional - Inventory details. - **quantity** (number) - Required if `track_inventory` is true. - **low_stock_threshold** (number) - Optional. - **track_inventory** (boolean) - Optional, defaults to false. - **images** (array) - Optional - List of image objects for the product. - **url** (string) - Required. - **alt** (string) - Optional. - **primary** (boolean) - Optional. - **metadata** (object) - Optional - Custom metadata fields. ### Request Example ```json { "name": "Example Widget", "description": "A high-quality widget for all your needs.", "category": "Widgets", "price": 19.99, "currency": "USD", "inventory": { "quantity": 100, "track_inventory": true }, "images": [ { "url": "https://example.com/image1.jpg", "primary": true }, { "url": "https://example.com/image2.jpg" } ] } ``` ### Response #### Success Response (201) - **product** (object) - The newly created product object, including its assigned ID and timestamps. #### Response Example ```json { "product": { "id": "prod_12345", "name": "Example Widget", "description": "A high-quality widget for all your needs.", "category": "Widgets", "price": 19.99, "currency": "USD", "inventory": { "quantity": 100, "low_stock_threshold": null, "track_inventory": true }, "images": [ { "url": "https://example.com/image1.jpg", "alt": null, "primary": true }, { "url": "https://example.com/image2.jpg", "alt": null, "primary": false } ], "metadata": {}, "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } } ``` ``` -------------------------------- ### Products API - Get Product by ID Endpoint Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/api_versioned_docs/version-v2/products/index.md This endpoint retrieves a specific product by its unique identifier. It is a simple GET request to the product's specific URL. No specific programming language is associated as this is an HTTP request description. ```http GET /products/{id} ``` -------------------------------- ### Create Docusaurus Site with Classic Template Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/docs/test/level1/level2/level3/level4/deeply-nested-page.md This command generates a new Docusaurus site using the classic template and installs all necessary dependencies. It can be run in any standard terminal environment. Ensure Node.js version 18.0 or above is installed. ```bash npm create docusaurus@latest my-website classic ``` -------------------------------- ### GET /products/{id} Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/api-docs/products/index.md Retrieves a specific product by its ID. ```APIDOC ## GET /products/{id} ### Description Retrieves a specific product by its ID. ### Method GET ### Endpoint https://api.example.com/v3/products/{id} ### Parameters #### Path Parameters - `id` (string) - Required - The unique identifier of the product. ### Response #### Success Response (200) - `product` (object) - The product object. #### Response Example { "product": { "id": "string", "name": "string", "description": "string", "category": "string", "price": 0.0, "currency": "string", "inventory": { "quantity": 0, "low_stock_threshold": 0, "track_inventory": true }, "images": [ { "url": "string", "alt": "string", "primary": true } ], "metadata": {}, "created_at": "string", "updated_at": "string" } } ``` -------------------------------- ### Enter Prerelease Mode for Docusaurus Plugins Source: https://github.com/signalwire/docusaurus-plugins/blob/main/PUBLISHING.md Commands to initiate prerelease mode for Docusaurus plugins. This involves choosing a tag (e.g., 'alpha'), versioning the packages to include the prerelease suffix, committing the changes, and publishing with the specified tag. ```bash # Choose your tag: alpha, beta, rc, etc. yarn prerelease:enter alpha # Version packages (creates 1.0.0-alpha.0, 1.0.0-alpha.1, etc.) yarn prerelease:version # Commit changes git add . git commit -m "Enter alpha prerelease" # Publish with the specified tag yarn prerelease:publish ``` -------------------------------- ### Get Product by ID Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/api_versioned_docs/version-v2/products/index.md Retrieves a specific product by its unique identifier. ```APIDOC ## GET /products/{id} ### Description Retrieves a specific product by its unique identifier. ### Method GET ### Endpoint https://api.example.com/v3/products/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the product. ### Response #### Success Response (200) - **product** (object) - The requested product object. #### Response Example ```json { "id": "string", "name": "string", "description": "string", "category": "string", "price": 0.0, "currency": "string", "inventory": { "quantity": 0, "low_stock_threshold": 0, "track_inventory": true }, "images": [ { "url": "string", "alt": "string", "primary": true } ], "metadata": {}, "created_at": "string", "updated_at": "string" } ``` ``` -------------------------------- ### Users API - Get All Users Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/api_versioned_docs/version-v2/users/index.md Retrieves a paginated list of all users. ```APIDOC ## GET /users ### Description Returns a paginated list of users. ### Method GET ### Endpoint /v3/users ### Parameters #### Query Parameters - **page** (integer) - Optional - The page number to retrieve. - **limit** (integer) - Optional - The number of users per page. ### Response #### Success Response (200) - **users** (array) - A list of user objects. - **id** (string) - The unique identifier for the user. - **email** (string) - The email address of the user. - **name** (string) - The name of the user. - **created_at** (string) - The timestamp when the user was created. - **updated_at** (string) - The timestamp when the user was last updated. - **profile** (object) - Contains user profile information. - **avatar_url** (string) - The URL of the user's avatar. - **bio** (string) - A short biography of the user. - **preferences** (object) - User-defined preferences. #### Response Example { "users": [ { "id": "user123", "email": "test@example.com", "name": "John Doe", "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z", "profile": { "avatar_url": "https://example.com/avatar.jpg", "bio": "Software engineer.", "preferences": {} } } ] } ``` -------------------------------- ### GET /products/{id} Source: https://github.com/signalwire/docusaurus-plugins/blob/main/website/api_versioned_docs/version-v1/products/index.md Retrieves a specific product by its unique identifier. ```APIDOC ## GET /products/{id} ### Description Retrieves a single product by its unique ID. ### Method GET ### Endpoint /v3/products/{id} ### Path Parameters - **id** (string) - Required - The unique identifier of the product. ### Response #### Success Response (200) - **product** (object) - The product object matching the ID. #### Response Example ```json { "product": { "id": "string", "name": "string", "description": "string", "category": "string", "price": "number", "currency": "string", "inventory": { "quantity": "number", "low_stock_threshold": "number", "track_inventory": "boolean" }, "images": [ { "url": "string", "alt": "string", "primary": "boolean" } ], "metadata": {}, "created_at": "string", "updated_at": "string" } } ``` ```