### SDK Installation and Quick Start Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/3.10.comprehensive-testing-documentation.md Instructions for installing the SDK via npm and a quick start example for getting account balance. ```markdown ## Installation ```bash npm install daytona-wildberries-typescript-sdk ``` ## Quick Start ```typescript import { WildberriesSDK } from 'daytona-wildberries-typescript-sdk'; const sdk = new WildberriesSDK({ apiKey: process.env.WB_API_KEY }); // Example: Get account balance const balance = await sdk.finances.getBalance(); console.log(`Balance: ${balance.currentBalance}`); ``` ``` -------------------------------- ### Quickstart Installation Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/5.10.russian-documentation-translation.md Demonstrates the npm command to install the Wildberries TypeScript SDK. This is a standard installation step. ```bash npm install wb-api-sdk ``` -------------------------------- ### Products Module Guide: Quick Start Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/2.10.sdk-integration-documentation.md This TypeScript code snippet demonstrates how to quickly get started with the Products Module of the Wildberries SDK. It shows how to initialize the SDK and perform basic operations like fetching categories and creating a product. ```typescript import { WildberriesSDK } from 'daytona-wildberries-typescript-sdk'; const sdk = new WildberriesSDK({ apiKey: process.env.WB_API_KEY }); // Get categories const parents = await sdk.products.getParentCategories(); const categories = await sdk.products.getCategories(parents.data[0].id); // Create product const product = await sdk.products.createProduct({ brandName: 'YourBrand', categoryId: categories.data[0].id, characteristics: [...] }); ``` -------------------------------- ### SDK Setup and Example Execution Command Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/5.5.complete-example-suite-best-practices.md Shows the basic steps to set up the Wildberries SDK, including exporting the API key and installing the SDK, followed by the command to run a TypeScript example using npx. ```markdown # SDK Examples Working code examples for all Wildberries SDK modules. ## Quick Start 1. Set your API key: `export WB_API_KEY="your_key_here"` 2. Install SDK: `npm install wb-api-sdk` 3. Run any example: `npx tsx examples/example-name.ts` --- ## By Complexity ### Basic Examples (5-10 minutes) | Example | Module | Description | |---------|---------|-------------| | [Hello World](basic/hello-world.ts) | General | Initialize SDK and ping API | | [Get Categories](basic/get-categories.ts) | Products | Fetch product categories | | [List Orders](basic/list-orders.ts) | Orders | Retrieve order list | ### Intermediate Examples (10-30 minutes) | Example | Module | Description | |---------|---------|-------------| | [Product CRUD](intermediate/product-crud.ts) | Products | Create, update, delete products | | [Order Processing](intermediate/order-processing.ts) | Orders | Complete order workflow | | [Tariffs Calculator](intermediate/tariffs-pricing-calculator.ts) | Tariffs | Calculate pricing and fees | | [Promotion Campaign](intermediate/promotion-campaign-automation.ts) | Promotion | Manage promotional campaigns | ### Advanced Examples (30-60 minutes) | Example | Module | Description | |---------|---------|-------------| | [Multi-Module Integration](advanced/integration-product-order-finance.ts) | Multiple | End-to-end workflow | | [Custom Retry Logic](advanced/custom-retry.ts) | Core | Advanced error handling | | [Performance Optimization](advanced/performance-optimization.ts) | Core | Rate limiting and caching | --- ## By Module ``` -------------------------------- ### README Quick Start Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/1.10.main-sdk-class.md Demonstrates the installation and basic usage of the Wildberries SDK, including initialization and a first API call. ```typescript // Install npm install daytona-wildberries-typescript-sdk // Initialize (< 5 minutes) const sdk = new WildberriesSDK({ apiKey: process.env.WB_API_KEY! }); // First API call (< 1 minute) const response = await sdk.general.ping(); console.log('Connected:', response.Status); // 'OK' // Total time: < 30 minutes ✅ ``` -------------------------------- ### SDK Initialization and First API Call Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/1.10.main-sdk-class.md Demonstrates how to install, import, and initialize the WildberriesSDK with an API key, followed by making a simple API call to the general module's ping endpoint. This example is designed for quickstart guides. ```typescript // Complete working example import { WildberriesSDK } from 'daytona-wildberries-typescript-sdk'; async function main() { // Initialize SDK const sdk = new WildberriesSDK({ apiKey: process.env.WB_API_KEY! }); // Make first API call const response = await sdk.general.ping(); console.log('Connected:', response.Status); } main(); ``` -------------------------------- ### Complete Quickstart Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/1.10.main-sdk-class.md A comprehensive example demonstrating SDK initialization with an API key from environment variables, making a 'ping' call, and handling potential connection errors. ```typescript import { WildberriesSDK } from 'daytona-wildberries-typescript-sdk'; async function main() { const sdk = new WildberriesSDK({ apiKey: process.env.WB_API_KEY! }); try { const response = await sdk.general.ping(); console.log('✓ SDK connected:', response.Status); } catch (error) { console.error('Connection failed:', error); } } main(); ``` -------------------------------- ### Quick Start Installation and Usage Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/6.4.homepage-navigation.md Demonstrates how to install and use the SDK to fetch parent categories. Ensure you have an API key. ```typescript import { WildberriesSDK } from 'daytona-wildberries-typescript-sdk'; const sdk = new WildberriesSDK({ apiKey: 'your-api-key' }); const categories = await sdk.products.getParentCategories(); ``` -------------------------------- ### Getting Started Index (docs/getting-started/index.md) Content Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/5.2.documentation-structure-reorganization.md Outlines the content for the 'Getting Started' section, including quick links, prerequisites, and next steps for new users. ```markdown # Getting Started New to the Wildberries TypeScript SDK? This section will get you up and running quickly. ## Quick Links - **[Installation](installation.md)** - Install the SDK via npm - **[Quickstart](quickstart.md)** - Make your first API call in 5 minutes - **[Tutorials](tutorials/)** - Step-by-step guides for common workflows ## Prerequisites - Node.js ≥ 20.0.0 - npm ≥ 10.0.0 - Wildberries API key ([get one here](https://seller.wildberries.ru/)) ## Next Steps 1. [Install the SDK](installation.md) 2. [Complete the quickstart](quickstart.md) 3. Try a [tutorial](tutorials/) for your use case 4. Explore the [API reference](../api/) --- [← Back to Documentation Home](../index.md) ``` -------------------------------- ### Getting Started with Wildberries SDK Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/4.7.sdk-integration-final-testing.md Demonstrates basic SDK setup, connectivity testing, fetching product categories, checking orders, and retrieving account balance. Ensure your WB_API_KEY is set in your environment variables. ```typescript /** * Getting Started with Wildberries SDK * * This example demonstrates basic SDK setup and usage. */ import { WildberriesSDK } from '../src'; async function gettingStarted() { // 1. Initialize SDK const sdk = new WildberriesSDK({ apiKey: process.env.WB_API_KEY || 'your-api-key-here', timeout: 30000, retryConfig: { maxRetries: 3, retryDelay: 1000, exponentialBackoff: true } }); console.log('SDK initialized successfully!\n'); // 2. Test connectivity console.log('Testing API connectivity...'); const isConnected = await sdk.ping(); console.log(`Connection status: ${isConnected ? 'SUCCESS' : 'FAILED'}\n`); // 3. Get product categories console.log('Fetching product categories...'); const categories = await sdk.products.getParentCategories(); console.log(`Found ${categories.data.length} categories:`); categories.data.slice(0, 5).forEach(cat => { console.log(` - ${cat.name} (ID: ${cat.id})`); }); console.log(''); // 4. Check orders console.log('Fetching recent orders...'); const orders = await sdk.ordersFBS.getOrders({ limit: 5 }); console.log(`Found ${orders.orders.length} orders\n`); // 5. Check balance console.log('Fetching account balance...'); const balance = await sdk.finances.getBalance(); console.log(`Current balance: ${balance.balance} ${balance.currency}\n`); console.log('Getting started complete!'); } // Error handling wrapper gettingStarted() .then(() => console.log('\nSuccess!')) .catch(error => { console.error('\nError:', error.message); if (error.name === 'AuthenticationError') { console.error('Tip: Check your API key in .env file'); } }); ``` -------------------------------- ### Project Setup and Initial Commands Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/5.1.community-foundation-files.md Clone the repository, navigate to the project directory, install dependencies, and run initial tests. ```bash git clone https://github.com/salacoste/daytona-wildberries-typescript-sdk.git cd wb-api-sdk npm install npm test ``` -------------------------------- ### SDK Quick Start Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/2.10.sdk-integration-documentation.md A basic example demonstrating how to initialize the Wildberries SDK with an API key and make a simple call to the products module to fetch parent categories. ```typescript import { WildberriesSDK } from 'daytona-wildberries-typescript-sdk'; const sdk = new WildberriesSDK({ apiKey: process.env.WB_API_KEY }); // Products Module const categories = await sdk.products.getParentCategories(); ``` -------------------------------- ### Finances Module Quickstart Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/3.9.sdk-integration-business-modules.md A TypeScript example demonstrating how to initialize the Wildberries SDK and use the finances module to fetch account balance and transactions. Requires an API key to be set in the environment. ```typescript import { WildberriesSDK } from 'daytona-wildberries-typescript-sdk'; const sdk = new WildberriesSDK({ apiKey: process.env.WB_API_KEY }); // Financial Operations const balance = await sdk.finances.getBalance(); console.log(`Current Balance: ${balance.currentBalance}`); const transactions = await sdk.finances.getTransactions({ dateFrom: '2024-01-01', dateTo: '2024-12-31' }); console.log(`Transactions: ${transactions.length}`); ``` -------------------------------- ### Quickstart Guide Initialization Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/1.10.main-sdk-class.md Demonstrates the basic initialization of the WildberriesSDK with an API key. Replace 'YOUR_API_KEY' with your actual key. ```typescript const sdk = new WildberriesSDK({ apiKey: 'YOUR_API_KEY' }); ``` -------------------------------- ### General Module Quickstart Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/3.10.comprehensive-testing-documentation.md Example of using the General module for basic API operations and retrieving seller information. ```typescript import { WildberriesSDK } from 'daytona-wildberries-typescript-sdk'; const sdk = new WildberriesSDK({ apiKey: process.env.WB_API_KEY }); // Ping API await sdk.general.ping(); // Get seller info const info = await sdk.general.sellerInfo(); console.log(`Seller: ${info.name}`); ``` -------------------------------- ### Running Example File Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/1.10.main-sdk-class.md Command to execute the example TypeScript file using tsx. This is used to test the quickstart example. ```bash npx tsx examples/quickstart.ts ``` -------------------------------- ### Sales Analytics Quickstart Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/3.9.sdk-integration-business-modules.md A TypeScript example for using the analytics module of the Wildberries SDK to retrieve sales performance data. This snippet is intended for the README's quickstart section. ```typescript // Sales Analytics ``` -------------------------------- ### VitePress Navigation Configuration Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/6.4.homepage-navigation.md Configures the main navigation links for the VitePress site. Links include Home, Getting Started, Guides, API Reference, Examples, and FAQ. ```typescript nav: [ { text: 'Home', link: '/' }, { text: 'Getting Started', link: '/getting-started/quickstart' }, { text: 'Guides', link: '/guides/best-practices' }, { text: 'API Reference', link: '/api/' }, { text: 'Examples', link: '/examples/' }, { text: 'FAQ', link: '/FAQ' }, ] ``` -------------------------------- ### Translate Navigation Index Pages Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/6.14.comprehensive-russian-translation.md This task involved translating three main navigation index pages (`index.md`) for guides, getting started, and examples into Russian. It also included adding frontmatter metadata and updating internal links to point to the new Russian pages. ```markdown Translate `docs/guides/index.md` to `docs/ru/guides/index.md` (29 lines) Translate `docs/getting-started/index.md` to `docs/ru/getting-started/index.md` (30 lines) Translate `docs/examples/index.md` to `docs/ru/examples/index.md` (40 lines) ``` -------------------------------- ### Example Initialization Command Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/_bmad/bmm/workflows/3-solutioning/create-architecture/steps/step-03-starter.md This is an example of a full starter command with options, to be used for initializing a new project. It should be the first implementation story. ```bash {{full_starter_command_with_options}} ``` -------------------------------- ### Context7 Query for VitePress Installation Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/6.1.vitepress-installation.md Example Context7 queries to resolve VitePress library information and retrieve documentation on installation, configuration, and TypeScript setup. ```typescript // Required Context7 queries: 1. resolve-library-id("vitepress") → get library ID 2. get-library-docs({ context7CompatibleLibraryID: "/vuejs/vitepress", topic: "installation, configuration, typescript config", tokens: 5000 }) ``` -------------------------------- ### VitePress Top Navigation Configuration Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/6.3.typedoc-api-integration.md Configures the main navigation bar in a VitePress site to include links to Home, Getting Started, Guides, API Reference, and FAQ. ```typescript export default defineConfig({ themeConfig: { nav: [ { text: 'Home', link: '/' }, { text: 'Getting Started', link: '/getting-started/quickstart' }, { text: 'Guides', link: '/guides/best-practices' }, { text: 'API Reference', link: '/api/' }, // NEW { text: 'FAQ', link: '/FAQ' } ] } }); ``` -------------------------------- ### Full Media and Pricing Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/2.3.products-media-pricing.md Demonstrates a comprehensive workflow for setting up a product with media and pricing. Includes uploading files/URLs, verifying media, setting prices with discounts, and handling asynchronous task processing. Also shows a workaround for media removal by replacing with a subset of URLs. ```typescript import { WildberriesSDK } from '../src'; import { readFileSync } from 'fs'; const sdk = new WildberriesSDK({ apiKey: process.env.WB_API_KEY! }); async function setupProductWithMediaAndPricing() { const nmID = 12345; // Product from Story 2.2 example // 1. Upload media files console.log('Uploading media files...'); // Option A: Upload file directly const imageBuffer = readFileSync('path/to/image.jpg'); await sdk.products.uploadMediaFile(nmID, imageBuffer, 1); console.log('Image 1 uploaded'); // Option B: Upload via URLs (recommended for multiple files) const mediaURLs = [ 'https://example.com/product-main.jpg', 'https://example.com/product-side.jpg', 'https://example.com/product-back.jpg', 'https://example.com/product-video.mp4' ]; await sdk.products.uploadMediaByURLs(nmID, mediaURLs); console.log('All media uploaded via URLs'); // 2. Verify media uploaded const currentMedia = await sdk.products.getMediaList(nmID); console.log(`Product has ${currentMedia.length} media files`); // 3. Set pricing console.log('Setting prices and discounts...'); const pricingTask = await sdk.products.updatePricing([ { nmID: nmID, price: 2999, // Price in rubles (integer only) discount: 15 // 15% discount } ]); console.log('Pricing task created:', pricingTask.uploadID); // 4. Wait and check pricing task status (async processing) await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2s const taskStatus = await sdk.products.getPricingTaskStatus(pricingTask.uploadID); console.log('Pricing task status:', taskStatus.status); // 5. Verify pricing applied const pricing = await sdk.products.getPricing(nmID); console.log('Current pricing:', pricing[0]); // 6. Remove media (workaround - replace with subset) const keepURLs = mediaURLs.slice(0, 2); // Keep only first 2 await sdk.products.uploadMediaByURLs(nmID, keepURLs); console.log('Media reduced to 2 files'); } setupProductWithMediaAndPricing().catch(console.error); ``` -------------------------------- ### Complete Product Setup Workflow Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/examples/TESTING.md Demonstrates the end-to-end product setup process, including category navigation, creation, media upload, pricing, and stock level configuration. Use this to test the full product lifecycle. ```typescript import { Wildberries } from "@salacoste/daytona"; const wb = new Wildberries({ token: "YOUR_API_TOKEN", }); async function completeProductWorkflow() { // 1. Navigate categories const categories = await wb.products.getCategories(); console.log("Categories retrieved:", categories); const categoryId = categories.categories[0].id; // Example: use the first category // 2. Create product const product = await wb.products.createProduct({ categoryId: categoryId, name: "Example Product", // ... other required product details }); console.log("Product created:", product); // 3. Upload media (using previously shown method) await wb.products.uploadMedia({ productId: product.id, url: "http://example.com/image.jpg", }); // 4. Configure pricing await wb.products.createPricingTask({ productId: product.id, price: "999.99", }); // 5. Set stock levels await wb.products.addStock({ warehouseId: "YOUR_WAREHOUSE_ID", // Replace with a valid warehouse ID sku: product.sku, // Assuming product object has sku quantity: 50, }); console.log("Complete product workflow demonstrated."); } completeProductWorkflow().catch(console.error); ``` -------------------------------- ### Run Media Upload and Pricing Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/examples/README.md Execute the products-media-pricing.ts example using tsx to demonstrate managing product images and pricing, including uploading media, setting prices, and handling bulk updates. ```bash npx tsx examples/products-media-pricing.ts ``` -------------------------------- ### Translate Code Examples in Performance Guide Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/6.14.comprehensive-russian-translation.md All TypeScript code examples within the performance guide were translated into Russian comments. This snippet illustrates the type of translation applied to these examples. ```typescript // Rate limit configuration with global and module-specific limits // Request batching pattern (avoiding sequential, using parallel with rate limits) // Smart scheduling with RateLimiter // HTTP/2 multiplexing configuration with Axios // In-memory caching with NodeCache (5 min TTL) // Redis caching with expiration (5 min) // Smart cache invalidation with Map-based cache // Bulk pricing updates with batching // Parallel report generation workflow // Large report streaming with pipeline // Pagination with generator function for memory efficiency // SDK manager with cleanup and GC // Request timing tracker with metrics (count, avg, min, max, p95, p99) // Heap snapshot profiling with v8 // Benchmark suite with sequential vs parallel comparison ``` -------------------------------- ### Provider Contract Verification CI/CD Workflow Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/_bmad/tea/agents/bmad-tea/resources/knowledge/contract-testing.md This GitHub Actions workflow automates provider contract verification against published pacts. It includes setup for Node.js, dependency installation, starting Docker Compose for dependencies, and running verification tests. ```yaml # .github/workflows/contract-test-provider.yml (Provider side) # NOTE: Canonical naming is contract-test-provider.yml per pactjs-utils conventions name: Pact Provider Verification on: pull_request: push: branches: [main] repository_dispatch: types: [pact_changed] # Webhook from Pact Broker jobs: verify-contracts: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' - name: Install dependencies run: npm ci - name: Start dependencies run: docker-compose up -d - name: Run provider verification run: npm run test:pact:provider:remote:contract env: PACT_BROKER_BASE_URL: ${{ secrets.PACT_BROKER_BASE_URL }} PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }} GITHUB_SHA: ${{ github.sha }} GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }} - name: Can I deploy provider? (main only) if: github.ref == 'refs/heads/main' && env.PACT_BREAKING_CHANGE != 'true' run: npm run can:i:deploy:provider - name: Record provider deployment (main only) if: github.ref == 'refs/heads/main' run: npm run record:provider:deployment --env=dev ``` -------------------------------- ### Track Quickstart Example View Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/6.11.analytics-privacy.md Tracks when a user views the code example on the quickstart page using IntersectionObserver. This event can be used to mark a conversion stage in GA4. ```typescript onMounted(() => { // Track when user reaches code example const codeBlock = document.querySelector('.example-code'); const observer = new IntersectionObserver((entries) => { if (entries[0].isIntersecting) { trackConversion('viewed_quickstart_example'); } }); if (codeBlock) observer.observe(codeBlock); }); ``` -------------------------------- ### Integration Test Setup for Questions API with MSW Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/3.6.communications-qa-reviews.md Sets up an integration test environment using Mock Service Worker (MSW) to intercept and mock HTTP requests to the questions API. This example shows how to configure MSW to respond to GET requests for questions. ```typescript // Integration test pattern with MSW const server = setupServer( http.get('https://feedbacks-api.wildberries.ru/api/v1/questions', ({ request }) => { const url = new URL(request.url); const isAnswered = url.searchParams.get('isAnswered') === 'true'; return HttpResponse.json({ data: { countUnanswered: isAnswered ? 0 : 10, countArchive: isAnswered ? 50 : 0, questions: [ { id: 'q123', text: 'What is the material?', createdDate: '2024-01-15T10:00:00Z', state: isAnswered ? 'wbRu' : 'suppliersPortalSynch', ``` -------------------------------- ### Quick Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/6.3.typedoc-api-integration.md A basic example demonstrating how to instantiate the Wildberries SDK and access its modules to perform common operations. ```APIDOC ## Quick Example ```typescript import { WildberriesSDK } from 'daytona-wildberries-typescript-sdk'; const sdk = new WildberriesSDK({ apiKey: 'your-api-key' }); // Access any of the 11 modules const categories = await sdk.products.getParentCategories(); const orders = await sdk.ordersFBS.getOrders({ limit: 10 }); const balance = await sdk.finances.getBalance(); ``` ``` -------------------------------- ### Install TypeScript Executor Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/examples/TESTING.md Install the TypeScript executor globally to run TypeScript examples. ```bash npm install -g tsx # Install TypeScript executor ``` -------------------------------- ### Full Example: Fetching and Comparing Storage Fees Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/guides/storage-fees-integration.md Demonstrates a complete workflow: initializing the SDK, fetching 'Paid Storage' and 'Weekly Report' data for a specified period, comparing the results, and displaying key metrics and top products by storage fees. ```typescript import { WildberriesSDK } from 'daytona-wildberries-typescript-sdk'; async function main() { const sdk = new WildberriesSDK({ apiKey: process.env.WB_API_KEY! }); // Период W49 (2-8 декабря 2024) const dateFrom = '2024-12-02'; const dateTo = '2024-12-08'; console.log('Fetching Paid Storage data...'); const paidStorage = await getStorageFees(sdk, dateFrom, dateTo); console.log(`Paid Storage Total: ${paidStorage.totalAmount.toFixed(2)}₽`); console.log('Fetching Weekly Report data...'); const weeklyReport = await getWeeklyStorageFees(sdk, dateFrom, dateTo); console.log(`Weekly Report Total: ${weeklyReport.totalStorageFee.toFixed(2)}₽`); // Сравнение const comparison = compareStorageData(paidStorage, weeklyReport); console.log(' === COMPARISON ==='); console.log(`Match: ${comparison.match ? '✅ YES' : '❌ NO'}`); console.log(`Difference: ${comparison.difference.toFixed(2)}₽ (${comparison.differencePercent.toFixed(4)}%)`); console.log(' By Date:'); for (const day of comparison.byDate) { console.log(` ${day.date}: PS=${day.paidStorage.toFixed(2)} WR=${day.weeklyReport.toFixed(2)} diff=${day.diff.toFixed(2)}`); } // Топ товаров по хранению const topProducts = Object.entries(paidStorage.byProduct) .sort((a, b) => b[1].amount - a[1].amount) .slice(0, 10); console.log(' Top 10 Products by Storage:'); for (const [nmId, data] of topProducts) { console.log(` nm_id=${nmId} | ${data.subject} | ${data.amount.toFixed(2)}₽`); } } main().catch(console.error); ``` -------------------------------- ### Examples Index (docs/examples/index.md) Content Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/5.2.documentation-structure-reorganization.md Structures the 'Examples' section, providing an overview and categorization for code examples, starting with basic usage. ```markdown # Examples Working code examples demonstrating SDK usage for common scenarios. ## By Complexity ### Basic Examples - [Hello World](basic/hello-world.md) - Simple SDK initialization - [Single API Call](basic/single-call.md) - Make a basic API request ``` -------------------------------- ### Install VitePress Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/6.1.vitepress-installation.md Installs VitePress as a development dependency. This command is typically run after initial project setup to add documentation capabilities. ```bash npm install vitepress@^1.6.4 --save-dev ``` -------------------------------- ### Web Search for Starter Templates Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/_bmad/bmm/workflows/3-solutioning/create-architecture/steps/step-03-starter.md Use these search queries to find relevant starter templates for your primary technology. Ensure you include terms like 'latest' and 'CLI create command' to find up-to-date and easily usable options. ```bash Search the web: "{{primary_technology}} starter template CLI create command latest" ``` ```bash Search the web: "{{primary_technology}} boilerplate generator latest options" ``` ```bash Search the web: "{{primary_technology}} production-ready starter best practices" ``` -------------------------------- ### Example JavaScript Code Snippet Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/5.9.faq-glossary-documentation.md This is a general example of JavaScript code used within the FAQ. Ensure the SDK is installed and configured before use. ```javascript const { WildberriesSDK } = require("@wildberries/sdk"); const sdk = new WildberriesSDK({ token: "YOUR_API_TOKEN", // other configuration options }); async function exampleUsage() { try { const products = await sdk.catalog.getProducts({ filter: { category_id: 123 }, }); console.log(products); } catch (error) { console.error("Error fetching products:", error); } } ``` -------------------------------- ### Install and Test SDK Dependencies Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/CONTRIBUTING.md Steps to clone the repository, install dependencies, and run tests to ensure a working development environment. ```bash git clone https://github.com/YOUR-USERNAME/daytona-wildberries-typescript-sdk.git cd daytona-wildberries-typescript-sdk npm install npm test ``` -------------------------------- ### Initialize BaseClient and Make GET Request Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/api/classes/BaseClient.md Demonstrates how to configure and instantiate the BaseClient, then use it to perform a GET request to fetch product data. Ensure SDKConfig is properly defined with API key, timeout, and log level. ```typescript const config: SDKConfig = { apiKey: 'your-api-key', timeout: 30000, logLevel: 'debug' }; const client = new BaseClient(config); // Make GET request const data = await client.get( 'https://content-api.wildberries.ru/api/v1/products' ); ``` -------------------------------- ### Example TypeScript Code Snippet Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/5.9.faq-glossary-documentation.md This is a general example of TypeScript code used within the FAQ. Ensure the SDK is installed and configured before use. ```typescript import { WildberriesSDK } from "@wildberries/sdk"; const sdk = new WildberriesSDK({ token: "YOUR_API_TOKEN", // other configuration options }); async function exampleUsage() { try { const products = await sdk.catalog.getProducts({ filter: { category_id: 123 }, }); console.log(products); } catch (error) { console.error("Error fetching products:", error); } } ``` -------------------------------- ### General Project Setup Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/_bmad/bmm/workflows/document-project/templates/index-template.md Commands for setting up and running the project locally. This is typically used for single-part projects. ```bash {{setup_commands}} ``` -------------------------------- ### Install Wildberries SDK and Dependencies Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/examples/README.md Install the Wildberries SDK and its dependencies using npm. This includes commands for both published versions and local development setups. ```bash # Install SDK (when published) npm install wb-api-sdk # For local development npm install # Build SDK npm run build # Install tsx for running examples npm install -g tsx ``` -------------------------------- ### Quickstart Guide First API Call Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/1.10.main-sdk-class.md Illustrates making the first API call using the SDK's 'ping' endpoint. This verifies the SDK is connected and functional. ```typescript await sdk.general.ping(); ``` -------------------------------- ### Install SDK and tsx Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/examples/README.md Install the Wildberries SDK using npm and the tsx tool globally for running TypeScript examples. Ensure Node.js version is >= 20.0.0. ```bash npm install wb-api-sdk ``` ```bash npm install -g tsx ``` -------------------------------- ### Run Multi-Module Integration Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/examples/README.md Execute the script to demonstrate cross-module data flow and integration, from product creation to financial tracking. ```bash export WB_API_KEY="your-api-key" npx tsx examples/integration-product-order-finance.ts ``` -------------------------------- ### ExciseReportRequest Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/api/-internal-/interfaces/ExciseReportRequest.md An example of the ExciseReportRequest object, specifying the countries for which to retrieve excise report data. Leave the 'countries' array empty to get data for all available countries. ```json { "countries": [ "AM", "RU" ] } ``` -------------------------------- ### Setup Project for Authentication Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/_bmad/tea/agents/bmad-tea/resources/knowledge/playwright-config.md Implement a setup project to handle user authentication and save the authentication state. This script logs in a user and stores their session for reuse. ```typescript import { chromium, FullConfig } from '@playwright/test'; import path from 'path'; async function globalSetup(config: FullConfig) { const browser = await chromium.launch(); const page = await browser.newPage(); // Perform authentication await page.goto('http://localhost:3000/login'); await page.fill('[data-testid="email"]', 'test@example.com'); await page.fill('[data-testid="password"]', 'password123'); await page.click('[data-testid="login-button"]'); // Wait for authentication to complete await page.waitForURL('**/dashboard'); // Save authentication state await page.context().storageState({ path: path.resolve(__dirname, '../.auth/user.json'), }); await browser.close(); } export default globalSetup; ``` -------------------------------- ### Complete Product Catalog Sync Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/getting-started/tutorials/product-catalog-sync.md This comprehensive example demonstrates the full product catalog synchronization process, including fetching categories, creating a product, uploading media, and updating pricing. Ensure the SDK is initialized with your API key and necessary environment variables are set. ```typescript import { WildberriesSDK } from 'daytona-wildberries-typescript-sdk'; import { readFileSync } from 'fs'; const sdk = new WildberriesSDK({ apiKey: process.env.WB_API_KEY }); async function syncProductCatalog() { try { // Step 1: Get categories console.log('Step 1: Fetching categories...'); const categories = await sdk.products.getParentAll(); console.log(`✓ Found ${categories.data.length} parent categories\n`); // Step 2: Create product console.log('Step 2: Creating product...'); const productData = { brandName: 'TechBrand', categoryId: '101', title: 'TechBrand Smartphone Pro 15', description: 'Latest smartphone with advanced features', characteristics: [ { id: 'brand', value: 'TechBrand' }, { id: 'model', value: 'Pro 15' }, { id: 'color', value: 'Black' } ], pricing: { price: 59999, discount: 10, currency: 'RUB' } }; const product = await sdk.products.createCardsUpload(productData); console.log(`✓ Product created: ${product.data.id}\n`); // Step 3: Upload media console.log('Step 3: Uploading product images...'); const imagePaths = ['./images/front.jpg', './images/back.jpg']; for (const imagePath of imagePaths) { const imageBuffer = readFileSync(imagePath); await sdk.products.uploadMediaFile({ productId: product.data.id, file: imageBuffer, fileName: imagePath.split('/').pop(), mimeType: 'image/jpeg' }); } console.log(`✓ Uploaded ${imagePaths.length} images\n`); // Step 4: Update pricing console.log('Step 4: Updating pricing...'); await sdk.products.updatePricing({ productId: product.data.id, price: 54999, discount: 15 }); console.log('✓ Price updated\n'); console.log('🎉 Product catalog sync complete!'); console.log(`Product ID: ${product.data.id}`); console.log('Status: Ready for marketplace'); } catch (error) { console.error('❌ Sync failed:', error.message); process.exit(1); } } // Run the sync syncProductCatalog(); ``` -------------------------------- ### Troubleshooting Guide Structure Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/5.8.troubleshooting-guide-debug-resources.md This markdown snippet outlines the structure of a troubleshooting guide, including a quick diagnosis section that links to detailed solutions for common SDK issues. ```markdown # Troubleshooting Guide Quick solutions for common SDK issues. ## Quick Diagnosis **Having issues? Start here:** 1. **Can't authenticate?** → [Authentication Issues](#authentication-issues) 2. **Getting rate limited?** → [Rate Limit Issues](#rate-limit-issues) 3. **Network errors?** → [Network Issues](#network-issues) 4. **Data validation errors?** → [Validation Issues](#validation-issues) 5. **Something else?** → [General Issues](#general-issues) --- ## Authentication Issues ``` -------------------------------- ### Run General Module Example Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/1.9.general-module-implementation.md Execute the example script for the General module to ensure it functions correctly after building. ```bash tsx examples/general.ts ``` -------------------------------- ### Making a GET Request with Custom Headers Source: https://github.com/salacoste/daytona-wildberries-typescript-sdk/blob/main/docs/stories/1.3.base-client.md Example of performing a GET request using the BaseClient, including custom headers via RequestOptions. This demonstrates how to add per-request specific configurations. ```typescript await client.get( 'https://content-api.wildberries.ru/api/v1/products', { headers: { 'X-Custom-Header': 'value' } } ); ```