@sales-planner/http-client 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # @sales-planner/http-client
2
+
3
+ Type-safe HTTP client for the Sales Planner API.
4
+
5
+ > This package re-exports the client from `@sales-planner/shared`. You can use either package.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @sales-planner/http-client
11
+ # or
12
+ pnpm add @sales-planner/http-client
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import { SalesPlannerClient } from '@sales-planner/http-client';
19
+
20
+ const client = new SalesPlannerClient({
21
+ baseUrl: 'https://sales-planner-back.vercel.app',
22
+ apiKey: 'your-api-key'
23
+ });
24
+
25
+ // Get current user
26
+ const me = await client.getMe();
27
+
28
+ // Get shops
29
+ const shops = await client.getShops();
30
+
31
+ // Get SKUs for a shop
32
+ const skus = await client.getSkus({ shop_id: 1, tenant_id: 1 });
33
+
34
+ // Import sales history
35
+ const result = await client.importSalesHistoryJson([
36
+ { sku_code: 'SKU-001', period: '2026-01', quantity: 100 }
37
+ ], { shop_id: 1, tenant_id: 1 });
38
+ ```
39
+
40
+ ## Available Methods
41
+
42
+ ### Authentication
43
+ - `getMe()` - Get current user with roles and tenants
44
+
45
+ ### Users
46
+ - `getUsers()`, `getUser(id)`, `createUser(dto)`, `deleteUser(id)`
47
+
48
+ ### Tenants
49
+ - `getTenants()`, `getTenant(id)`, `createTenant(dto)`, `updateTenant(id, dto)`, `deleteTenant(id)`
50
+ - `createTenantWithShopAndUser(dto)` - Create tenant with shop and user in one call
51
+
52
+ ### Shops
53
+ - `getShops(tenantId?)`, `getShop(id)`, `createShop(dto)`, `updateShop(id, dto)`, `deleteShop(id)`
54
+ - `deleteShopData(id)` - Delete all data (SKUs, sales history) for a shop
55
+
56
+ ### SKUs
57
+ - `getSkus(ctx)`, `getSku(id, ctx)`, `createSku(dto, ctx)`, `updateSku(id, dto, ctx)`, `deleteSku(id, ctx)`
58
+ - `importSkusJson(items, ctx)`, `importSkusCsv(csvContent, ctx)`
59
+ - `exportSkusJson(ctx)`, `exportSkusCsv(ctx)`
60
+ - `getSkusExampleJson()`, `getSkusExampleCsv()` - Get import format examples
61
+
62
+ ### Sales History
63
+ - `getSalesHistory(ctx, query?)`, `getSalesHistoryItem(id, ctx)`
64
+ - `createSalesHistory(dto, ctx)`, `updateSalesHistory(id, dto, ctx)`, `deleteSalesHistory(id, ctx)`
65
+ - `importSalesHistoryJson(items, ctx)`, `importSalesHistoryCsv(csvContent, ctx)`
66
+ - `exportSalesHistoryJson(ctx, query?)`, `exportSalesHistoryCsv(ctx, query?)`
67
+ - `getSalesHistoryExampleJson()`, `getSalesHistoryExampleCsv()` - Get import format examples
68
+
69
+ ### Roles & User Roles
70
+ - `getRoles()`, `getRole(id)`, `createRole(dto)`, `updateRole(id, dto)`, `deleteRole(id)`
71
+ - `createUserRole(dto)`, `deleteUserRole(id)`
72
+
73
+ ### API Keys
74
+ - `getApiKeys()`, `createApiKey(dto)`, `deleteApiKey(id)`
75
+
76
+ ### Marketplaces
77
+ - `getMarketplaces()`, `getMarketplace(id)`, `createMarketplace(dto)`, `updateMarketplace(id, dto)`, `deleteMarketplace(id)`
78
+
79
+ ## Error Handling
80
+
81
+ ```typescript
82
+ import { SalesPlannerClient, ApiError } from '@sales-planner/http-client';
83
+
84
+ try {
85
+ const user = await client.getUser(999);
86
+ } catch (error) {
87
+ if (error instanceof ApiError) {
88
+ console.log(error.status); // 404
89
+ console.log(error.message); // "User not found"
90
+ }
91
+ }
92
+ ```
93
+
94
+ ## Types
95
+
96
+ All entity types, DTOs, and response types are exported:
97
+
98
+ ```typescript
99
+ import type {
100
+ User, Tenant, Shop, Sku, SalesHistory,
101
+ CreateUserDto, CreateTenantDto, CreateShopDto,
102
+ ShopContextParams, PeriodQuery,
103
+ UserWithRolesAndTenants, ImportResult
104
+ } from '@sales-planner/http-client';
105
+ ```
106
+
107
+ ## License
108
+
109
+ MIT
@@ -0,0 +1,4 @@
1
+ export { SalesPlannerClient, ApiError } from '@sales-planner/shared';
2
+ export type { ClientConfig } from '@sales-planner/shared';
3
+ export type { User, Tenant, Shop, Sku, SalesHistory, Role, UserRole, ApiKey, Marketplace, CreateUserDto, CreateTenantDto, CreateTenantWithShopDto, CreateShopDto, CreateSkuDto, UpdateSkuDto, ImportSkuItem, CreateSalesHistoryDto, UpdateSalesHistoryDto, ImportSalesHistoryItem, CreateApiKeyDto, CreateRoleDto, CreateUserRoleDto, CreateMarketplaceDto, ShopContextParams, PeriodQuery, UserWithRolesAndTenants, TenantWithShopAndApiKey, ImportResult, DeleteDataResult, SkuExportItem, SalesHistoryExportItem, } from '@sales-planner/shared';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACrE,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG1D,YAAY,EAEV,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,GAAG,EACH,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,WAAW,EAEX,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EAEpB,iBAAiB,EACjB,WAAW,EAEX,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,sBAAsB,GACvB,MAAM,uBAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ // Re-export client and types from @sales-planner/shared
2
+ export { SalesPlannerClient, ApiError } from '@sales-planner/shared';
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@sales-planner/http-client",
3
+ "version": "0.1.0",
4
+ "description": "HTTP client for Sales Planner API",
5
+ "author": "Damir Manapov",
6
+ "license": "MIT",
7
+ "keywords": ["sales-planner", "api-client", "http-client", "typescript"],
8
+ "type": "module",
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsc",
23
+ "typecheck": "tsc --noEmit"
24
+ },
25
+ "dependencies": {
26
+ "@sales-planner/shared": "^0.2.0"
27
+ },
28
+ "devDependencies": {
29
+ "typescript": "^5.7.3"
30
+ }
31
+ }