@sales-planner/http-client 0.19.4 → 0.20.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 CHANGED
@@ -18,7 +18,7 @@ const client = new SalesPlannerClient({
18
18
  apiKey: 'your-api-key',
19
19
  });
20
20
 
21
- const ctx = { tenant_id: 1, shop_id: 1 };
21
+ const ctx = { tenantId: 1, shopId: 1 };
22
22
 
23
23
  // CRUD (all list endpoints return paginated responses)
24
24
  const { items: brands, total } = await client.brands.getAll(ctx);
@@ -62,16 +62,16 @@ const { items: salesHistory } = await client.salesHistory.getAll(ctx, { ids: [10
62
62
  **Period Filtering** - Sales history, leftovers, and competitor sales also support period filtering:
63
63
  ```typescript
64
64
  const { items, total } = await client.salesHistory.getAll(ctx, {
65
- period_from: '2024-01',
66
- period_to: '2024-12',
65
+ periodFrom: '2024-01',
66
+ periodTo: '2024-12',
67
67
  limit: 50,
68
68
  offset: 0,
69
69
  });
70
70
 
71
71
  // Same for leftovers and competitor sales
72
72
  const { items: leftovers } = await client.leftovers.getAll(ctx, {
73
- period_from: '2024-01',
74
- period_to: '2024-12',
73
+ periodFrom: '2024-01',
74
+ periodTo: '2024-12',
75
75
  });
76
76
  ```
77
77
 
@@ -80,8 +80,8 @@ const { items: leftovers } = await client.leftovers.getAll(ctx, {
80
80
  // Get specific sales history records with period filter
81
81
  const { items } = await client.salesHistory.getAll(ctx, {
82
82
  ids: [1, 2, 3],
83
- period_from: '2024-01',
84
- period_to: '2024-06',
83
+ periodFrom: '2024-01',
84
+ periodTo: '2024-06',
85
85
  limit: 50,
86
86
  });
87
87
  ```
@@ -112,7 +112,7 @@ const role = await client.roles.getById(1);
112
112
 
113
113
  // User-shop assignments
114
114
  const userShops = await client.userShops.getAll({ shopId: 1 });
115
- await client.userShops.create({ user_id: 1, shop_id: 1 });
115
+ await client.userShops.create({ userId: 1, shopId: 1 });
116
116
  await client.userShops.delete(assignmentId);
117
117
 
118
118
  // Delete all shop data (SKUs, sales history, brands, categories, etc.)
@@ -141,7 +141,7 @@ console.log(metadata); // { entities: [...], version: "..." }
141
141
  SKU metrics and materialized view management:
142
142
 
143
143
  ```typescript
144
- const ctx = { shop_id: 1, tenant_id: 1 };
144
+ const ctx = { shopId: 1, tenantId: 1 };
145
145
 
146
146
  // SKU Metrics - aggregated metrics from materialized views
147
147
  const { items, total } = await client.skuMetrics.list(ctx);
@@ -182,8 +182,8 @@ try {
182
182
  ```typescript
183
183
  // Required for all shop-scoped operations
184
184
  interface ShopContextParams {
185
- shop_id: number;
186
- tenant_id: number;
185
+ shopId: number;
186
+ tenantId: number;
187
187
  }
188
188
 
189
189
  // Pagination (all getAll methods support this)
@@ -195,8 +195,8 @@ interface PaginationQuery {
195
195
 
196
196
  // Period filtering (sales history, leftovers, competitor sales)
197
197
  interface PeriodQuery {
198
- period_from?: string; // YYYY-MM format
199
- period_to?: string; // YYYY-MM format
198
+ periodFrom?: string; // YYYY-MM format
199
+ periodTo?: string; // YYYY-MM format
200
200
  }
201
201
 
202
202
  // Paginated response (returned by all getAll methods)
@@ -216,10 +216,10 @@ All entities extend base interfaces:
216
216
  // Base for shop-scoped entities without code (e.g., SalesHistory)
217
217
  interface ShopScopedBaseEntity {
218
218
  id: number;
219
- shop_id: number;
220
- tenant_id: number;
221
- created_at: Date;
222
- updated_at: Date;
219
+ shopId: number;
220
+ tenantId: number;
221
+ createdAt: Date;
222
+ updatedAt: Date;
223
223
  }
224
224
 
225
225
  // Base for coded entities (e.g., SKUs, Brands, Categories)
@@ -236,45 +236,45 @@ interface User {
236
236
  id: number;
237
237
  email: string;
238
238
  name: string;
239
- default_shop_id: number | null;
240
- created_at: Date;
241
- updated_at: Date;
239
+ defaultShopId: number | null;
240
+ createdAt: Date;
241
+ updatedAt: Date;
242
242
  }
243
243
 
244
244
  interface Tenant {
245
245
  id: number;
246
246
  title: string;
247
- owner_id: number | null;
248
- created_by: number;
249
- created_at: Date;
250
- updated_at: Date;
247
+ ownerId: number | null;
248
+ createdBy: number;
249
+ createdAt: Date;
250
+ updatedAt: Date;
251
251
  }
252
252
 
253
253
  interface Shop {
254
254
  id: number;
255
255
  title: string;
256
- tenant_id: number;
257
- created_at: Date;
258
- updated_at: Date;
256
+ tenantId: number;
257
+ createdAt: Date;
258
+ updatedAt: Date;
259
259
  }
260
260
 
261
261
  interface Role {
262
262
  id: number;
263
263
  name: string;
264
264
  description: string | null;
265
- created_at: Date;
266
- updated_at: Date;
265
+ createdAt: Date;
266
+ updatedAt: Date;
267
267
  }
268
268
 
269
269
  interface ApiKey {
270
270
  id: number;
271
- user_id: number;
271
+ userId: number;
272
272
  key: string;
273
273
  name: string | null;
274
- expires_at: Date | null;
275
- last_used_at: Date | null;
276
- created_at: Date;
277
- updated_at: Date;
274
+ expiresAt: Date | null;
275
+ lastUsedAt: Date | null;
276
+ createdAt: Date;
277
+ updatedAt: Date;
278
278
  }
279
279
  ```
280
280
 
@@ -285,13 +285,13 @@ Coded entities (`Sku`, `Brand`, `Category`, `Group`, `Status`, `Supplier`, `Ware
285
285
  ```typescript
286
286
  interface Sku extends CodedShopScopedEntity {
287
287
  title2?: string | null;
288
- category_id?: number | null;
289
- group_id?: number | null;
290
- status_id?: number | null;
291
- supplier_id?: number | null;
288
+ categoryId?: number | null;
289
+ groupId?: number | null;
290
+ statusId?: number | null;
291
+ supplierId?: number | null;
292
292
  }
293
293
  // Brand, Category, Group, Status, Supplier, Warehouse, Marketplace
294
- // all have just: id, code, title, shop_id, tenant_id, created_at, updated_at
294
+ // all have just: id, code, title, shopId, tenantId, createdAt, updatedAt
295
295
  ```
296
296
 
297
297
  #### Time-Series Entities
@@ -299,37 +299,37 @@ interface Sku extends CodedShopScopedEntity {
299
299
  ```typescript
300
300
  interface SalesHistory {
301
301
  id: number;
302
- sku_id: number;
303
- marketplace_id: number;
302
+ skuId: number;
303
+ marketplaceId: number;
304
304
  period: string; // YYYY-MM format
305
305
  quantity: number;
306
- shop_id: number;
307
- tenant_id: number;
308
- created_at: Date;
309
- updated_at: Date;
306
+ shopId: number;
307
+ tenantId: number;
308
+ createdAt: Date;
309
+ updatedAt: Date;
310
310
  }
311
311
 
312
312
  interface Leftover {
313
313
  id: number;
314
- sku_id: number;
315
- warehouse_id: number;
314
+ skuId: number;
315
+ warehouseId: number;
316
316
  period: string; // YYYY-MM format
317
317
  quantity: number;
318
- shop_id: number;
319
- tenant_id: number;
320
- created_at: Date;
321
- updated_at: Date;
318
+ shopId: number;
319
+ tenantId: number;
320
+ createdAt: Date;
321
+ updatedAt: Date;
322
322
  }
323
323
 
324
324
  interface SeasonalCoefficient {
325
325
  id: number;
326
- group_id: number;
326
+ groupId: number;
327
327
  month: number; // 1-12
328
328
  coefficient: number;
329
- shop_id: number;
330
- tenant_id: number;
331
- created_at: Date;
332
- updated_at: Date;
329
+ shopId: number;
330
+ tenantId: number;
331
+ createdAt: Date;
332
+ updatedAt: Date;
333
333
  }
334
334
  ```
335
335
 
@@ -338,35 +338,35 @@ interface SeasonalCoefficient {
338
338
  ```typescript
339
339
  interface CompetitorProduct {
340
340
  id: number;
341
- marketplace_id: number;
342
- marketplace_product_id: string; // BIGINT as string
341
+ marketplaceId: number;
342
+ marketplaceProductId: string; // BIGINT as string
343
343
  title: string | null;
344
344
  brand: string | null;
345
- shop_id: number;
346
- tenant_id: number;
347
- created_at: Date;
348
- updated_at: Date;
345
+ shopId: number;
346
+ tenantId: number;
347
+ createdAt: Date;
348
+ updatedAt: Date;
349
349
  }
350
350
 
351
351
  interface CompetitorSale {
352
352
  id: number;
353
- competitor_product_id: number;
353
+ competitorProductId: number;
354
354
  period: string; // YYYY-MM format
355
355
  quantity: number;
356
- shop_id: number;
357
- tenant_id: number;
358
- created_at: Date;
359
- updated_at: Date;
356
+ shopId: number;
357
+ tenantId: number;
358
+ createdAt: Date;
359
+ updatedAt: Date;
360
360
  }
361
361
 
362
362
  interface SkuCompetitorMapping {
363
363
  id: number;
364
- sku_id: number;
365
- competitor_product_id: number;
366
- shop_id: number;
367
- tenant_id: number;
368
- created_at: Date;
369
- updated_at: Date;
364
+ skuId: number;
365
+ competitorProductId: number;
366
+ shopId: number;
367
+ tenantId: number;
368
+ createdAt: Date;
369
+ updatedAt: Date;
370
370
  }
371
371
  ```
372
372
 
@@ -382,23 +382,23 @@ Available entity types summary:
382
382
  ```typescript
383
383
  interface SkuMetrics {
384
384
  id: number;
385
- sku_id: number;
386
- shop_id: number;
387
- tenant_id: number;
388
- sku_code: string;
389
- sku_title: string;
385
+ skuId: number;
386
+ shopId: number;
387
+ tenantId: number;
388
+ skuCode: string;
389
+ skuTitle: string;
390
390
  // IDs for API responses (like other entities)
391
- group_id: number | null;
392
- category_id: number | null;
393
- status_id: number | null;
394
- supplier_id: number | null;
395
- last_period: string; // YYYY-MM format
396
- last_period_sales: number; // Total sales for last period
397
- current_stock: number; // Current inventory
398
- days_of_stock: number | null;
399
- abc_class: 'A' | 'B' | 'C'; // A=top 20%, B=next 30%, C=bottom 50%
400
- sales_rank: number; // 1 = highest sales
401
- computed_at: Date;
391
+ groupId: number | null;
392
+ categoryId: number | null;
393
+ statusId: number | null;
394
+ supplierId: number | null;
395
+ lastPeriod: string; // YYYY-MM format
396
+ lastPeriodSales: number; // Total sales for last period
397
+ currentStock: number; // Current inventory
398
+ daysOfStock: number | null;
399
+ abcClass: 'A' | 'B' | 'C'; // A=top 20%, B=next 30%, C=bottom 50%
400
+ salesRank: number; // 1 = highest sales
401
+ computedAt: Date;
402
402
  }
403
403
 
404
404
  // Export uses simple names (like SKUs export), not camelCase
@@ -457,10 +457,10 @@ interface SkuImportResult extends ImportResult {
457
457
  created: number;
458
458
  updated: number;
459
459
  errors: string[];
460
- categories_created: number;
461
- groups_created: number;
462
- statuses_created: number;
463
- suppliers_created: number;
460
+ categoriesCreated: number;
461
+ groupsCreated: number;
462
+ statusesCreated: number;
463
+ suppliersCreated: number;
464
464
  }
465
465
  ```
466
466
 
@@ -1,7 +1,7 @@
1
1
  import type { ApiKey, CreateApiKeyRequest, PaginatedResponse, PaginationQuery } from '@sales-planner/shared';
2
2
  import { BaseClient } from './base-client.js';
3
3
  export interface GetApiKeysQuery extends PaginationQuery {
4
- user_id?: number;
4
+ userId?: number;
5
5
  }
6
6
  export declare class ApiKeysClient extends BaseClient {
7
7
  getAll(query?: GetApiKeysQuery): Promise<PaginatedResponse<ApiKey>>;
@@ -1 +1 @@
1
- {"version":3,"file":"api-keys-client.d.ts","sourceRoot":"","sources":["../../src/clients/api-keys-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,aAAc,SAAQ,UAAU;IACrC,MAAM,CAAC,KAAK,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAMnE,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpC,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxC"}
1
+ {"version":3,"file":"api-keys-client.d.ts","sourceRoot":"","sources":["../../src/clients/api-keys-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,aAAc,SAAQ,UAAU;IACrC,MAAM,CAAC,KAAK,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAMnE,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpC,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxC"}
@@ -1,7 +1,7 @@
1
1
  import type { Tenant, CreateTenantRequest, UpdateTenantRequest, CreateTenantWithShopRequest, TenantWithShopAndApiKey, PaginatedResponse, PaginationQuery } from '@sales-planner/shared';
2
2
  import { BaseClient } from './base-client.js';
3
3
  export interface GetTenantsQuery extends PaginationQuery {
4
- owner_id?: number;
4
+ ownerId?: number;
5
5
  }
6
6
  export declare class TenantsClient extends BaseClient {
7
7
  getAll(query?: GetTenantsQuery): Promise<PaginatedResponse<Tenant>>;
@@ -1 +1 @@
1
- {"version":3,"file":"tenants-client.d.ts","sourceRoot":"","sources":["../../src/clients/tenants-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,aAAc,SAAQ,UAAU;IACrC,MAAM,CAAC,KAAK,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAMnE,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpC,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD,qBAAqB,CACzB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,uBAAuB,CAAC;IAI7B,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxC"}
1
+ {"version":3,"file":"tenants-client.d.ts","sourceRoot":"","sources":["../../src/clients/tenants-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,aAAc,SAAQ,UAAU;IACrC,MAAM,CAAC,KAAK,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAMnE,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpC,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD,qBAAqB,CACzB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,uBAAuB,CAAC;IAI7B,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sales-planner/http-client",
3
- "version": "0.19.4",
3
+ "version": "0.20.0",
4
4
  "description": "HTTP client for Sales Planner API",
5
5
  "author": "Damir Manapov",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "README.md"
25
25
  ],
26
26
  "dependencies": {
27
- "@sales-planner/shared": "0.17.4"
27
+ "@sales-planner/shared": "0.18.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "typescript": "^5.7.3"